Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 08 Dec 2019, 15:20
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Proposed mods to puppies Remaster Script
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [1 Post]  
Author Message
s243a

Joined: 02 Sep 2014
Posts: 2199

PostPosted: Tue 06 Aug 2019, 11:53    Post subject:  Proposed mods to puppies Remaster Script
Subject description: for my woof-next fork
 

I know that a lot of work has been done on remastering scripts and various tools can be found in the following thread:

http://murga-linux.com/puppy/viewtopic.php?p=1033645#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:

   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
   }         



Now, I know that changes are being made to remasterpup2 on woof-CE but am working on a woof-next fork so I don't have to go in the same direction.

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.

_________________
Find me on minds and on pearltrees.
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [1 Post]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0451s ][ Queries: 12 (0.0151s) ][ GZIP on ]