2021 Updated Nemesis Base Modules

Arch based Porteus community project
biotec
White ninja
White ninja
Posts: 27
Joined: 23 Jan 2014, 23:50
Distribution: slackware
Location: Oviedo

2021 Updated Nemesis Base Modules

Post#226 by biotec » 09 Mar 2021, 23:24

Yes, that was the script I meant.

I answered to your PM.

User avatar
M. Eerie
Shogun
Shogun
Posts: 428
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce x64

2021 Updated Nemesis Base Modules

Post#227 by M. Eerie » 11 Mar 2021, 12:39

Hi ncmprhnsbl,

Code: Select all

perl-uri
exists in both XFCE and DEVEL modules.

@Ed. You've got PM

Thanks
> Does not compute_ 🖖

User avatar
M. Eerie
Shogun
Shogun
Posts: 428
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce x64

2021 Updated Nemesis Base Modules

Post#228 by M. Eerie » 15 Mar 2021, 10:54

Thanks to @Ed for updating the script for me.

@biotec I've tested by login as root (/etc/conf.d/agetty.tty1 -> agetty_options = "- autologin = root"), same result. Everything updates, but login with admin pw is somehow mixed with guest/root accounts.

I've sent you a PM.

Thanks.
> Does not compute_ 🖖

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3263
Joined: 20 Mar 2012, 03:42
Distribution: 5.0-current-64bit
Location: australia
Contact:

2021 Updated Nemesis Base Modules

Post#229 by ncmprhnsbl » 16 Mar 2021, 12:49

2021-03-16 base modules updated and added 003-lxde..
notes:
various package updates..
core:
moved libx11 to gui (not sure why it was in core..)
tweaked udev-update-fstab to be more arch compliant..
put libquadmath.so (gcc-libs) back (from devel) .. may actually be useful..eg. galculator
added /etc/pacman.d/archive-mirror and archive-mirror-arch mirror links for "frozen" archive of the repos set to the date of the build.. to use, backup the standard mirrorlists and rename them(archive-mirror and archive-mirror-arch) to mirror and mirror-arch. this is an easy way to avoid conflicting packages when adding(or updating) extra software.. note that setup-pman will overwrite this.. will look into somehow incorporating this as an option in setup-pman..

xfce4:
removed perl-uri (no idea why it got there :p) thanks M. Eerie
cleaned up some exo menu items
biotec wrote:
09 Mar 2021, 13:38
c) I would like to use lxde
003-lxde added :
packages included:

Code: Select all

atkmm
cairomm
dunst
epdfview
file-roller
galculator
gconf
gcr
giblib
glibmm
gnome-keyring
gparted
gpicview
gtk-engine-murrine
gtk3
gtkmm3
13lock
iso-codes
json-glib
leafpad
libappindicator-gtk3
libcanberra
libcloudproviders
libdbusmenu-glib
libdbusmenu-gtk3
libfm
libfm-extra
libfm-gtk2
libgnome-keyring
libgtop
libindicator-gtk3
libnma
libnotify
libsigc++
libxss
lxappearance
lxappearance-obconf
lxde-common
lxhotkey
lxinput
lxlauncher
lxmenu-data
lxmusic
lxpanel
lxrandr
lxsession
lxtask
lxterminal
menu-cache
mobile-broadband-provider-info
network-manager-applet
nm-connection-editor
pangomm
pcmanfm
poppler
poppler-glib
rest
scrot
sound-theme-freedesktop
vte3
wayland-protocols
xcb-util-xrm
xmms2
bug: unwanted system mounts(proc,sys,dev,pts) showing in filemanager (this is solved in slackware porteus, not sure how yet)(some gvfs trick..)
note; to unlock screenlocker i3lock, just type password and press enter

@M.Eerie, i havn't forgotten your update script, and will probably include it, at some point..
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

User avatar
M. Eerie
Shogun
Shogun
Posts: 428
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce x64

2021 Updated Nemesis Base Modules

Post#230 by M. Eerie » 27 May 2021, 09:14

ncmprhnsbl wrote:
16 Mar 2021, 12:49
added /etc/pacman.d/archive-mirror and archive-mirror-arch mirror links for "frozen" archive
This is a gift. With recent update, mousepad (0.5.5-2) was resizing the window unexpectedly, so I've been able to fixit by installing the previous version (0.5.4-1). Just download and downgrade:

Code: Select all

pacman -U mousepad-0.5.4-1-x86_64.pkg.tar.zst
Thanks! :)
> Does not compute_ 🖖

User avatar
M. Eerie
Shogun
Shogun
Posts: 428
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce x64

2021 Updated Nemesis Base Modules

Post#231 by M. Eerie » 06 Jun 2021, 10:49

M. Eerie wrote:
27 May 2021, 09:14
mousepad (0.5.5-2) was resizing the window unexpectedly
Ok, fixed with the usual:

Code: Select all

$ glib-compile-schemas /usr/share/glib-2.0/schemas
Note: Maybe I'm wrong, but it seems like recent ffmpeg versions depends on zimg and libgomp (from gcc-libs package). Since I was explicitly deleting that library in the stripping part of my updating script, I have to check it out.
> Does not compute_ 🖖

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3263
Joined: 20 Mar 2012, 03:42
Distribution: 5.0-current-64bit
Location: australia
Contact:

