foxpup wrote:Interesting tool s243a.
I looked to the script and did not understand it at all.
But I am almost noob scripting.
It's partly my fault also because I added some complexity that wasn't strictly required to get the job done.
I thought it would be simple.
This is what I think:
- unsquash all the sfs to the same working directory (wd)
- copy all files from savefile to the same wd
This is correct. However, rather than unsquashing the sfs file I mount each sfs file at "/mnt/wksfs". Here is some trimmed down code :
around line #240 (but trimmed down and simplified
Code: Select all
while read -r -u9 file1 ; do
mount -v -t squashfs $file1 /mnt/wksfs
mv_or_copy_files /mnt/wksfs $target_dir
umount /mnt/wksfs
done 9< <( find $sfs_dir -maxdepth 1 -type f -name "*.sfs" | \
grep -v -e "^$sfs_dir"/'f.*' | \
grep -v -e "^$sfs_dir"/'z.*' )
Code: Select all
mv_or_copy_files() #Line number 120
while IFS=$'\0' read -r -d $'\0' -u10 fm_filePath_prefixed ; do #Line number 141
#
mkdir -p `dirname $to_filePath_prefixed` #Line number 161
cp -a -u $fm_filePath_prefixed $to_filePath_prefixed #Files are only copied if they are newer
done 10< <( find $s_folder_fullpath -type f -name "*" -print0 ) #Line number 165
}
The input to the above loops comes from the find command at the end of the function:
https://blog.famzah.net/2016/10/20/bash ... -commands/
In the first find example we have:
(Not valid code)
Code: Select all
find $sfs_dir -maxdepth 1 -type f -name "*.sfs" \ #Find all files the end in .sfs (search only one level deep.
grep -v -e "^$sfs_dir"/'f.*' #exclude files that start with "f" (These are firware)
grep -v -e "^$sfs_dir"/'z.*' #exclude files that start with "z" (these are kernal modules)
In the second example we're finding all files within a given directory
Code: Select all
find $s_folder_fullpath -type f -name "*" -print0
* the -type f option means find only files (no directors). It also seems to include symlinks although this isn't clear from the manpage.
* the -print0 option means to use the "null character" as the field seperator. This can help with unusually file names, However, I don't think my code is perfectly robust this way.
Both loops are reading and writing from a file descriptor. At the end of the loop we have:
the file descriptor is "10" or more properly written as "&10" (but not here). The reason to use a file descriptor is so that within the while loop we can accept terminal input wihout interfering with the read at the top of the loop. Terminal input comes from standard input (i.e. &1). I use standard input for debugging purposes. For instance I can pause the script with:
Code: Select all
read -p "Press enter to continue" <&1
and then read from the screen a given set of echo statements that I printed out.
At the top of the loop the file descriptor input is showon with the -u10 option.
- remove all files with the whiteout prefix (suffix?) and the corresponding files without the whiteout prefix in de wd
This is correct:
Code: Select all
apply_white_out_files(){ #Line number 171
case
...
*) #Line number 207
...
fname=${wh_fname#.wh.} #https://lwn.net/Articles/324291/
rm $to_dirPath_prefixed/$fname
rm $to_dirPath_prefixed/$wh_fname
esac
...
}
except that there is also a type of whitout file that means that the current directory is opaque (in other words it blocks all lower layers from showing up in the directory. In this case we replace the directory with the directory from the save folder.
Code: Select all
case $wh_fname in
'.wh..wh..opq') #Around line #190
rm -rf $to_dirPath_prefixed
cp $fm_dirPath_prefixed $to_dirPath_prefixed
rm $to_dirPath_prefixed/$wh_fname
Finally there are two types of whitout files that I don't know what they do so I just delete them:
Code: Select all
'.wh..wh.plnk'|'.wh..wh.aufs') #https://unix.stackexchange.com/questions/92287/aufs-whiteout-removal
...
rm $to_dirPath_prefixed/$wh_fname
;;
- mksquashfs the wd
Is this wrong? How?
You could do this if you want to just replace the main puppy sfs file. Or alternatively you could build a new ISO.
Edit:; see:make_ISO_Fm_slitaz-rootfs
https://pastebin.com/5BfvZKXy
Requires:
make-tazpup_functions.sh
https://pastebin.com/K7bgqLFE