]> git.ipfire.org Git - ipfire-3.x.git/commitdiff
Updated pakfire's compressor and decompressor.
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 5 May 2009 09:44:53 +0000 (11:44 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 5 May 2009 09:44:53 +0000 (11:44 +0200)
src/pakfire/compressor
src/pakfire/decompressor [new file with mode: 0755]

index 3ef86d351e041d79452d71dc93d88828b4d7726e..351baa1cd69575f7b98f94f149c0ba52299a0527 100755 (executable)
 #                                                                             #
 ###############################################################################
 
-PKG_NAME=$1
-PKG_VER=$2
-PKG_REL=$3
-ROOTFILE=$4
+while [ $# -gt 0 ]; do
+       case "$1" in
+               *)
+                       if [ -z "$PKG_TARGET" ]; then
+                               PKG_TARGET=$1
+                       else
+                               if [ ! -e "$1" ]; then
+                                       echo "Rootfile do not exist: $1" >&2
+                                       exit 1
+                               fi
+                               ROOTFILES="$ROOTFILES $1"
+                       fi
+                       ;;
+       esac
+       shift
+done
 
 if [ -z "$TARGET" ]; then
        echo "TARGET is not set. Cannot continue." >&2
        exit 1
 fi
 
-if [ ! -e "$ROOTFILE" ]; then
-       echo "Rootfile does not exist: $ROOTFILE" >&2
-       exit 1
-fi
+echo -n "Running for $PKG_TARGET..."
 
-PKG_LIST="normal"
-# Checking for a devel package
-grep -q "^D" $ROOTFILE && PKG_LIST="$PKG_LIST devel"
-
-if [ -n "${PKG_VER}" ]; then
-    PKG_STRING="${PKG_NAME}-${PKG_VER}"
-else
-    PKG_STRING="${PKG_NAME}"
+if [ -e "/packages/$PKG_TARGET" ]; then
+       echo "Skip."
+       exit 0
 fi
 
-for PKG_EXTRA in $PKG_LIST; do
-       # Prepare target name.
-       PKG_TARGET=${PKG_STRING}-${SNAME}-${PKG_REL}
-       if [ "$PKG_EXTRA" != "normal" ]; then
-               PKG_TARGET="$PKG_TARGET-$PKG_EXTRA"
-       fi
-       PKG_TARGET="$PKG_TARGET.ipk"
-
-       echo "Running for $PKG_TARGET..."
+ARCHIEVE=$(mktemp)
+TMP_DIR=$(mktemp -d)
 
-       ARCHIEVE=$(mktemp)
-
-       # Remove unused files from filelist
-       FILELIST=$(grep -v "^#" $ROOTFILE)
-
-       if [ "$PKG_EXTRA" = "devel" ]; then
-               FILELIST=$(echo "$FILELIST" | grep "^D" | sed -e "s/^D//g")
-       else
-               FILELIST=$(echo "$FILELIST" | grep -v "^D")
-       fi
-
-       FILELIST=$(echo "$FILELIST" | sed \
-               -e "s/KVER/$KVER/g" \
-               -e "s/IFS_TARGET/$IFS_TARGET/g")
+for rootfile in $ROOTFILES; do
+       cd / && grep -v "^#" < $rootfile | \
+                       sed -e "s/KVER/$KVER/g" \
+                               -e "s/IFS_TARGET/$IFS_TARGET/g" | \
+                       cpio -pdl --quiet $TMP_DIR
+done
 
-       if [ -z "$FILELIST" ]; then
-               rm -f $ARCHIEVE
-               continue
-       fi
+cd $TMP_DIR
 
-       # Changing to root
-       cd /
+find . | cpio -o --quiet | lzma -czv - > $ARCHIEVE
 
-       echo "$FILELIST" | cpio -o | lzma -czv - > $ARCHIEVE
+cat $ARCHIEVE > /packages/$PKG_TARGET
 
-       cat $ARCHIEVE > /packages/$PKG_TARGET
+echo "Done."
 
-       rm -f $ARCHIEVE
-done
+rm -rf $ARCHIEVE $TMP_DIR
diff --git a/src/pakfire/decompressor b/src/pakfire/decompressor
new file mode 100755 (executable)
index 0000000..337a4de
--- /dev/null
@@ -0,0 +1,56 @@
+#!/bin/bash
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2007, 2008, 2009 Michael Tremer & Christian Schmidt           #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+FILES=
+ROOT=/
+
+while [ $# -gt 0 ]; do
+       case "$1" in
+               --root=*)
+                       ROOT=${1#--root=}
+                       ;;
+               *.ipk)
+                       file=$1
+                       [ ${file:0:1} != / ] && file="$(pwd)/$file"
+                       if [ -e "$file" ]; then
+                               FILES="$FILES $file"
+                       else
+                               echo "File does not exist: $file" >&2
+                               exit 1
+                       fi
+                       ;;
+       esac
+       shift
+done
+
+if [ "$ROOT" != "/" ]; then
+       [ -d "$ROOT" ] || mkdir -p $ROOT
+       cd $ROOT
+       if [ "$(pwd)" != "$ROOT" ]; then
+               echo "Could not change to root: $ROOT" >&2
+               exit 1
+       fi
+fi
+
+for file in $FILES; do
+       echo "Extracting $file..."
+       lzma -cd $file | cpio -diu --no-absolute-filenames --quiet
+done