2021 Updated Nemesis Base Modules

Post#232 by ncmprhnsbl » 06 Jun 2021, 12:52

M. Eerie wrote:
06 Jun 2021, 10:49
recent ffmpeg versions depends on zimg
yep, in march : https://github.com/archlinux/svntogit-p ... 5eb9b7203a
i'll add it to my list, thanks :)
libgomp, i guess is (one of?)the gcc-lib that aom requires.. which goes back to 2018..
i only recently stripped gcc-libs(export to devel actually) and libgomp was one that i kept.. just following porteus slackware..
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

User avatar
M. Eerie
Shogun
Shogun
Posts: 428
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce x64

2021 Updated Nemesis Base Modules

Post#233 by M. Eerie » 07 Jun 2021, 07:56

> Does not compute_ 🖖

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3263
Joined: 20 Mar 2012, 03:42
Distribution: 5.0-current-64bit
Location: australia
Contact:

2021 Updated Nemesis Base Modules

Post#234 by ncmprhnsbl » 07 Jun 2021, 08:10

M. Eerie wrote:
07 Jun 2021, 07:56
svt-av1 needs to be added too..
indeed, well spotted.. added , thanks
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

User avatar
M. Eerie
Shogun
Shogun
Posts: 428
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce x64

2021 Updated Nemesis Base Modules

Post#235 by M. Eerie » 24 Sep 2021, 19:19

@Anyone interested and using this script to update Nemesis base modules:

Can you please check the script, starting Nemesis with these parameters?

Code: Select all

 login=root base_only copy2ram
Also, you need to change this line:

Code: Select all

[[ $EUID -ne 0 ]] && su -c "$SC $*"
with this one:

Code: Select all

[[ $EUID -eq 0 ]] || su -c "$0"; [[ $? -eq 1 ]] && exit 
You can get Nemesis new ISO's and modules here.

Thanks
> Does not compute_ 🖖

User avatar
M. Eerie
Shogun
Shogun
Posts: 428
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce x64

2021 Updated Nemesis Base Modules

Post#236 by M. Eerie » 30 Oct 2021, 10:18

This could be considered the most recent version pending the 'fakeroot' patch.

Code: Select all

#!/bin/bash
# UPnemesis-base (alias upbase)
# Updates NEMESIS base modules ( $PORTDIR/base )
#
# https://forum.porteus.org/viewtopic.php?p=85205#p85205
#

[[ $EUID -eq 0 ]] || su -c "$0" #FIXME [[ $? -ne 0 ]] && exit

confirm() { echo; tput bold; tput setaf 6; read -n1 -rsp "$1"; tput sgr0; echo -e "\n"; [[ $REPLY =~ ^[Yy]$ ]]; }
warn() { echo; echo "$(tput setaf 1) $1 $(tput sgr0)"; echo; }; 
[ ! $(grep -o 'base_only' /proc/cmdline) ] && warn "Please start Nemesis with **Always Fresh** boot parameters" && exit
mirrorlist-toggle ### Allow updating base

the_end() {
	cd /tmp/updBASE || exit
	[[ -z $(\ls -A LOCALES) ]] || dir2xzm LOCALES LOCALES.xzm
	rm -r LOCALES "$outMOD" >/dev/null 2>&1
	echo " All Done!"; echo "Your files are here: $PWD"; xdg-open . & disown ### FIXME // exo-open . // thunar .
	unset pkgAdd pkgRem outMOD
	eval "exit $?"
}
trap the_end SIGHUP SIGINT SIGTERM #SIGQUIT  EXIT HUP INT TERM

### stat -c '%A %a %G %g %n' $(find ./usr/bin -mindepth 1 -maxdepth 1 '(' -type f -not -perm 0755 ')') -o '(' -type d -not -perm 0755 ')' ### -o '(' -type f -not -perm 0644 ')') #FIXME
fixPERMS() {
	chmod -f 711 "$1"/var/db/sudo/ >/dev/null 2>&1
	chmod -f 700 "$1"/var/db/sudo/lectured/ "$1"/var/lib/NetworkManager/ "$1"/etc/NetworkManager/system-connections/ >/dev/null 2>&1
	chmod -f 750 "$1"/root "$1"/etc/sudoers.d/ "$1"/etc/openvpn/{client,server}/ "$1"/{usr/share,etc}/polkit-1/rules.d/ >/dev/null 2>&1
	chmod -f 755 "$1"/etc "$1"/etc/local.d "$1"/usr "$1"/usr/local "$1"/usr/local/bin >/dev/null 2>&1
	chmod -f 555 "$1"/{proc,sys}/ "$1"/srv/ftp >/dev/null 2>&1
	chmod -f 775 "$1"/var/games >/dev/null 2>&1
	chmod -f 1777 "$1"/var/{spool/mail,tmp} >/dev/null 2>&1
	find "$1"/usr/share/icons -type d -exec chmod 755 {} + >/dev/null 2>&1
	find "$1"/usr/share/icons -type f -exec chmod 644 {} + >/dev/null 2>&1
}

### Bypass adwaita-icon-theme
remADWAITA() {
	[ -d "$1"/usr/share/icons/Adwaita ] || return
	rm "$1"/usr/share/mime/packages/freedesktop.org.xml "$1"/usr/lib/gtk-2.0/2.10.0/engines/libadwaita.so >/dev/null 2>&1
	rm -r "$1"/usr/share/icons/{Adwaita,Adwaita-dark,HighContrast} >/dev/null 2>&1 #FIXME
}

