btop

Post links to your 64bit module repos here. Repo maintainers are responsible for resolving any issues caused by their xzm's.
User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3924
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

btop

Post#1 by ncmprhnsbl » 01 Oct 2021, 06:49

btop is a terminal system monitor and process manager: https://github.com/aristocratos/btop

not a module, but a script to get the latest static build and make a module:
btop-static.pBuild:

Code: Select all

#!/bin/bash
## a script to get and make a module of the latest btop static binary!
# blame: ncmprhnsbl

# Source porteus functions
. /usr/share/porteus/porteus-functions
get_colors

# Check for root
if [ `whoami` != "root" ]; then
	red "Root user, please."
	exit 1
fi

PKG="btop"
TMPDIR=${TMPDIR:-/tmp/pBuild}
FROOT=${TMPDIR}/$PKG/usr/share/$PKG

ARCH="$(uname -m)"

if [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i586 -mtune=i686 -DNDEBUG"
  ARCH="i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC -DNDEBUG"
  LIBDIRSUFFIX="64"
  ARCH="x86_64"
fi

cleanup () {
[ -d $TMPDIR ] && rm -rf $TMPDIR
exit 0
}

create_fake_slack() {
cd $TMPDIR/$PKG
PKGINFO=var/lib/pkgtools/packages
mkdir -p $PKGINFO
echo "PACKAGE NAME: $PKG-static-$VERSION-$ARCH" > $PKGINFO/$PKG-static-$VERSION-$ARCH

cat >> $PKGINFO/$PKG-static-$VERSION-$ARCH << EOS
PACKAGE DESCRIPTION:
btop: btop (Resource monitor)  
btop:  
btop: Resource monitor that shows usage and stats for processor, 
btop: memory, disks, network and processes. 
btop: 
btop: 
btop: 
btop: 
btop: 
btop: 
btop: https://github.com/aristocratos/btop
FILE LIST:
EOS

find * | grep -v var >> $PKGINFO/$PKG-static-$VERSION-$ARCH
}

if [ $(which $PKG 2>/dev/null) ]; then
	CVERSION=$($PKG --version | awk '{print$NF}')
	green "\nCurrently installed version: $CVERSION\n"
else
	CVERSION=0
fi

cyan "Getting latest version info.."
URL=https://github.com/aristocratos/$PKG
VERSION=$(wget release -q -O - $URL | grep /aristocratos/$PKG/releases/tag/v | grep -o [0-9].[0-9].[0-9]*)
if [ $VERSION = $CVERSION ]; then
	green "\nYou have the latest version already. Exiting..\n"
	exit 0
else 
	green "\nLatest version is $VERSION\n"
	read -p "Would you like to get the latest version? [y/n]" -n 1 -r -s && echo 
	if [[ ! $REPLY =~ ^[Yy]$ ]]; then
	echo "Exiting.."
	exit 0
	fi
fi

mkdir -p $FROOT
cd ${TMPDIR}

cyan "Getting the tarball.."
echo
if [ ! -f ${TMPDIR}/$PKG-$VERSION-$ARCH-linux-musl.tbz ]; then
	download $URL/releases/download/v$VERSION/$PKG-$ARCH-linux-musl.tbz ${TMPDIR}
fi

if [ ! -f ${TMPDIR}/$PKG-$ARCH-linux-musl.tbz ]; then
	echo
	red "Download Failed? Exiting.."
	cleanup
fi

cyan "Extracting.."
echo
tar -xvf $PKG-$ARCH-linux-musl.tbz

cyan "Copyting the files.."
echo

cp -a bin $TMPDIR/$PKG/usr
cp -a themes $TMPDIR/$PKG/usr/share/$PKG

if [ $(which strip 2>/dev/null) ]; then
	cyan "Stripping the binary.."
	echo
	strip --strip-unneeded $TMPDIR/$PKG/usr/bin/$PKG
fi

cyan "Adding slack style package database info.."
echo
create_fake_slack

cyan "Compressing the module.."
echo
dir2xzm $TMPDIR/$PKG /tmp/$PKG-static-$VERSION-$ARCH.xzm

green "\nDone.. $PKG-static-$VERSION-$ARCH.xzm is ready in /tmp.\n"
cleanup
usage: make a file named btop-static.pBuild and copy this text to it. then(as root in terminal, in same directory):

Code: Select all

sh btop-static.pBuild
if /usr/bin/strip (either as part of binutils package or if 05-devel.xzm is activated) is present the binary will also be stripped (makes it a bit smaller, totally optional)

script to build a nonstatic(using shared libs) version from source to come...
Last edited by ncmprhnsbl on 17 Dec 2021, 13:17, edited 2 times in total.
Reason: adjusted script
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3924
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

btop

Post#2 by ncmprhnsbl » 01 Oct 2021, 08:45

..and here's one that builds from source (needs 05-devel.xzm activated)
btop.pBuild:

Code: Select all

#!/bin/sh

# pBuild for btop (shared libs)

# Source porteus functions
. /usr/share/porteus/porteus-functions
get_colors

# Check for root
if [ `whoami` != "root" ]; then
	echo "Root user, please."
	exit 1
fi

PRGNAM=btop
VURL="https://github.com/aristocratos/btop"
VERSION=$(wget release -q -O - $VURL | grep /aristocratos/btop/releases/tag/v | grep -o [0-9].[0-9].[0-9]*)
BUILD=${BUILD:-1}
TAG=ncm
SRC_ARCHIVE=${SRC_ARCHIVE:-tar.gz}
URL="${VURL}/archive/refs/tags/v${VERSION}.${SRC_ARCHIVE}"

[ -e v${VERSION}.${SRC_ARCHIVE} ] || wget -c $URL || exit 1

NPROCS=$(cat /proc/cpuinfo | grep processor | wc -l)

ARCH="$(uname -m)"

CWD=$(pwd)
TMP=${TMP:-/tmp/JSB}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

if [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i586 -mtune=i686 -DNDEBUG"
  ARCH="i586"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC -DNDEBUG"
  LIBDIRSUFFIX="64"
else
  SLKCFLAGS="-O2 -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard -DNDEBUG"
  LIBDIRSUFFIX=""
fi

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/v$VERSION.${SRC_ARCHIVE}
cd $PRGNAM-$VERSION
chown -R root:root .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  -o -perm 511 \) -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
cleanup () {
[ -d $TMP ] && rm -rf $TMP
exit 0
}

create_fake_slack() {
cd $PKG
PKGINFO=var/lib/pkgtools/packages
mkdir -p $PKGINFO
echo "PACKAGE NAME: $PRGNAM-$VERSION-$ARCH" > $PKGINFO/$PRGNAM-$VERSION-$ARCH

cat >> $PKGINFO/$PRGNAM-$VERSION-$ARCH << EOS
PACKAGE DESCRIPTION:
btop: btop (Resource monitor)  
btop:  
btop: Resource monitor that shows usage and stats for processor, 
btop: memory, disks, network and processes. 
btop: 
btop: 
btop: 
btop: 
btop: 
btop: 
btop: https://github.com/aristocratos/btop
FILE LIST:
EOS

find * | grep -v var >> $PKGINFO/$PRGNAM-$VERSION-$ARCH
}

CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \

make -j $NPROCS
make DESTDIR=$PKG PREFIX=/usr install

find $PKG | xargs file | grep -e "executable" -e "shared object" \
  | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null

create_fake_slack

dir2xzm $PKG /tmp/$PRGNAM-$VERSION-$ARCH.xzm

green "\n /tmp/$PRGNAM-$VERSION-$ARCH.xzm is ready.\n"
cleanup
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

btop

Post#3 by Ed_P » 01 Oct 2021, 15:41

Thank you ncmp. :)
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

