Updating/building modules in Nemesis

Arch based Porteus community project
Post Reply
User avatar
M. Eerie
Samurai
Samurai
Posts: 168
Joined: 31 Aug 2017, 21:18
Distribution: APorteus BUDGIE x64

Updating/building modules in Nemesis

Post#1 by M. Eerie » 08 Aug 2019, 16:34

From the works of Jack and ncmprhnsbl, I've been sketching some lines to build/update modules on Nemesis. Just putting it all togheter here to save new users from digging around.

Please, feel free to improve it and report back, as I am not a scripting master at all.

Code: Select all

#!/bin/bash
##
## Update module from $PORTDIR/modules by searchinng part of his name
##

## Check for root
if [ `whoami` != "root" ]; then
      echo "You must be admin to run this script"
      exit
fi

read -p "Input part of module name to update: " modinput
modulo=`basename $(ls $PORTDIR/modules | grep -i $modinput) .xzm`

PATH1=/tmp/$modulo
unsquashfs -f -d $PATH1 $PORTDIR/modules/$modulo.xzm

## 1. Preparation and ensure the cache is clean
# update pacman database
pacman -Sy

# clear package cache
rm /var/cache/pacman/pkg/*

#needed to update packages in an arbitrary path
cp --parents -au /var/lib/pacman/local/ALPM_DB_VERSION $PATH1

OUT1=/tmp/lx
OUT2=/tmp/upall
OUT3=/tmp/uplx
pacman -Qqr $PATH1 | awk '{print $1}' > $OUT1
pacman -Qqu | awk '{print $1}' > $OUT2
sleep 5

## Compare module to find upgrades   
comm -12 $OUT2 $OUT1 > $OUT3

## 2. Download the packages to cache without dependency checking 
## pacman -Sw / Swdd <list of packages> 
## (dd) --> disable dependency checking
pacman -Sddw `cat $PWD/uplx`

## 3. Install the Updated packages to the extracted module
## (dd) --> disable all dependency checking
pacman -Uddr $PATH1 /var/cache/pacman/pkg/*.pkg.tar.xz

## 4. Stripping unneeded files
#......................
# lxstrip.sh BEGIN
#......................

## Some of this stuff could be useful to someone
#cp -au --parents $PATH1/usr/include $PATH2/usr/
#cp -au --parents $PATH1/usr/share/info $PATH2/usr/share/
#cp -au --parents $PATH1/usr/share/doc $PATH2/usr/share/
#cp -au --parents $PATH1/usr/share/gtk-doc $PATH2/usr/share/
#cp -au --parents $PATH1/usr/share/licenses $PATH2/usr/share/
#cp -au --parents $PATH1/usr/share/man $PATH2/usr/share/
#cp -au --parents $PATH1/usr/share/locale $PATH2/usr/share/
#cp -au --parents $PATH1/usr/share/gir-1.0 $PATH2/usr/share/

rm -rf $PATH1/usr/include/* 
rm -rf $PATH1/usr/share/info/* 
rm -rf $PATH1/usr/share/doc/* 
rm -rf $PATH1/usr/share/gtk-doc/* 
rm -rf $PATH1/usr/share/licenses/* 
rm -rf $PATH1/usr/share/man/* 
rm -rf $PATH1/usr/lib/systemd/*
rm -rf $PATH1/tmp
#rm -rf $PATH1/usr/share/gir-1.0/*
#rm $PATH1/usr/bin/gtk3-demo
#rm $PATH1/usr/bin/gtk3-demo-application
#rm $PATH1/usr/bin/gtk3-widget-factory

#rm $PATH1/usr/share/applications/gtk3-demo.desktop
#rm $PATH1/usr/share/applications/gtk3-widget-factory.desktop


rm $PATH1/var/lib/pacman/local/ALPM_DB_VERSION
[[ -f $PATH1/var/log/pacman.log ]] && rm $PATH1/var/log/pacman.log

#......................
# lxstrip.sh END
#......................

## 5. Make the module
[[ -d $PATH1/home ]] && chown guest.users $PATH1/home
chown -R root.root $PATH1
dir2xzm $PATH1/ $PATH1.xzm

## 6.Clean the cache before updating any other modules 
pacman -Scc
rm $OUT1 $OUT2 $OUT3
rm -r $PATH1
unset modinput modulo OUT1 OUT2 OUT3 PATH1
:hmmm: Maybe lacks a cd /tmp before unpacking...

Updated. Still dirty work..., but you get the idea. :)

Thanks.
Last edited by M. Eerie on 09 Aug 2019, 19:48, edited 2 times in total.

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 2135
Joined: 20 Mar 2012, 03:42
Distribution: 5.0rc1-64bit all-DE+more
Location: australia
Contact:

Updating/building modules in Nemesis

Post#2 by ncmprhnsbl » 09 Aug 2019, 05:32

some suggests:
M. Eerie wrote:
08 Aug 2019, 16:34
Maybe lacks a cd /tmp before unpacking...
or use /tmp instead of $PWD

pacman -Scc requires user input[yes/no], possibly just rm /var/cache/pacman/pkg/*

one problem that can occur with automating this way is if there is some new dependency appears, it will be missed..
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

User avatar
M. Eerie
Samurai
Samurai
Posts: 168
Joined: 31 Aug 2017, 21:18
Distribution: APorteus BUDGIE x64

Updating/building modules in Nemesis

Post#3 by M. Eerie » 09 Aug 2019, 19:58

ncmprhnsbl wrote:
09 Aug 2019, 05:32
if there is some new dependency appears, it will be missed..
We force disabling dependencies (pacman -Sdd). I don't know how to deal with this. Is there any workaround?

By now, If the module suddenly fails, it's up to the user to try pacman -S <package> and see what are the new dependencies needed.

:oops:

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 2135
Joined: 20 Mar 2012, 03:42
Distribution: 5.0rc1-64bit all-DE+more
Location: australia
Contact:

Updating/building modules in Nemesis

Post#4 by ncmprhnsbl » 09 Aug 2019, 21:56

really depends on the packages involved, what is trying to be achieved..
for example, when i update the 003-xfce module, there are some gtk3 deps(eg. adwaita-icon-theme..etc) that i don't want/need..
another approach could be to use --ignore <packages> variable
this kind of script was really only meant to streamline upgrading of a desktop type module...to save rebuilding from scratch each time..
for most software, just using pman should be sufficent..
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

Post Reply