How to use makesb to include folder

Post your comments, questions, bug reports or suggest new features for alphaOS
ducklin5
Advanced
Posts: 54
Joined: 24 Jun 2014, 08:27

How to use makesb to include folder

Postby ducklin5 » 21 Sep 2014, 09:20

My query is simple: Is there a way i could make an sb file with selected folders?
like makesb -d /usr/... / /opt/...

Scooby
Site Admin
Posts: 826
Joined: 09 Sep 2013, 16:52

Re: How to use makesb to include folder

Postby Scooby » 21 Sep 2014, 14:08

Yes there are a way to do that but not with makesb, it is dedicated to
handle arch repo's

I do it with two functions in /root/.bashrc
They were intended for my own use and probably are a bit overlapping
however you are free to modify them for your own purpose

I shared them before here

There is a brief explanation in the above link as well

change ENV_MODULES_DIR to your own modules/ dir

Code: Select all

export ENV_MODULES_DIR="/mnt/home/15alphaos64/modules"

function sq-session() {
   local back_dir="$PWD"
    local name="$1"

   local default_str="etc,root,usr"
   read -p "Enter comma separated list of top dirs to save: " str

   [ -z "$str" ] && str="$default_str"
   echo "Commencing save of $str ..."

   TEMPDIR=$(mktemp -d -q)
   builtin cd /mnt/live/memory/changes
   eval cp -r {$str} $TEMPDIR

   builtin cd /tmp
   [ -z "$name" ] && name="saved_ram-`date +%Y%m%d%H%M`"
   mksquashfs "$TEMPDIR" "${name}.sb" -noappend -comp xz -Xbcj x86 -Xdict-size 100% -b 1M

   echo -e "\nMoving squash: "${name}.sb" to $ENV_MODULES_DIR"
   mv "${name}.sb" "$ENV_MODULES_DIR"
   builtin cd "$back_dir"
   echo "done"      
}

function sq-file() {
    local file=`realpath "$1"`
   local name="$2"
   if [ -z "$name" ]; then name="${1##*/}"; fi
   if [ -z "$name" ]; then name="${1%/}"; fi

   echo "Commencing squashify of $file ..."

   TEMPDIR=$(mktemp -d -q)
   
   cp -r --parents "$file" "$TEMPDIR"
   
   mksquashfs "$TEMPDIR" "${name}.sb" -noappend -comp xz -Xbcj x86 -Xdict-size 100% -b 1M
   
   echo "Moving squash: "${name}.sb" to $ENV_MODULES_DIR"
   mv "${name}.sb" "$ENV_MODULES_DIR"
   
   echo "done"
}


I now remembered I did put them in a bash script as well for somebody
to be put in /usr/bin

here it is
https://www.dropbox.com/s/k16y7totbg3lw1p/sq?dl=0

change SQ_OBJECT_TARGET variable to point at your /modules dir


if you want to do it by hand the nescessary steps could be gleaned from those
functions

ducklin5
Advanced
Posts: 54
Joined: 24 Jun 2014, 08:27

Re: How to use makesb to include folder

Postby ducklin5 » 21 Sep 2014, 15:44

This is how it works right?:

Code: Select all

sq [folder and/or file location] [name of sb file]

Scooby
Site Admin
Posts: 826
Joined: 09 Sep 2013, 16:52

Re: How to use makesb to include folder

Postby Scooby » 21 Sep 2014, 18:05

yes I believe so

It was some time ago I did that file and I don't use it meself
I have the functions in my .bashrc

But here is the help

Code: Select all

> ./sq --help
    Usage:
      sq [OPTION]... [FILES]...
          -h, --help            display usage message.
         
          -v, --version         display script version.

          -s, --set-modules-dir Set path to your own
                                modules directory
                                It defaults to:
                                /mnt/home/alphaos/modules
         
                        
     if you want to squash some of the top directories
     in RAM then supply only one argument which is the
     name of the resulting module without .sb ending
     
     if two arguments are supplied the first is the
     name of file or directory to be squashed the
     second is the name of resulting bundle without
     .sb ending

    OBS! naming matters since it controls in what
         order modules are loaded during boot. I
         use numbers in front where 9 will be
         loaded before 8            
               
     Examples:
               sq 2222222RAM_SAVED
               sq /root/.start 1111111start
               sq --set-modules-dir /mnt/home/alphaos/modules



do the set of path to your modules path first

Code: Select all

sq --set-modules-dir /mnt/home/alphaos/modules


then as you said

ducklin5
Advanced
Posts: 54
Joined: 24 Jun 2014, 08:27

Re: How to use makesb to include folder

Postby ducklin5 » 21 Sep 2014, 18:12

what if i want to include multiple directories, it doesnt work with a space or a comma

Code: Select all

sq /opt/game-develop /usr/share/game-develop/

Scooby
Site Admin
Posts: 826
Joined: 09 Sep 2013, 16:52

Re: How to use makesb to include folder

Postby Scooby » 21 Sep 2014, 18:15

I thought of your situation and think maybe it is easier and more learning to do it
by hand the first time

The steps would be

1. Create a work dir in /tmp

Code: Select all

mkdir /tmp/game_develop

2. cp the relevant directories to this new work directory

Code: Select all

   cp -r --parents /usr/gamedevelop /tmp/game_develop
   cp -r --parents /opt/gamedevelop /tmp/game_develop


3. Squash the work dir

Code: Select all

 mksquashfs /tmp/game_develop game_develop_by_disco_duck.sb -noappend -comp xz -Xbcj x86 -Xdict-size 100% -b 1M


Then you should get a correct game_develop_by_disco_duck.sb file

The correctness of the file could be verified by mounting it like

Code: Select all

mkdir /mnt/test
mount game_develop_by_disco_duck.sb /mnt/test
ls /mnt/test

Scooby
Site Admin
Posts: 826
Joined: 09 Sep 2013, 16:52

Re: How to use makesb to include folder

Postby Scooby » 21 Sep 2014, 18:20

ducklin5 wrote:what if i want to include multiple directories, it doesnt work with a space or a comma

Code: Select all

sq /opt/game-develop /usr/share/game-develop/


as I said those funtions was intended for my own use and shared as is

It could be hacked to take several dirs but I have not felt the need for it so often
if I need it I do it manually

ducklin5
Advanced
Posts: 54
Joined: 24 Jun 2014, 08:27

Re: How to use makesb to include folder

Postby ducklin5 » 21 Sep 2014, 18:26

Okay thanks for the reply anyway

Scooby
Site Admin
Posts: 826
Joined: 09 Sep 2013, 16:52

Re: How to use makesb to include folder

Postby Scooby » 22 Sep 2014, 12:24

did you get it to work?

jonas
Competent
Posts: 21
Joined: 19 Sep 2014, 11:46

Re: How to use makesb to include folder

Postby jonas » 23 Sep 2014, 15:43

Scooby, I followed your instructions how to make an sb manually from multiple directories and found one thing which may be a bit confusing. After I made the sb I removed the original directories and tried to activate the sb using bundle -a but it didn't seem to work. I think it was because the original directories were still in my savefile (running in usbmode) and there was some conflict. After a reboot everything worked as it should.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 10 guests

cron