reimplemented dir2sb and sb2dir to act as 'conversion' utility

This commit is contained in:
TomasM
2018-11-23 04:05:44 -05:00
parent 5a090f6ac4
commit edb710c1b3
2 changed files with 69 additions and 22 deletions
+26 -6
View File
@@ -1,13 +1,33 @@
#!/bin/bash
# convert .sb compressed Slax Bundle file into directory tree
# Author: Tomas M. <http://www.slax.org/>
#
if [ ! -d "$2" ]; then
if [ ! -e "$1" ]; then
echo
echo "Convert .sb compressed module into directory tree"
echo "usage: $0 source_file.sb existing_output_directory"
echo "Convert .sb compressed module into directory with the same name"
echo "usage: $0 [source_file.sb] [[optional output_directory]]"
echo " If the output_directory is specified, it must exist"
echo " If the output_directory is not specified, the name source_file.sb"
echo " is used and the directory is overmounted with tmpfs"
exit 1
fi
unsquashfs -f -dest "$2" "$1" >/dev/null
if [ ! -r "$1" ]; then
echo "File does not exist: $1" >&2
exit
fi
if [ "$2" = "" ]; then
SOURCE="$1".x
while [ -e "$SOURCE" ]; do SOURCE="$SOURCE"x; done
mv "$1" "$SOURCE" || exit
mkdir "$1"
mount -t tmpfs tmpfs "$1"
unsquashfs -f -dest "$1" "$SOURCE" >/dev/null || exit
rm "$SOURCE"
else
if [ ! -d "$2" ]; then
echo "Directory does not exist: $2" >&2
exit
fi
unsquashfs -f -dest "$2" "$1" >/dev/null
fi