btop

Post#4 by Rava » 03 Oct 2021, 11:31

I had to guess what best call script from #1 and pBuild script from #2.

For now I went with create-btop.pBuild.sh and create-btop.sh

(Not the most intuitive and self-explanatory name choice, but the best I could think of at the blink of an eye)

Since so far I did not download the corresponding 05-devel.xzm, I will only test create-btop.sh… but now I have a reason to download 05-devel.xzm. :D

Added in 7 minutes 6 seconds:
Update
create-btop.sh works like a charm. Image
____________________________________

Request: would be an option to include the man page too much of a hassle?

E.g. call create-btop.sh as create-btop.sh -m would add the man page. :)
Cheers!
Yours Rava

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3924
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

btop

Post#5 by ncmprhnsbl » 03 Oct 2021, 12:42

Rava wrote:
03 Oct 2021, 11:38
I had to guess what best call script from #1 and pBuild script from #2.
look a little closer:
ncmprhnsbl wrote:
01 Oct 2021, 06:49
btop-static.pBuild:
ncmprhnsbl wrote:
01 Oct 2021, 08:45
btop.pBuild:
but you're free to name them whatever you like ;)
Rava wrote:
03 Oct 2021, 11:38
Request: would be an option to include the man page too much of a hassle?
yes, it would... because there is no such thing..
there is btop -h
and in app help: press m for menu and choose help from that.
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

