WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Proper use of squashfs -ef  (Read 4694 times)

Offline GeminiEngine

  • Newbie
  • *
  • Posts: 18
  • New to and loving this distribution.
Proper use of squashfs -ef
« on: May 19, 2014, 02:24:43 AM »
I am interested in the proper use and syntax of using unsquashfs. I have reviewed several man pages on this but still have at least one question that does not seem answered in them. There is documentation about this, the command appears to be
Code: [Select]
squashfs /path/to/squash/file -ef /path/within/squashfs/to/directory/or/file/to/unsquash None of the pages tell you where it extracts it to or how to specify where it should extract to; so where does it go?

My greater goal is simple, I want to make a script to recreate one specific functionality of ondemand from 4.7.7 that would extract the image of the extensions executable and copy to "/etc/sysconfig/tcedir/ondemand" and rename where appropriate. In psuedo-code, kind of, just my short hand I picked up from playing with code.
Code: [Select]
nameArray = parsed(ls /etc/sysconfig/tcedir/ondemand)
imgArray = parsed(ls /etc/sysconfig/tcedir/ondemand/*.img)

for each Name in nameArray
  for each Check in imgArray                                             # A loop to check for duplicates
    if Name = Check.substring(0,len(Name)-1) then goto nextName          # checking if image file already exists their, if so skip to next file
  loop Checked
  if askUser("if they want image on wBar") then push Name verifiedArray  #does the user want it on wBar
  :nextName
loop Name

for each Name in verifiedArray
  [
  unsquash "/usr/local/share/pixmap/*" from "/etc/sysconfig/tcedir/optional/"+Name+".tcz" to "/tmp/ondemandtemp"
  copy "/tmp/ondemandtemp/*" to "/etc/sysconfig/tcedir/ondemand/"+Name+".img"

  OR (depends which is faster)

  call ondemand Name+".tcz"
  copy "/tmp/tcloop/"+Name+"/usr/local/share/pixmap/*" to "/etc/sysconfig/tcedir/ondemand/"+Name+".img"
  ]
  deleteFiles in "/tmp/ondemandtemp"
  [unmount the ondemand]
loop Name
cleanup left over temp files and directories

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11695
Re: Proper use of squashfs -ef
« Reply #1 on: May 19, 2014, 08:36:29 AM »
Hi GeminiEngine
This will extract a squashed file to a directory called  squashfs-root  in the directory you are currently in:
Code: [Select]
unsquashfs FilenamePrecede  Filename  with a path if it's in a different directory.
This will extract a squashed file to a directory called  george  in the directory you are currently in:
Code: [Select]
unsquashfs -d george FilenamePrecede  george  with a path if you want it in a different directory.
Many commands also have some form of help built in, such as:
Code: [Select]
tc@box:~$ unsquashfs --help
SYNTAX: unsquashfs [options] filesystem [directories or files to extract]
        -v[ersion]              print version, licence and copyright information
        -d[est] <pathname>      unsquash to <pathname>, default "squashfs-root"
        -n[o-progress]          don't display the progress bar
        -no[-xattrs]            don't extract xattrs in file system (default)
        -x[attrs]               extract xattrs in file system
        -p[rocessors] <number>  use <number> processors.  By default will use
                                number of processors available
        -i[nfo]                 print files as they are unsquashed
        -li[nfo]                print files as they are unsquashed with file
                                attributes (like ls -l output)
        -l[s]                   list filesystem, but don't unsquash
        -ll[s]                  list filesystem with file attributes (like
                                ls -l output), but don't unsquash
        -f[orce]                if file already exists then overwrite
        -s[tat]                 display filesystem superblock information
        -e[f] <extract file>    list of directories or files to extract.
                                One per line
        -da[ta-queue] <size>    Set data queue to <size> Mbytes.  Default 256
                                Mbytes
        -fr[ag-queue] <size>    Set fragment queue to <size> Mbytes.  Default
                                256 Mbytes
        -r[egex]                treat extract names as POSIX regular expressions
                                rather than use the default shell wildcard
                                expansion (globbing)

Decompressors available:
        gzip
and:
Code: [Select]
tc@box:~$ mksquashfs --help
SYNTAX:mksquashfs source1 source2 ...  dest [options] [-e list of exclude
dirs/files]

Filesystem build options:
-comp <comp>            select <comp> compression
                        Compressors available:
                                gzip (default)
-b <block_size>         set data block to <block_size>.  Default 4096 bytes
-no-exports             don't make the filesystem exportable via NFS
-no-sparse              don't detect sparse files
-no-xattrs              don't store extended attributes (default)
-xattrs                 store extended attributes
-noI                    do not compress inode table
-noD                    do not compress data blocks
-noF                    do not compress fragment blocks
-noX                    do not compress extended attributes
-no-fragments           do not use fragments
-always-use-fragments   use fragment blocks for files larger than block size
-no-duplicates          do not perform duplicate checking
-all-root               make all files owned by root
-force-uid uid          set all file uids to uid
-force-gid gid          set all file gids to gid
-nopad                  do not pad filesystem to a multiple of 4K
-keep-as-directory      if one source directory is specified, create a root
                        directory containing that directory, rather than the
                        contents of the directory

Filesystem filter options:
-p <pseudo-definition>  Add pseudo file definition
-pf <pseudo-file>       Add list of pseudo file definitions
-sort <sort_file>       sort files according to priorities in <sort_file>.  One
                        file or dir with priority per line.  Priority -32768 to
                        32767, default priority 0
-ef <exclude_file>      list of exclude dirs/files.  One per line
-wildcards              Allow extended shell wildcards (globbing) to be used in
                        exclude dirs/files
-regex                  Allow POSIX regular expressions to be used in exclude
                        dirs/files

Filesystem append options:
-noappend               do not append to existing filesystem
-root-becomes <name>    when appending source files/directories, make the
                        original root become a subdirectory in the new root
                        called <name>, rather than adding the new source items
                        to the original root

Mksquashfs runtime options:
-version                print version, licence and copyright message
-recover <name>         recover filesystem data using recovery file <name>
-no-recovery            don't generate a recovery file
-info                   print files written to filesystem
-no-progress            don't display the progress bar
-processors <number>    Use <number> processors.  By default will use number of
                        processors available
-read-queue <size>      Set input queue to <size> Mbytes.  Default 64 Mbytes
-write-queue <size>     Set output queue to <size> Mbytes.  Default 512 Mbytes
-fragment-queue <size>  Set fragment queue to <size> Mbytes.  Default 64 Mbytes

Miscellaneous options:
-root-owned             alternative name for -all-root
-noInodeCompression     alternative name for -noI
-noDataCompression      alternative name for -noD
-noFragmentCompression  alternative name for -noF
-noXattrCompression     alternative name for -noX

Compressors available and compressor specific options:
        gzip (no options) (default)

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11049
Re: Proper use of squashfs -ef
« Reply #2 on: May 19, 2014, 09:15:47 AM »
You might also want to use the existing code from 4.7.7.
The only barriers that can stop you are the ones you create yourself.

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Proper use of squashfs -ef
« Reply #3 on: May 19, 2014, 10:24:27 AM »
You could implement this as a script that you run from bootlsync.sh.

Realistically, I don't see the point.
If you want them in wbar, why not have them mounted onboot.  They take up little room.
Ondemand was designed to speed up boot  by not mounting seldom used extensions.
If you are going to mount, extract, and umount extensions to get the icons, you will end up slower than just including them onboot with little RAM saved.
« Last Edit: May 19, 2014, 10:28:45 AM by gerald_clark »

Offline GeminiEngine

  • Newbie
  • *
  • Posts: 18
  • New to and loving this distribution.
Re: Proper use of squashfs -ef
« Reply #4 on: May 19, 2014, 10:20:01 PM »
@Rich; Best lesson, --help.  Feeling lost without pre-installed man pages.
@curaga; Several years out of practice for programming, yeah I know it means I am re-inventing the wheel. Then again to find it in the source would be learning something new. I will probably do both.

@gerald_clark I thought about the bootlsync.sh after reading Ch20, however, this is not meant to be run every time that TinyCore is started. It is meant to be utterly ran once after a customized kiosk is created. In my work case I am attempting to put to use a couple dozen old computers, most only a half gig, some less, in any case we have some legacy apps (I think we still have the source) that I am going to be seeing if I can compile/package for use in TinyCore. These apps are used less than once a day, I see no point in loading at every boot. In favor of expediency of success I may forgo but for now, I have time.
« Last Edit: May 20, 2014, 12:52:09 AM by GeminiEngine »