# msgUsage: show a usage message and exit
msgUsage() {
- echo "Usage: $(basename $0) [TMP_DIR] [PKG_DIR] [RELEASE_DIR] [RELEASE_NAME]"
+ echo "Usage: $(basename $0) <tmp-dir> <pkg-dir> <release-dir> <release-name>"
echo "Examples:"
- echo " \$ $(basename $0) tmp ports/core-cross releases crux-arm-rootfs-2.7"
- echo " \$ $(basename $0) tmp ports/core-cross releases crux-arm-rootfs-2.6"
- echo " \$ $(basename $0) tmp ports/core-cross-noeabi releases crux-arm-rootfs-2.6-noeabi"
+ echo " \$ $(basename $0) /tmp/rootfs ports/core-cross . minirootfs-XX"
+ echo " \$ $(basename $0) /tmp/rootfs /pub/pkg releases crux-arm-rootfs-XX"
exit 0
}
-# msgWarn: show a warning message
-msgWarn() {
- echo "Warning, $@" 2>&1
-}
-
# msgError: show a error message and exit
msgError() {
echo "Error, $@" 2>&1
# checkVars: checks for user given arguments
#
# params:
-# $1 - TMP_DIR
-# $2 - PKG_DIR
+# $1 - TMPDIR
+# $2 - PKGDIR
# $3 - RELEASE_DIR
# $4 - RELEASE_NAME
checkVars() {
[ $# -lt 1 ] && msgUsage
- [ ! -z "$1" ] && TMP_DIR="$1"
- [ "$TMP_DIR" = "/tmp" ] && msgError "you can't use /tmp as TMP_DIR"
- [ ! -z "$2" ] && PKG_DIR="$2"
+ [ ! -z "$1" ] && TMPDIR="$1"
+ [ "$TMPDIR" = "/tmp" ] && msgError "you can't use /tmp as TMPDIR"
+ [ ! -z "$2" ] && PKGDIR="$2"
[ ! -z "$3" ] && RELEASE_DIR="$3"
[ ! -z "$4" ] && RELEASE_NAME="$4"
# check for directories, if not create them
- for dir in $TMP_DIR $RELEASE_DIR; do
+ for dir in $TMPDIR $RELEASE_DIR; do
if [ ! -d "$dir" ]; then
- msgWarn "creating directory '$dir'" && install -d $dir || exit 1
+ install -d $dir || msgError "can't create directory $dir"
fi
done
- TMP_DIR="$(cd $TMP_DIR; pwd)"
- PKG_DIR="$(cd $PKG_DIR; pwd)"
+ TMPDIR="$(cd $TMPDIR; pwd)"
+ PKGDIR="$(cd $PKGDIR; pwd)"
RELEASE_DIR="$(cd $RELEASE_DIR; pwd)"
- [ -z "$PACKAGES" ] && PACKAGES="$(find $PKG_DIR -type f -name '*#*pkg.tar.gz')"
+ [ -z "$PACKAGES" ] && PACKAGES="$(find $PKGDIR -type f -name '*#*pkg.tar.*')"
}
# global variables
PWD_DIR="$(pwd)"
-TMP_DIR="$PWD_DIR/tmp"
-PKG_DIR="$PWD_DIR/pkg"
-RELEASE_DIR="$PWD_DIR/releases"
-RELEASE_NAME="crux-arm-rootfs-2.7"
-PACKAGES=""
+TMPDIR="$PWD_DIR/tmp"
+PKGDIR="$PWD_DIR/pkg"
checkCommands
checkVars $@
# create the database stuff for pkgutils
-sudo install -d -m 0755 $TMP_DIR/var/lib/pkg
-sudo touch $TMP_DIR/var/lib/pkg/db
-sudo chmod 0444 $TMP_DIR/var/lib/pkg/db
+sudo install -d -m 0755 $TMPDIR/var/lib/pkg
+sudo touch $TMPDIR/var/lib/pkg/db
+sudo chmod 0444 $TMPDIR/var/lib/pkg/db
# install all packages
pkgnum=0
+echo "Please wait for results..."
for pkg in $PACKAGES; do
- sudo pkgadd -r $TMP_DIR $pkg && echo "Installing $pkg" || exit 1
+ sudo pkgadd -r $TMPDIR $pkg || msgError "failed to install $pkg"
let pkgnum=$pkgnum+1
done
# create the tarball and the md5sum
-cd $TMP_DIR && sudo tar cvjf $RELEASE_DIR/$RELEASE_NAME.tar.bz2 * && cd ..
-cd $RELEASE_DIR && md5sum $RELEASE_NAME.tar.bz2 > $RELEASE_NAME.tar.bz2.md5 && cd ..
+cd $TMPDIR && sudo tar cJf $RELEASE_DIR/$RELEASE_NAME.tar.xz * && cd -
+cd $RELEASE_DIR && md5sum $RELEASE_NAME.tar.xz > $RELEASE_NAME.tar.xz.md5 && cd -
+
+echo "- Installed $pkgnum packages"
+echo "- Finished $RELEASE_DIR/$RELEASE_NAME.tar.xz"
-echo "Installed packages: $pkgnum"
-sudo rm -rf $TMP_DIR
-echo "Release done: $RELEASE_DIR/$RELEASE_NAME.tar.bz2"
+sudo rm -rf $TMPDIR
# End of file