# #
###############################################################################
-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
--- /dev/null
+#!/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