free software resistance
the cost of computing freedom is eternal vigilance
### pupray.fig
*original date:* nov 2018
*originally posted:* oct 2024
pupray.fig:
```
#### license: creative commons cc0 1.0 (public domain)
#### http://creativecommons.org/publicdomain/zero/1.0/
proginf = "pupray 0.1, nov 2018 mn"
# ========================================================
# you will need python 2, and fig 2.x or 4.x to run this.
# you can download fig 4.6 here:
# https://notabug.org/figosdev/figos/raw/master/fig46.py
# ========================================================
# this is a python-based language
# only inline python sections require indenting
# other code indentation is optional
function fsortplus sortlist
python
from hashlib import sha256
from datetime import datetime
b = []
outlist = []
for p in sortlist:
if len(p):
try: fs = int(os.path.getsize(p))
except: fs = -1
try: s256 = sha256(open(p).read()).hexdigest()
except: s256 = "-" * 64
try: filetime = str(datetime.fromtimestamp(os.path.getmtime(p)))[0:19]
except: filetime = -1
try: b += [(fs, s256, filetime, p)]
except: b += [(0, "problem", "with", "fsortplus")]
b.sort()
for p in b:
tab = chr(9)
try: outlist += [str(p[0]) + " " + p[1] + " " + p[2] + tab + p[3]]
except: outlist += ["-1" + chr(32) + "-" * 64 + chr(32) + "?" + chr(32) + "?" + chr(32) + p[3]]
return outlist
fig
fig
function isfilesfs p
pts split p ","
forin each pts
col instr each ":"
iftrue col
now split each ":" mid 2 1 swap now each
fig
sfs instr each "quashfs filesystem"
iftrue sfs
now return 1
fig
next
now return 0
fig
function sep
python
global loglines
fig
nl 10 chr
now "" plus nl prints
loglines plus now
fig
function fileprints p
python
global loglines
fig
now p prints
loglines plus p
fig
function fileprint p
python
global loglines
fig
nl 10 chr
now p plus nl prints
loglines plus now
fig
qu 34 chr
loglines arr mid 0 1
filename command mid 1 1
now "mkdir -p /mnt/pupray/" shell
now "/mnt/pupray/" chdir
now "mkdir /mnt/pupray/mnt 2> /dev/null" shell
now "mkdir /mnt/pupray/init 2> /dev/null" shell
now "mkdir /mnt/pupray/fs 2> /dev/null" shell
now "mkdir /mnt/pupray/sfs 2> /dev/null" shell
now "mounting " plus filename plus "... " fileprints now
qu 34 chr
now "sha256sum " plus qu plus filename plus qu arrshell mid 1 1 split now " " mid 1 1 fileprints now " " fileprints now
now "file -L " plus qu plus filename plus qu arrshell mid 1 1 fileprint now
now "mount " plus qu plus filename plus qu plus " /mnt/pupray/mnt 2>&1" arrshell
#now "ls -l /mnt/pupray/mnt" shell
now "kernel " fileprints now
kernel "file /mnt/pupray/mnt/vmlinuz ; cp /mnt/pupray/mnt/vmlinuz /mnt/dlibre" arrshell mid 1 1 fileprint kernel
now sep
# https://stackoverflow.com/questions/12002315/extract-vmlinux-from-vmlinuz-or-bzimage
now "dd if=/mnt/pupray/mnt/vmlinuz status=none skip=`grep -a -b -o -m 1 -P '\\037\\213\\010\\000' "
further = now plus "/mnt/pupray/mnt/vmlinuz 2>/dev/null | cut -d: -f 1` bs=1 2>/dev/null | zcat 2>/dev/null |"
builtinminix = further plus " egrep 'minix.fs|MINIX.fs' 2>/dev/null | wc -l" arrshell mid 1 1 val
# sorted list
cdfiles "find /mnt/pupray/mnt/ -type f" arrshell fsortplus cdfiles
forin p cdfiles
now p fileprint now
next
# create array of just sfs files
sfsfiles arr mid 0 1
versfs "find /mnt/pupray/mnt/ -type f" arrshell
forin sfs, versfs
ifequal sfs ""
pass
else
confsfs "file " plus qu plus sfs plus qu arrshell mid 1 1 isfilesfs confsfs
iftrue confsfs
sfsfiles plus sfs
fig
fig
next
now sep
now "processing initrd" fileprint now
now sep
propergz arr mid 1 0
gzfiles "ls /mnt/pupray/mnt/*.gz" arrshell
forin gz, gzfiles
ifequal gz ""
pass
else
initrd "file " plus gz arrshell mid 1 1
now "/mnt/pupray/init/" chdir
now "rm init 2> /dev/null ; gzip -cd " plus gz plus " > init 2>/dev/null " arrshell
mountfs "mount -o loop init /mnt/pupray/fs 2>&1 | grep 'unknown filesystem' | wc -l" arrshell mid 1 1 val
iftrue mountfs
now "pupray unable to mount unknown filesystem " fileprints now "file /mnt/pupray/init/init" arrshell mid 1 1 fileprint now
else
properinit instr gz "initrd.gz"
alreadymounted "mount | grep '\/mnt\/pupray\/fs' | wc -l" arrshell mid 1 1 val
iftrue alreadymounted
properinit 0
fig
iftrue properinit
now "file /mnt/pupray/mnt/initrd.gz" shell
now "rm init" shell #arrshell mid 1 1 fileprint now
#mountfs "mount -o loop init /mnt/pupray/fs 2>&1" arrshell mid 1 1 fileprint mountfs
now "zcat " plus gz plus " | cpio -i -H newc -d 2> /dev/null" shell
initrdfiles "find /mnt/pupray/init -type f" arrshell fsortplus initrdfiles
forin p initrdfiles
now p fileprint now
next
qu 34 chr
gzparam "--exclude=" plus qu plus gz plus qu
propergz plus gzparam
fig
ifequal properinit 0
initrdfiles "find /mnt/pupray/fs -type f" arrshell fsortplus initrdfiles
forin p initrdfiles
now p fileprint now
next
gzparam "--exclude=" plus qu plus gz plus qu
propergz plus gzparam
fig
fig
fig
next
now sep
forin sfs, sfsfiles
ifequal sfs ""
pass
else
now sep
now "processing sfs file: " plus sfs fileprint now
sfsparam "--exclude=" plus qu plus sfs plus qu
singlepath split sfs "/" right 1 mid 1 1
singlename split singlepath "." mid 1 1
sfspath "/mnt/pupray/sfs/" plus singlename
now "mkdir " plus sfspath shell
propergz plus sfsparam
now sfspath chdir
now "unsquashfs -p 1 " plus sfs shell
sortfiles "find " plus sfspath plus " -type f" arrshell fsortplus sortfiles
forin p sortfiles
now p fileprint now
next
now "/mnt/pupray/sfs" chdir
fig
next
now sep
iftrue builtinminix
now "puppy kernel supports minix fs" fileprint now
else
now "no minix fs support found in this puppy kernel" fileprint now
fig
now sep
now "/mnt/pupray/" chdir
logname filename plus ".log"
log logname open "w" join loglines "" fprint logname
now logname close
params join propergz " "
tarcommand join versfs " "
tar "tar -cvzf " plus qu plus filename plus qu plus ".tgz log /mnt/pupray/sfs " plus tarcommand plus " " plus params print
now sep
now "rm -rf /mnt/pupray/init" shell
now "umount /mnt/pupray/mnt" shell
now "umount /mnt/pupray/fs 2> /dev/null" shell
now "rm -rf /mnt/pupray/sfs 2> /dev/null" shell
now "" print
```
license: 0-clause bsd
```
# 2018 mn
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
```
=> https://freesoftwareresistance.neocities.org