### [[ $? = 1 ]]
prepareSYS() {
	fixPERMS ""
	### WORKAROUND to --> "Please ensure you have a connection and try again. Exit code: 1" /// caused by /etc/local.d/firewall.start
	setup-pman || { pacman-db-upgrade; haveged; pacman-key --init; pacman-key --populate archlinux artix; pkill haveged; update-ca-trust; pacman -Sy; }
	[[ $(pacman -Qu | wc -l) -eq 0 ]] || pacman -Syyu --overwrite '*' ### --ignore '*' >/dev/null
	mkdir /tmp/updBASE || exit ### avoid iterations
	clear; echo "  Main system: updated  "; echo #FIXME
}

patchCORE() {
# mount -t proc proc proc/
# mount -t sysfs sys sys/
# mount --bind /dev dev/
# mount -t devpts pts dev/pts/ rw,mode=0620,gid=5 0 0
# umount -R "$1"/{proc,sys,dev}
	#for mp in proc sys dev dev/pts run; do mount --bind /$mp /tmp/"$outMOD"/$mp; done &
	#chroot /tmp/"$outMOD" /bin/bash

### Pre/Post transaction hooks
	# *** WARNING: USE THEM AT YOUR OWN RISK ***
	# THESE ARE SOME TASKS ('HOOKS') EXECUTED AFTER PACMAN FINISHES UPDATING PACKAGES
	# YOU CAN FIND THESE LOCATED AT: /usr/share/libalpm/hooks/
	# THEY NEED TO BE EXECUTED IN REAL ENVIRONMENT, SO YOU NEED TO chroot PRIOR TO USE THEM
	# MOST OF THEM WILL FAIL UNLESS YOU RECREATE A INSTALLED SYSTEM WITH THE NEEDED MOUNTPOINTS
	# *** YOU'VE BEEN WARNED ***

	pacman-db-upgrade -r /tmp/updBASE/"$outMOD"
	sysusers --root=/tmp/updBASE/"$outMOD"/ ### emulates '20-sysusers.hook' execution in our target root #FIXME
	tmpfiles --root=/tmp/updBASE/"$outMOD"/ --create #FIXME
	# usr/bin/update-ca-trust
	# usr/bin/gio-querymodules usr/lib/gio/modules
	# usr/bin/gtk-query-immodules-3.0 --update-cache
	# usr/bin/gdk-pixbuf-query-loaders --update-cache
	# usr/share/libalpm/scripts/gtk-update-icon-cache
	# glib-compile-schemas usr/share/glib-2.0/schemas
	# usr/share/libalpm/scripts/openrc-hook sysctl
	# usr/share/libalpm/scripts/openrc-hook reexec
	# usr/share/libalpm/scripts/dconf-update
	# usr/share/libalpm/scripts/openrc-hook reload dbus
	# umount -R {proc,sys,dev} ### WARNING
	#for mp in proc sys dev dev/pts; do mount --bind /$mp /$mp; done &
	return
}

updateBASE() {
	[ -d /tmp/updBASE ] || prepareSYS
	cd /tmp/updBASE || exit
	[ -d LOCALES ] || mkdir -p LOCALES
	PS3=$'\n'$'\e[00;36mPlease, select base module to update or exit (1-8): \e[0m'
	select outMOD in 003-lxde 003-mate 003-xfce 002-xtra 002-gui 05-devel 001-core end #FIXME
	do
		pkgAdd=""
		pkgRem=""
		case $outMOD in
			*lxde) pkgAdd=""; pkgRem="";; ### --overwrite '*' #FIXME
			*mate) pkgAdd=""; pkgRem="";; ### --overwrite '*' #FIXME
			*xfce) pkgAdd=""; pkgRem="";; ### --overwrite '*' #FIXME
			*xtra) pkgAdd=""; pkgRem="";; ### --overwrite '*' #FIXME
			 *gui) pkgAdd=""; pkgRem="";; ### --overwrite '*' #FIXME
			*devel) pkgAdd=""; pkgRem="";; ### --overwrite '*' #FIXME
			*core) pkgAdd=""; pkgRem="";; ### --overwrite '*';; ### --ignore '*' #FIXME
			end*) the_end;;
		esac
	#outMOD="$(basename "$(\ls -1 "$PORTDIR"/base/*$outMOD*)" | cut -d- -f-2)" ### \ls escapes user alias ;) #FIXME
	break
	done

	### rsync -a /mnt/live/memory/images/$outMOD*.xzm/ "$outMOD" ### unsquash uses parallel processing and seems to be faster #FIXME
    ### -b, --dbpath <path>  set an alternate database location --cachedir "/var/cache/pacman/pkg" #FIXME
	unsquashfs -f -d "$outMOD" /mnt/live/memory/copy2ram/"$outMOD"*
	cp -au --parents /var/lib/pacman/{sync/,local/ALPM_DB_VERSION} "$outMOD"
	if [[ $(pacman -Qur "$outMOD" | wc -l) -eq 0 ]]; then warn "$outMOD is up to date"; rm -r "$outMOD"; return; fi
	pacman -Qqnr "$outMOD" | pacman -Sddur "$outMOD" --overwrite '*' --noconfirm --needed - ### --ignore '*'