btop

Post#6 by Rava » 03 Oct 2021, 20:12

ncmprhnsbl wrote:
03 Oct 2021, 12:42
Rava wrote:
03 Oct 2021, 11:38
Request: would be an option to include the man page too much of a hassle?
yes, it would... because there is no such thing..
there is btop -h
and in app help: press m for menu and choose help from that.
Stupid me confused this man btop :

Code: Select all

                           Linux Manpages Online - man.cx manual pages (p1 of 4)
   [INS: :INS]

                                    Manpages

   Manpage: ____________________ go

NAME

   btop - convert size in bytes to size in pages (round down)

SYNOPSIS

   #include <sys/ddi.h>

   unsigned long btop(unsigned long numbytes);

INTERFACE LEVEL

   Architecture independent level 1 (DDI/DKI).

(NORMAL LINK) Use right-arrow or <return> to activate.
  Arrow keys: Up and Down to move.  Right to follow a link; Left to go back.
 H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list 
as the same btop. :wall:

As for the names, have to check if mousepad and geany and mcedit do syntax highlighting when using .pBuild extension.
Cheers!
Yours Rava

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3924
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

btop

Post#7 by ncmprhnsbl » 04 Oct 2021, 01:45

Rava wrote:
03 Oct 2021, 20:12
As for the names, have to check if mousepad and geany and mcedit do syntax highlighting when using .pBuild extension.
text editors should (auto)set syntax highlighting based on content, not file extension.. in any case i doubt that .pBuild would be recognized, since it's origin is here: pBuild Scripts
as i said, name them however you like, it's just a bash script.
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

btop

Post#8 by Rava » 04 Oct 2021, 09:10

ncmprhnsbl wrote:
04 Oct 2021, 01:45
text editors should (auto)set syntax highlighting based on content, not file extension..
Indeed they should, but won't.

Try it out: have the same script (sh or bash) either as name or as name.sh.

Mousepad will set syntax highlighting for name.sh, but will display name as text and you manually have to do the menu/submenu hopping to set it to sh [Main menu Document ▷ Filetype ▷ Scripts ▷ sh ]

Therefore when creating a script and using mousepad I name it whatever.sh and debug it till satisfied, and when finished I rename it whatever.

Have to check if geany does it correct (as you said: syntax highlighting based on content, not extension)
Cheers!
Yours Rava

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3924
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

btop

Post#9 by ncmprhnsbl » 19 Oct 2021, 03:34

btop-static module build/updater script updated(first post):
to accomodate the new tarball naming : btop-$VERSION-$ARCH-linux-musl.tbz
the static build is now built with musl(libc) , which probably makes it smaller, faster and a little lighter on memory..
did you know? : you can have your cpu temp(s) show in the very sensible degrees kelvin :D (among others)
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

btop

Post#10 by Rava » 19 Oct 2021, 18:02

^
Thanks. Oh and I prefer °Celsius. :D

Since I forgot to add above: geany does indeed the syntax highlighting based on content, not extension. B)
Cheers!
Yours Rava

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3924
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

btop

Post#11 by ncmprhnsbl » 17 Dec 2021, 13:21

adjusted the build script for the static version(first post) to accommodate the new unversioned naming of the .tbz
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

btop

Post#12 by Rava » 18 Dec 2021, 08:26

ncmprhnsbl wrote:
17 Dec 2021, 13:21
adjusted the build script for the static version(first post) to accommodate the new unversioned naming of the .tbz
It creates the module just fine, still I wanted to look into the tarball and since your script deletes that I tried the URL the script reports:

Code: Select all

Would you like to get the latest version? [y/n]
 Getting the tarball.. 

Downloading: btop-x86_64-linux-musl.tbz https://objectsgithubusercontentcom/github-production-release-asset-2e65be/365005377/e862c999-7e5e-4f4e-8128-9b48f8c018ec?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20211218%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211218T081529Z&X-Amz-Expires=300&X-Amz-Signature=c9abb675bd8386fd24a7a0a72e0f11cb89f0911e91b0ebd60da87bc9e29717db&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=365005377&response-content-disposition=attachment%3B%20filename%3Dbtop-x86_64-linux-musltbz&response-content-type=application%2Foctet-st09:15: DONE
but of course that is no valid URL:

