Script to product modules from package list in Nemesis

Arch based Porteus community project

Moderator: M. Eerie

molokai
Ronin
Ronin
Posts: 2
Joined: 10 Apr 2017, 22:40
Distribution: nemesis
Location: fiji

Script to product modules from package list in Nemesis

Post#1 by molokai » 10 Apr 2017, 23:25

my 1st :P post well it is reply

i hacked and slashed some lines from different scripts mostly found in porteus done some edit to it way i like.
maybe someone finds it useful.
at lest name and name-version extraction... :%)
its heavy commented, its for me, this is my first script so....

pacman --cachedir /path/to/dir -Sw <some packages>
goes before this script

call script from dir where .pkgs are


>>not recommended for people skimmin' around forum just copy/pasting stuff and expect it to work << like i do :fool:

Code: Select all

#!/bin/bash
## convert cached .pkg.tar.xz(s) from $PWD to xzm module
## for molokaii


## from pkg2xzm script
## process downloaded packages.pkg.tar.xz and convert to xzm 

## Create custom pacman db dir at working/temp location
#tmpdir=/tmp/pacmancached-$UID
tmpdir=$PWD
mkdir -p $tmpdir/cached-install/var/lib/pacman/local

## Mount the local pacman database at working/temp dir 
## so that custom location update operation sees it (pacman -Uddr needs)
mount --rbind /var/lib/pacman $tmpdir/cached-install/var/lib/pacman


## Monkey around with db files, hold them outside mount binded 
## /var/lib/pacman db dir
## to be put back where they need to be after unmounting
## this shit-around requiers extraction of package name-version below
dbhold="$tmpdir/dbhold.$$"
mkdir -p $dbhold


## use pacman -U to unpack packages from cached pkgs dir
## make install destination dir
#mkdir -p $tmpdir/cached-install ##already done recursively earlier
for i in $(ls *.pkg.tar.xz *.pkg.tar.gz *.pkg.tar 2>/dev/null); do

#used this before no doing in loop  
#pacman -Uddr $tmpdir/cached-install $tmpdir/*.pkg.tar.xz
pacman --noconfirm -Uddr $tmpdir/cached-install $tmpdir/$i
done

## build package.lst with name and version for db monkeying
## remove starting characters with grep, tr '\n'... borowed never used it
pacman --print-format %n-%v -Upddr $tmpdir/cached-install $tmpdir/*.pkg.tar.xz \
| grep -v "loading packages..." | tr '\n' ' ' > package.lst

arr=($(<$tmpdir/package.lst))

## ${arr[@]} this is how array is declared for iteration 
## package list with multiple entries space separated 
## dont know if it makes difference
for y in ${arr[@]}; do
	cp -a $tmpdir/cached-install/var/lib/pacman/local/$y $dbhold
done

## build name list fore module naming same as above only %n this time
pacman --print-format %n -Upddr $tmpdir/cached-install $tmpdir/*.pkg.tar.xz \
| grep -v "loading packages..." | tr '\n' ' ' > name.lst

arrg=($(<$tmpdir/name.lst))

# replace spaces with underscores and assign to variable lst content
# maybe for naming output module not using yet
#MODULE=$(for i in ${arrg[@]}; do echo $(echo $i | sed 's| |_|g'); done)

MODULE="build.$$"

# remove db entries, from --rbind mounted system db, of just unpacked/installed 
# packages to cached-install. So it stays as it was before it was mounted.
# cleanup stuff. use already created variable with package.lst 

for a in ${arr[@]}; do
	rm -r $tmpdir/cached-install/var/lib/pacman/local/$a
done

## Unmount local db
umount $tmpdir/cached-install/var/lib/pacman

## Finish monkey around with db entries Copy packages to module package db
cp -a $dbhold/* $tmpdir/cached-install/var/lib/pacman/local

echo -e $BGreen"==> "$BWhite"Running script dir2xzm to make $MODULE"$Color_Off

## pass two arguments to dir2xzm contiue there
dir2xzm $tmpdir/cached-install $tmpdir/$MODULE.xzm



User avatar
francois
Contributor
Contributor
Posts: 6434
Joined: 28 Dec 2010, 14:25
Distribution: xfce plank porteus nemesis
Location: Le printemps, le printemps, le printemps... ... l'hiver s'essoufle.

Re: [How to] manually upgrade 3.5 base modules

Post#2 by francois » 11 Apr 2017, 02:21

Welcome to porteus molokai. :)

I am trying to understand what you are doing. Are you making xzm modules from the package list?

Maybe we should split this post. :)
Prendre son temps, profiter de celui qui passe.

molokai
Ronin
Ronin
Posts: 2
Joined: 10 Apr 2017, 22:40
Distribution: nemesis
Location: fiji

Re: [How to] manually upgrade 3.5 base modules

Post#3 by molokai » 11 Apr 2017, 10:02

basicly yes u download packages to dir and u run "script" :wink: in that directory to build xzm module with help of built in dir2xzm script
nothing spec.
along the way u also get two .lst files extracted using --print-version option from pacman.
and clean up system's package database of install (pacman -U) operation.

maybe not good to place this post but its manualy and can produce any module so... idk.

User avatar
francois
Contributor
Contributor
Posts: 6434
Joined: 28 Dec 2010, 14:25
Distribution: xfce plank porteus nemesis
Location: Le printemps, le printemps, le printemps... ... l'hiver s'essoufle.

Re: [How to] manually upgrade 3.5 base modules

Post#4 by francois » 11 Apr 2017, 17:44

We will see what is ncmprhnsbl advice on this topic of yours. He his the owner of this thread, but also acts as a moderator.

Thanks.
Prendre son temps, profiter de celui qui passe.

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

Re: [How to] manually upgrade 3.5 base modules

Post#5 by ncmprhnsbl » 13 Apr 2017, 01:39

hi molokai,, welcome to porteus :)
your script probly does deserve its own topic,
there are aspects of it that may be useful in automating some of the update process..
it does seem though that much of what it does can be done by pman(pacman wrapper that makes modules)

Code: Select all

pman -Uddr /path/to/module /path/to/dir/*.pkg.tar.xz
(unless i'm completely wrong.. as i havent tried it)
the reason, tho, that i use pacman (and not pman) is so i can modify(strip some stuff and check for pac.new files) the module before dir2xzm ing it..
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

User avatar
francois
Contributor
Contributor
Posts: 6434
Joined: 28 Dec 2010, 14:25
Distribution: xfce plank porteus nemesis
Location: Le printemps, le printemps, le printemps... ... l'hiver s'essoufle.

Re: Scripts to product modules from package list in Nemesis

Post#6 by francois » 13 Apr 2017, 16:44

@molokai:
The previous thread has been split to accomodate to this new topic. Feel free to change the title if it does not fit your real intention.

Personnaly, I was impressed with your intervention and would be happy to read you in some future posts. :)
Prendre son temps, profiter de celui qui passe.

Post Reply