### pacman -r "$outMOD" --cachedir="/var/cache/pacman/pkg" -U /var/cache/pacman/pkg/*.{zst,xz}
	### Add / Remove packages --> Useful i.e. to avoid duplicate database entries
	[[ -z $pkgAdd ]] || eval "pacman -Sddr $outMOD $pkgAdd"
	[[ -z $pkgRem ]] || eval "pacman -Rddr $outMOD $pkgRem"
	#pacman -Qqmr $outMOD | pacman -Rddr $outMOD - ### Qq existing Qqn native Qqm foreign (aur,etc.), Qqt unrequired Qqe explicit QQd dependencies // pacman -Qet explicitly installed and not required as dependencies

cd /tmp/updBASE/"$outMOD" || exit
	### ADDED Get usr locale environment from cheatcodes and $LANG env variable
	KMAP=$(grep -Eo " kmap=[^ ]+" /proc/cmdline | cut -d= -f2)
	[[ -z $LANG ]] && LANG="$KMAP" || LANG="${LANG%.*}"
	[[ -z $LANG ]] && warn "Couldn't set your locale config" ### get_locale
	###	find usr/share/locale \( -name 'e[ns]_[EU]S' -o -name 'e[ns]' -o -iname 'locale.alias' \) -exec cp -au --parents {} /tmp/LOCALES \;
	find usr/share/locale \( -name "en" -o -name "en_US" -o -name "$KMAP" -o -name "$LANG" -o -iname 'locale.alias' \) -exec cp -au --parents {} /tmp/updBASE/LOCALES \;
	unset KMAP

	### strip out ~ 270 MB from core stuff
	[[ "$outMOD" = "001-core" ]] && {
		#patchCORE  ### OMIT BY DEFAULT chgrp root etc/shadow*
		rm -r usr/lib/{libasan,libgfortran,libgo,libtsan}.so* usr/lib/*.a usr/bin/js78* lib/pkgconfig usr/share/i18n/charmaps/*.gz >/dev/null 2>&1 #FIXME libgomp, seems to be necessary for ffmpeg
	}
	rm -r usr/share/{doc,gir-1.0,gtk-doc,info,licenses,locale,man} usr/include/* usr/lib/systemd/* tmp/* var/lib/pacman/{sync/,local/ALPM_DB_VERSION} >/dev/null 2>&1

cd /tmp/updBASE || exit
	fixPERMS "$outMOD"
	[ -d "$outMOD"/home/guest ] && chown -R 1000.1000 "$outMOD"/home/guest >/dev/null 2>&1
	#confirm "Press any key when ready "
	mv "$outMOD"/var/log/pacman.log "$outMOD"-pacman.log >/dev/null 2>&1
	dir2xzm "$outMOD" "$outMOD-$(date '+%Y%m%d').xzm"
	rm -r "$outMOD"
}

# Main loop
while confirm "Shall we update [y/*]? "; do updateBASE; done

warn " Aborted. Exit code: $?"

Last edited by M. Eerie on 07 Nov 2021, 22:58, edited 7 times in total.
> Does not compute_ 🖖

Jack
Contributor
Contributor
Posts: 1726
Joined: 09 Aug 2013, 14:25
Distribution: Porteus 4.0rc4 My Mate 64 bit
Location: USA

2021 Updated Nemesis Base Modules

Post#237 by Jack » 30 Oct 2021, 17:16

Should 1-6 be change to 1-7? Maybe another number.

Code: Select all

PS3=$'\n'$'\e[00;36mPlease, select base module to update or exit (1-6): \e[0m'
	select outMOD in 003-lxde 003-mate 003-xfce 002-xtra 002-gui 05-devel 001-core end #FIXME
	do
I just like Slackware because I think it teach you about Linux to build packages where Ubuntu is like Windows you just install programs you want.

User avatar
M. Eerie
Shogun
Shogun
Posts: 428
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce x64

2021 Updated Nemesis Base Modules

Post#238 by M. Eerie » 31 Oct 2021, 11:30

Jack wrote:
30 Oct 2021, 17:16
Should 1-6 be change to 1-7?
Indeed. Last minute, I've added 003-mate as another option for you to update. But the menu should be presented it in correct order anyway.

Corrected. Thanks!

(Actually it should be 8...)
> Does not compute_ 🖖

User avatar
M. Eerie
Shogun
Shogun
Posts: 428
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce x64

2021 Updated Nemesis Base Modules

Post#239 by M. Eerie » 10 Nov 2021, 12:52

Reworked script. Fakeroot included. Still needs fine-tuning to deal with root account.

Code: Select all

#!/usr/bin/env bash
# ------------------------------------------------------
# update-base
# Updates NEMESIS base modules ( $PORTDIR/base )
# Author: M. Eerie jul-2020-2021
# https://forum.porteus.org/viewtopic.php?p=85455#p85455
# ======================================================

[[ $EUID -eq 0 ]] || su -c "$0"
confirm() { echo; tput setaf 6; read -n1 -rsp "$1"; tput sgr0; echo -e "\n"; [[ $REPLY =~ ^[Yy]$ ]]; }
warn() { echo; tput bold; for i in {1,0,1,0,1}; do echo "$(tput sc)$(tput setaf $i) $1 $(tput rc)$(tput kri)"; sleep 0.1; done; tput sgr0; echo; }; notify() { echo; echo "$(tput setaf 3) $1 $(tput sgr0)"; echo; };
[ ! "$(grep -o 'base_only' /proc/cmdline)" ] && warn "Please start Nemesis with **Always Fresh** boot parameters" && exit

mirrorlist-toggle ### Allow updating base modules

the_end() {
	cd /tmp/updBASE || exit
	[[ -z $(\ls -A LOCALES) ]] || dir2xzm LOCALES LOCALES.xzm
	rm -r LOCALES "$bMOD" >/dev/null 2>&1
	echo " All Done!"; echo "Your files are here: $PWD"; xdg-open . & disown ### exo-open .
	unset KMAP LANG pkgAdd pkgRem outdated dBX bMOD
	eval "exit $?"
}
trap the_end SIGHUP SIGINT SIGTERM

                ##
                 ##
                  ##
####### #######   ### PREPARATION
                  ##
                 ##
                ##

### Canonicalize Permissions. Try to put system permissions truncated by rootcopy, etc. into standard values
### stat -c '%A %a %G %g %n' $(find $1/{etc,usr} '(' -type f -not -perm 0644 ')' -o '(' -type d -not -perm 0755 ')')
fixPERMS() {
	[ -z "$1" ] || { warn "Resetting permissions on: $1" && confirm "Press any key when ready "; }
	chmod -f 711 "$1"/var/db/sudo/ >/dev/null 2>&1
	chmod -f 700 "$1"/var/db/sudo/lectured/ "$1"/var/lib/NetworkManager/ "$1"/etc/NetworkManager/system-connections/ >/dev/null 2>&1
	chmod -f 750 "$1"/root "$1"/etc/sudoers.d/ "$1"/etc/openvpn/{client,server}/ "$1"/{usr/share,etc}/polkit-1/rules.d/ >/dev/null 2>&1
	chmod -f 755 "$1"/etc "$1"/etc/local.d "$1"/usr "$1"/usr/local "$1"/usr/local/bin >/dev/null 2>&1
	chmod -f 555 "$1"/{proc,sys}/ "$1"/srv/ftp >/dev/null 2>&1
	chmod -f 775 "$1"/var/games >/dev/null 2>&1
	chmod -f 1777 "$1"/var/{spool/mail,tmp} >/dev/null 2>&1
	find "$1"/usr/share/icons -type d -exec chmod 755 {} + >/dev/null 2>&1
	find "$1"/usr/share/icons -type f -exec chmod 644 {} + >/dev/null 2>&1
	find "$1"/usr/share/icons -type d -exec chown 0.0 {} + >/dev/null 2>&1
	find "$1"/usr/share/icons -type f -exec chown 0.0 {} + >/dev/null 2>&1
	chown -R $USER:$USER "$1"$HOME >/dev/null 2>&1
	sed -i 's/wheel/0/' "$1"/usr/share/polkit-1/rules.d/50-default.rules >/dev/null 2>&1  ### FIX root/admin password issue
}

### Bypass adwaita-icon-theme (This could be deprecated by now)
remADWAITA() {
	[ -d "$1"/usr/share/icons/Adwaita ] || return
	rm "$1"/usr/share/mime/packages/freedesktop.org.xml "$1"/usr/lib/gtk-2.0/2.10.0/engines/libadwaita.so >/dev/null 2>&1
	rm -r "$1"/usr/share/icons/{Adwaita,Adwaita-dark,HighContrast} >/dev/null 2>&1 #FIXME
}

prepareSYS() {
	fixPERMS ""
	### WORKAROUND to --> "Please ensure you have a connection and try again. Exit code: 1" /// caused by /etc/local.d/firewall.start
	setup-pman || { pacman-db-upgrade; haveged; pacman-key --init; pacman-key --populate archlinux artix; pkill haveged; update-ca-trust; pacman -Sy; }
	[[ $(pacman -Qu | wc -l) -eq 0 ]] || pacman -Syu --overwrite '*' ### --ignore '*' >/dev/null
	mkdir -p /tmp/updBASE/LOCALES || exit ### avoid iterations
	clear; echo "  Main system: updated  "; echo
}

                ##
                 ##
                  ##
####### #######   ### UPDATE PACKAGES
                  ##
                 ##
                ##

updateBASE() {
	clear
	[ -d /tmp/updBASE ] || prepareSYS
	cd /tmp/updBASE || exit
	[ -d LOCALES ] || mkdir -p LOCALES
	PS3=$'\n'$'\e[00;36mPlease, select base module to update or exit (1-9): \e[0m'
	select bMOD in 003-lxde 003-lxqt 003-mate 003-xfce 002-xtra 002-gui 05-devel 001-core end
	do
		pkgAdd=""
		pkgRem=""
		case $bMOD in
			*lxde|*lxqt|*xfce|*mate) pkgAdd=""; pkgRem="";;
			*xtra) pkgAdd=""; pkgRem="";;
			 *gui) pkgAdd=""; pkgRem="";;
			*devel) pkgAdd=""; pkgRem="";;
			*core) pkgAdd=""; pkgRem="";; ### --ignore '*'
			end*) the_end;;
		esac
	break
	done

	### rsync -a /mnt/live/memory/images/$bMOD*.xzm/ "$bMOD" ### unsquash uses parallel processing and seems to be faster
	unsquashfs -f -d "$bMOD" "$PORTDIR/base/$bMOD"* || exit
	dBX="$(pacman-conf DBPath)"; pCache="$(pacman-conf CacheDir)"
	ln -s "$dBX"sync "$bMOD$dBX" && ln -s "$dBX"local/ALPM_DB_VERSION "$bMOD$dBX"local

	### Firstly remove explicit packages. Should you get conflicting packages OR duplicate database entries (coming from two different base modules) you can get rid of them here)
	[[ -z "$pkgRem" ]] || eval "pacman -Rddr $bMOD $pkgRem"

	outdated="$(pacman -Qqur $bMOD)"
	if [[ -z "$outdated" ]]; then notify "$bMOD is up to date"; rm -r "$bMOD"; return; fi

	if [[ "$bMOD" != 001-core ]]; then 
		pacman -b "$bMOD$dBX" --overwrite '*' --noconfirm --needed -Sddr "$bMOD" - <<<"$outdated"

	else

### We are FORCING partial upgrades... <-- https://wiki.archlinux.org/title/System_maintenance#Partial_upgrades_are_unsupported
		for mp in proc sys dev; do mount -B /$mp "$bMOD"/$mp/; done &
		fakeroot -- pacman --overwrite '*' --noconfirm -Sddur "$bMOD" - <<<"$outdated" ### fakechroot fakeroot -- pacman ...
		umount -R "$bMOD"/{proc,sys,dev} >/dev/null 2>&1
		### Should any of the above cannot be dismounted, the next line will find the culprit:
		### sudo ls -l /proc/*/root | grep "$bMOD" 

### Alternate method to avoid scriptlets (post update hooks) NOT RECOMMENDED
		### find "$pCache" -iname "*.xz" -o -iname "*.zst" -exec tar -xvpf {} -C "$bMOD" 2>/dev/null 2>&1 \;
		### rm $bMOD/{.PKGINFO,.INSTALL,.MTREE,.BUILDINFO}
		### pacman --dbonly -b $bMOD$dBX -Sdd --overwrite '*' --noconfirm - <<<"$outdated"
		### \ls /usr/share/libalpm/hooks
	fi

	### Add user-resquested packages ***without dependencies***
		[[ -z "$pkgAdd" ]] || eval "pacman -Sddr $bMOD $pkgAdd"

### Qq existing | Qqn native | Qqm foreign (aur,etc.) | Qqe explicit | Qqd dependencies | Qqt unrequired | -Qet explicitly installed and not required as dependencies

###TODO Process alien/orphan packages
#	trizens="$(pacman -Qqmr $bMOD)"
#	orphan=$(pacman -Qqdtr $bMOD)
#	if [[ -n "$orphan" ]]; then warn "There seems to be orphan/foreign packages in $bMOD";  
#		while warn "Would you like to remove them? [y/*] "
#			do
###TODO Prompt the user which ones to remove
#			  pacman -Rddr $bMOD - <<<"$orphan"
#			done
#		return
#	fi

                ##
                 ##
                  ##
####### #######   ### LOCALES
                  ##
                 ##
                ##

cd /tmp/updBASE/"$bMOD" || exit
	### Get usr locale environment from cheatcodes and $LANG env variable
	KMAP=$(grep -Eo " kmap=[^ ]+" /proc/cmdline | cut -d= -f2)
	[[ -z $LANG ]] && LANG="$KMAP" || LANG="${LANG%.*}"
	[[ -z $LANG ]] && warn "Couldn't set your locale config" ### get_locale
	find usr/share/locale \( -name "en" -o -name "en_US" -o -name "$KMAP" -o -name "$LANG" -o -iname 'locale.alias' \) -exec cp -au --parents {} /tmp/updBASE/LOCALES \;
	unset KMAP

                ##
                 ##
                  ##
####### #######   ###  STRIP & BUILD
                  ##
                 ##
                ##

### FIXME Bypass 05-devel from being stripped (checking out)
	[[ "$bMOD" = "05-devel" ]] || {
		rm -r usr/lib/{libasan,libtsan,libgfortran,libgo}.so* usr/lib/*.a usr/bin/js78* lib/pkgconfig usr/include/* >/dev/null 2>&1  #libgomp, is needed by ffmpeg
	}
	rm -r usr/share/{doc,gir-1.0,gtk-doc,info,licenses,locale,man} usr/share/i18n/charmaps/*.gz usr/lib/systemd/* tmp/* >/dev/null 2>&1
	rm var/lib/pacman/{sync,local/ALPM_DB_VERSION} >/dev/null 2>&1

cd /tmp/updBASE || exit
	fixPERMS "$bMOD"
	#confirm "Press any key when ready "
	mv "$bMOD"/var/log/pacman.log "$bMOD"-pacman.log >/dev/null 2>&1
	dir2xzm "$bMOD" "$bMOD-$(date '+%Y%m%d').xzm"
	rm -r "$bMOD"
}

# Main loop
while confirm "Shall we update [y/*]? "; do updateBASE; done

warn " Aborted. Exit code: $?"

# 8   8 8""""8 8""""8 8""""8 ""8"" 8""""      8""""8   8""""8 8""""8 8""""
# 8   8 8    8 8    8 8    8   8   8          8    8   8    8 8      8     
# 8e  8 8eeee8 8e   8 8eeee8   8e  8eeee      8eeee8ee 8eeee8 8eeeee 8eeee
# 88  8 88     88   8 88   8   88  88    eeee 88     8 88   8     88 88    
# 88  8 88     88   8 88   8   88  88         88     8 88   8 e   88 88    
# 88ee8 88     88eee8 88   8   88  88eee      88eeeee8 88   8 8eee88 88eee
Last edited by M. Eerie on 18 Nov 2021, 06:40, edited 10 times in total.
> Does not compute_ 🖖

Jack
Contributor
Contributor
Posts: 1726
Joined: 09 Aug 2013, 14:25
Distribution: Porteus 4.0rc4 My Mate 64 bit
Location: USA

2021 Updated Nemesis Base Modules

Post#240 by Jack » 10 Nov 2021, 15:09

M. Eerie wrote:
10 Nov 2021, 12:52
Reworked script. Fakeroot included. Still needs fine-tuning to deal with root account.

Code: Select all

#!/usr/bin/env bash
# ------------------------------------------------------
# update-base
# Updates NEMESIS base modules ( $PORTDIR/base )
# Author: M. Eerie jul-2020-2021
# https://forum.porteus.org/viewtopic.php?p=85455#p85455
# ======================================================

[[ $EUID -eq 0 ]] || su -c "$0"

confirm() { echo; tput setaf 6; read -n1 -rsp "$1"; tput sgr0; echo -e "\n"; [[ $REPLY =~ ^[Yy]$ ]]; }
warn() { echo; echo "$(tput setaf 1) $(tput bold) $(tput blink) $1 $(tput sgr0)"; echo; }; notify() { echo; echo "$(tput setaf 3) $1 $(tput sgr0)"; echo; };

[ ! $(grep -o 'base_only' /proc/cmdline) ] && warn "Please start Nemesis with **Always Fresh** boot parameters" && exit
mirrorlist-toggle ### Allow updating base modules

the_end() {
	cd /tmp/updBASE || exit
	[[ -z $(\ls -A LOCALES) ]] || dir2xzm LOCALES LOCALES.xzm
	rm -r LOCALES "$bMOD" >/dev/null 2>&1
	echo " All Done!"; echo "Your files are here: $PWD"; xdg-open . & disown ### exo-open .
	unset pkgAdd pkgRem outdated dBX bMOD
	eval "exit $?"
}
trap the_end SIGHUP SIGINT SIGTERM

### stat -c '%A %a %G %g %n' $(find ./usr/bin -mindepth 1 -maxdepth 1 '(' -type f -not -perm 0755 ')') -o '(' -type d -not -perm 0755 ')' ### -o '(' -type f -not -perm 0644 ')') #TODO DEBUG
fixPERMS() {
#	warn "Resetting permissions on: $1"; confirm "Press any key when ready "
	chmod -f 711 "$1"/var/db/sudo/ >/dev/null 2>&1
	chmod -f 700 "$1"/var/db/sudo/lectured/ "$1"/var/lib/NetworkManager/ "$1"/etc/NetworkManager/system-connections/ >/dev/null 2>&1
	chmod -f 750 "$1"/root "$1"/etc/sudoers.d/ "$1"/etc/openvpn/{client,server}/ "$1"/{usr/share,etc}/polkit-1/rules.d/ >/dev/null 2>&1
	chmod -f 755 "$1"/etc "$1"/etc/local.d "$1"/usr "$1"/usr/local "$1"/usr/local/bin >/dev/null 2>&1
	chmod -f 555 "$1"/{proc,sys}/ "$1"/srv/ftp >/dev/null 2>&1
	chmod -f 775 "$1"/var/games >/dev/null 2>&1
	chmod -f 1777 "$1"/var/{spool/mail,tmp} >/dev/null 2>&1
	find "$1"/usr/share/icons -type d -exec chmod 755 {} + >/dev/null 2>&1
	find "$1"/usr/share/icons -type f -exec chmod 644 {} + >/dev/null 2>&1
	find "$1"/usr/share/icons -type d -exec chown 0.0 {} + >/dev/null 2>&1
	find "$1"/usr/share/icons -type f -exec chown 0.0 {} + >/dev/null 2>&1
	[ -d "$1"/home/guest ] && chown -R 1000.1000 "$1"/home/guest >/dev/null 2>&1
}

### Bypass adwaita-icon-theme
remADWAITA() {
	[ -d "$1"/usr/share/icons/Adwaita ] || return
	rm "$1"/usr/share/mime/packages/freedesktop.org.xml "$1"/usr/lib/gtk-2.0/2.10.0/engines/libadwaita.so >/dev/null 2>&1
	rm -r "$1"/usr/share/icons/{Adwaita,Adwaita-dark,HighContrast} >/dev/null 2>&1 #FIXME
}

prepareSYS() {
	fixPERMS ""
	### WORKAROUND to --> "Please ensure you have a connection and try again. Exit code: 1" /// caused by /etc/local.d/firewall.start
	setup-pman || { pacman-db-upgrade; haveged; pacman-key --init; pacman-key --populate archlinux artix; pkill haveged; update-ca-trust; pacman -Sy; }
	[[ $(pacman -Qu | wc -l) -eq 0 ]] || pacman -Syu --overwrite '*' ### --ignore '*' >/dev/null
	mkdir /tmp/updBASE || exit ### avoid iterations
	clear; echo "  Main system: updated  "; echo
}

updateBASE() {
	clear
	[ -d /tmp/updBASE ] || prepareSYS
	cd /tmp/updBASE || exit
	[ -d LOCALES ] || mkdir -p LOCALES
	PS3=$'\n'$'\e[00;36mPlease, select base module to update or exit (1-8): \e[0m'
	select bMOD in 003-lxde 003-mate 003-xfce 002-xtra 002-gui 05-devel 001-core end #FIXME
	do
		pkgAdd=""
		pkgRem=""
		case $bMOD in
			*lxde|*xfce|*mate) pkgAdd=""; pkgRem="";;
			*xtra) pkgAdd=""; pkgRem="";;
			 *gui) pkgAdd=""; pkgRem="xf86-input-void";;
			*devel) pkgAdd=""; pkgRem="";;
			*core) pkgAdd=""; pkgRem="";; ### --ignore '*'
			end*) the_end;;
		esac
	break
	done

	### rsync -a /mnt/live/memory/images/$bMOD*.xzm/ "$bMOD" ### unsquash uses parallel processing and seems to be faster
	unsquashfs -f -d "$bMOD" "/mnt/live/memory/copy2ram/$bMOD"*
	dBX="$(pacman-conf DBPath)" ###;cCH="$(pacman-conf CacheDir)"
	ln -s "$dBX"sync "$bMOD$dBX" && ln -s "$dBX"local/ALPM_DB_VERSION "$bMOD$dBX"local

	### Firstly, remove conflicting packages (also avoid duplicate database entries)
	[[ -z "$pkgRem" ]] || eval "pacman -Rddr $bMOD $pkgRem"

	outdated="$(pacman -Qqur $bMOD)"
	if [[ -z "$outdated" ]]; then notify "$bMOD is up to date"; rm -r "$bMOD"; return; fi

	if [[ "$bMOD" != 001-core ]]; then 
		pacman -Sddur "$bMOD" --overwrite '*' --noconfirm --needed - <<<"$outdated"

	### Add user-resquested packages ***without dependencies***
		[[ -z "$pkgAdd" ]] || eval "pacman -Sddur $bMOD $pkgAdd"

	else

		for mp in proc sys dev; do mount -B /$mp "$bMOD"/$mp/; done &
		fakeroot -- "$bMOD"/usr/bin/pacman -Sddu --overwrite '*' --noconfirm --noscriptlet - <<<"$outdated" #FIXME omit scriptlets to prevent permission issues
		###chroot "$bMOD" /bin/bash; pacman -Sddu --overwrite '*' --noconfirm - <<<"$outdated"; ###exit from chroot must be done manually #TODO switch_root ???
		umount -R "$bMOD"/{proc,sys,dev} >/dev/null 2>&1

	fi

###TODO Process orphan packages
#	orphan="$(pacman -Qqmr $bMOD)"
#	if [[ ! -z "$orphan" ]]; then warn "There seems to be orphan/foreign packages in $bMOD";  
#		while warn "Would you like to remove them? [y/*] "
#			do
###TODO Prompt the user which ones to remove
#			  pacman -Rddr $bMOD - <<<"$orphan"
#			done
#		return
#	fi

### Save locales
cd /tmp/updBASE/"$bMOD" || exit
	### Get usr locale environment from cheatcodes and $LANG env variable
	KMAP=$(grep -Eo " kmap=[^ ]+" /proc/cmdline | cut -d= -f2)
	[[ -z $LANG ]] && LANG="$KMAP" || LANG="${LANG%.*}"
	[[ -z $LANG ]] && warn "Couldn't set your locale config" ### get_locale
	find usr/share/locale \( -name "en" -o -name "en_US" -o -name "$KMAP" -o -name "$LANG" -o -iname 'locale.alias' \) -exec cp -au --parents {} /tmp/updBASE/LOCALES \;
	unset KMAP

### strip out ~ 270 MB from core stuff
	[[ "$bMOD" = "001-core" ]] && {
		#patchCORE  ### TODO execute scriptlets?
		rm -r usr/lib/{libasan,libgfortran,libgo,libtsan}.so* usr/lib/*.a usr/bin/js78* lib/pkgconfig usr/share/i18n/charmaps/*.gz >/dev/null 2>&1 #FIXME libgomp, seems to be necessary for ffmpeg
	}
	rm -r usr/share/{doc,gir-1.0,gtk-doc,info,licenses,locale,man} usr/include/* usr/lib/systemd/* tmp/* >/dev/null 2>&1
	rm var/lib/pacman/{sync,local/ALPM_DB_VERSION} >/dev/null 2>&1

cd /tmp/updBASE || exit
	fixPERMS "$bMOD"
	#confirm "Press any key when ready "
	mv "$bMOD"/var/log/pacman.log "$bMOD"-pacman.log >/dev/null 2>&1
	dir2xzm "$bMOD" "$bMOD-$(date '+%Y%m%d').xzm"
	rm -r "$bMOD"
}

# Main loop
while confirm "Shall we update [y/*]? "; do updateBASE; done

warn " Aborted. Exit code: $?"

I will try it out later today and I will let you know what happen.
I just like Slackware because I think it teach you about Linux to build packages where Ubuntu is like Windows you just install programs you want.

Post Reply