#! /bin/bash -- # Aggrega file di pacchetti installati o aggiornati con Pacman # dall'ultimo avvio di una distribuzione linux-live # (cfr. https://www.linux-live.org/ ) senza persistenza attivata, # creando un unico bundle .sb # I file vengono letti dalla directory changes e da essa filtrati solo # quelli appartenenti ai pacchetti di pacman. # # Autore: Guido Longoni IFS=$'\n' OUTLST="/tmp/added_files_$$.lst" CACHEDIR=$(sed -n -e '/^[[:space:]]*CacheDir/s|^[^=]*=[[:space:]]*||gp' -e 's|[[:space:]]*$||g' /etc/pacman.conf | head -n1) OUTDIR="/tmp/sb_$$" OUTFILE="$OUTDIR".sb CHGDIR=$(realpath $(mount | sed -n -e '/squashfs/s|.* on \([^ ]*\)/.*|\1|gp' | head -n1)/../changes) mkdir -p '/tmp' mkdir -p "$OUTDIR" rm -rf "$OUTLST" touch "$OUTLST" for i in $(find "$CACHEDIR" -iname '*.pkg.tar.xz'); do tar t -f $i >> "$OUTLST" 2>/dev/null done sort -u "$OUTLST" | grep -v '^\.' > "$OUTLST".tmp mv "$OUTLST".tmp "$OUTLST" rsync -av --old-d --files-from="$OUTLST" "$CHGDIR" "$OUTDIR" dir2sb "$OUTDIR" "$OUTFILE" rm -rf "$OUTDIR" rm -rf "$OUTLST"