http://murga-linux.com/puppy/viewtopic. ... 45#1033645
so if the work I'm going to describe has been done then this thread is primary as a learning exercise for me. Otherwise, it is the shortest path forward for me and possibly others.
Puppies remaster script basically turns your currently running puppy into an iso (or basesfs or adrv). Everything is copied except for select folders such as (home, root, etc, and var) In these select folders the info is copied from the base iso and selected mods are made (e.g. meta information about which packages are installed and possibly hardware customizations depending on the user selection).
My first issue is that the remaster script might miss a lot of changes in these select folders. I created scripts to try to address this (see post). Of course with these scripts there is a greater risk of copying private information. Consequently one has to take a closer look at their save file prior to remastering.
In these scripts, I copy directly from the save file. This means that I might copy some whiteout files. I need to give more thought on how to handle whiteout files.
Now since puppy treats each of these select folders separately one can't copy based on following symlinks. This might not be an issue if each select folder is dealt with properly. However, in my mod of this script I will first create all these select folders prior to merging any of them into the sfs. This way if needed we can at least follow symlinks from one of these folders to another.
Secondly, if someone has enough space then they might want to first copy everything to a temporary work space prior to creating the sfs file. This would for instance allow people to chroot into the temporary folder and make changes. To allow this my strategy is to create a wrapper function for mksquashfs. Depending on the settings one will either directly merge to the squashfile or instead copy the info to a temporary file.
Here is some draft code (not tested yet):
Code: Select all
squash() {
echo $0 $@
rxvt -bg orange -fg black -title "$m_01" -geometry 80x6 -e mksquashfs $@ 2> /dev/null
}
fk_squash() {
echo $0 $@
#s243a: use set -x to echo cpio commands in fk_mksquashfs and pass to rxvt
#rxvt -bg orange -fg black -title "$m_01" -geometry 80x6 -e mksquashfs $@ 2> /dev/null
fk_mksquashfs $@ #Short term hack
}
do_squash(){
if [ "$mode" = dir ]; then
fk_squash $@
else
squash $@
fi
}
fk_mksquashfs(){
#source_dir=$1; shift
#target_dir=$2; shift
option=""
out=() #Currently not used
args=()
declare -A exludes
for arg in "$@";do
if [[ "$arg" == -* ]]; then
case "$arg" in
-*)
option="$arg" ;;
esac
else
case option in
-e)
exludes+=( ["$arg"]=1 ) ;;
'')
args+=( "$arg" ) ;;
*)
out+=( "$arg" ) ;;
esac
fi
done
n_args=${#args}
target_dir=$args[$n_args]
target_dir="${target_dir%.sfs}"
mkdir -p "$target_dir"
unset 'args[$n_args-1]' #https://stackoverflow.com/questions/8247433/remove-the-last-element-from-an-array
#while read aDir; do
if [ realpath "$target_dir" != "/" ]; then
for aDir in "$args[@]"; do
excluded="${excludes[$aDir]}"
[ -z "$excluded" ] && excluded=0
if [ ! $excluded -eq 1 ]; then
cd $aDir
cpio -pd "$target_dir"
fi
done
fi
#done < <(ls -a -1)
}
do_mksquashfs(){
if [ "$mode" = dir ]; then
fk_mksquashfs $@
else
mksquashfs $@
fi
}
the fk_makesquashfs stands for "fake make squash file system". The functions prefixed with do are to select between the real and fake versions based on the settings within the script.
The complete preliminary/untested code can be found at: https://pastebin.com/y0cSmdGT. I will test later today and modify the content at this link.
P.S. I might give the option to clean up each select file as one goes but instead one can chose to wait until all select folders are created before merging the content into the sfs.