Code: Select all

wget "https://objectsgithubusercontentcom/github-production-release-asset-2e65be/365005377/e862c999-7e5e-4f4e-8128-9b48f8c018ec?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20211218%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211218T081529Z&X-Amz-Expires=300&X-Amz-Signature=c9abb675bd8386fd24a7a0a72e0f11cb89f0911e91b0ebd60da87bc9e29717db&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=365005377&response-content-disposition=attachment%3B%20filename%3Dbtop-x86_64-linux-musltbz&response-content-type=application%2Foctet-st09:15"
The destination name is too long (466), reducing to 236
--2021-12-18 09:21:46--  https://objectsgithubusercontentcom/github-production-release-asset-2e65be/365005377/e862c999-7e5e-4f4e-8128-9b48f8c018ec?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20211218%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211218T081529Z&X-Amz-Expires=300&X-Amz-Signature=c9abb675bd8386fd24a7a0a72e0f11cb89f0911e91b0ebd60da87bc9e29717db&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=365005377&response-content-disposition=attachment%3B%20filename%3Dbtop-x86_64-linux-musltbz&response-content-type=application%2Foctet-st09:15
Resolving objectsgithubusercontentcom (objectsgithubusercontentcom)... failed: Name or service not known.
wget: unable to resolve host address ‘objectsgithubusercontentcom’
I presume the URL not starts with objectsgithubusercontentcom/ as the script reports (which is no valid URL), but maybe
objects.githubusercontent.com/ instead?
Or is it
objects.github.usercontent.com/ ?
Cheers!
Yours Rava

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3924
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

btop

Post#13 by ncmprhnsbl » 18 Dec 2021, 13:12

Rava wrote:
18 Dec 2021, 08:26
It creates the module just fine, still I wanted to look into the tarball and since your script deletes that I tried the URL the script reports:
try reading the script ;)
PKG="btop"
URL=https://github.com/aristocratos/$PKG
VERSION=$(wget release -q -O - $URL | grep /aristocratos/$PKG/releases/tag/v | grep -o [0-9].[0-9].[0-9]*)
download $URL/releases/download/v$VERSION/$PKG-$ARCH-linux-musl.tbz
where github actually keeps it's stuff is irrelevant...
and if you want to keep the tarball, just comment "cleanup"
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

btop

Post#14 by Rava » 18 Dec 2021, 20:26

ncmprhnsbl wrote:
18 Dec 2021, 13:12
try reading the script ;)
That one time I try relying on a script output…
Just kidding… when too lazy analysing the script and presuming things instead of knowing things (you know, e.g. after not only analysing the script but also understanding it) … coming to a wrong conclusion is only on me. :ROFL:
ncmprhnsbl wrote:
18 Dec 2021, 13:12
URL=https://github.com/aristocratos/$PKG
VERSION=$(wget release -q -O - $URL | grep /aristocratos/$PKG/releases/tag/v | grep -o [0-9].[0-9].[0-9]*)
download $URL/releases/download/v$VERSION/$PKG-$ARCH-linux-musl.tbz
So, the "download" function not verbatim prints the accessed URL as I presumed…
Well, that can be added. :D

I presume the "download" function is included via

Code: Select all

# Source porteus functions
. /usr/share/porteus/porteus-functions
Since currently being on Port 4.0 I not look into /usr/share/porteus/porteus-functions since it could differ from 5.0 version.
On the other hand… scripts like yours would malfunction if /usr/share/porteus/porteus-functions would be unreliable. I make a md5sum between Port 5.0rc3 and Port 4.0 /usr/share/porteus/porteus-functions - and when the checksum differs I make a diff.
ncmprhnsbl wrote:
18 Dec 2021, 13:12
and if you want to keep the tarball, just comment "cleanup"
Will do. That's the easiest way. :juggler:
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

btop

Post#15 by Ed_P » 19 Dec 2021, 06:33

It is too bad this approach
ncmprhnsbl wrote:
18 Dec 2021, 13:12
URL=https://github.com/aristocratos/$PKG
VERSION=$(wget release -q -O - $URL | grep /aristocratos/$PKG/releases/tag/v | grep -o [0-9].[0-9].[0-9]*)
download $URL/releases/download/v$VERSION/$PKG-$ARCH-linux-musl.tbz
can't be used with https://www.mediafire.com/ downloads. :x
Ed

Post Reply