Skip to content

Instantly share code, notes, and snippets.

@mturquette
Created March 11, 2015 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mturquette/0d4de9b20343fafecf2b to your computer and use it in GitHub Desktop.
Save mturquette/0d4de9b20343fafecf2b to your computer and use it in GitHub Desktop.
#!/bin/sh
usage(){
echo "usage: $0 <path/to/qpkg>"
}
if [ $# -ne 1 ]
then
usage
exit 1
fi
/bin/echo "Files generated in directory 'out'"
OUT_DIR=$PWD/out
CONTROL_DIR=$OUT_DIR/control
DATA_DIR=$OUT_DIR/data
/bin/mkdir -p $CONTROL_DIR $DATA_DIR || exit 1
line=`grep -an control.tar.gz $1 | awk -F: '{print $1}'`
echo "Removing $line lines of header script before control.tar.gz"
tail -n +$line $1 > $OUT_DIR/new$1
tar -xf $OUT_DIR/new${1} -C $OUT_DIR
/bin/dd if=$OUT_DIR/new${1} | /bin/tar -xO | /bin/tar -xzv -C $CONTROL_DIR || exit 1
offset=$(/usr/bin/expr $script_len + 20480)
/bin/dd if=$OUT_DIR/new${1} bs=$offset skip=1 | /bin/cat | /bin/dd bs=1024 of=$DATA_DIR/data.tar.gz || exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment