From 71e2e7804c79db5a50dbfd6f79e2cfb1268836da Mon Sep 17 00:00:00 2001 From: Jose V Beneyto Date: Tue, 10 May 2011 13:23:26 +0200 Subject: [PATCH] Added makeRelease.sh script which was modified for 2.7 too --- makeRelease.sh | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100755 makeRelease.sh diff --git a/makeRelease.sh b/makeRelease.sh new file mode 100755 index 0000000..fb1fb56 --- /dev/null +++ b/makeRelease.sh @@ -0,0 +1,90 @@ +#!/bin/bash + +# msgUsage: show a usage message and exit +msgUsage() { + 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" + exit 0 +} + +# msgWarn: show a warning message +msgWarn() { + echo "Warning, $@" 2>&1 +} + +# msgError: show a error message and exit +msgError() { + echo "Error, $@" 2>&1 + exit 1 +} + +# checkCommands: checks for command dependencies +checkCommands() { + for cmd in sudo pkgmk tar md5sum; do + if ! which $cmd 2>&1 >/dev/null; then + msgError "'$cmd' is not in your \$PATH and you need it to execute this script" + fi + done +} + +# checkVars: checks for user given arguments +# +# params: +# $1 - TMP_DIR +# $2 - PKG_DIR +# $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 "$3" ] && RELEASE_DIR="$3" + [ ! -z "$4" ] && RELEASE_NAME="$4" + # check for directories, if not create them + for dir in $TMP_DIR $RELEASE_DIR; do + if [ ! -d "$dir" ]; then + msgWarn "creating directory '$dir'" && install -d $dir || exit 1 + fi + done + TMP_DIR="$(cd $TMP_DIR; pwd)" + PKG_DIR="$(cd $PKG_DIR; pwd)" + RELEASE_DIR="$(cd $RELEASE_DIR; pwd)" + [ -z "$PACKAGES" ] && PACKAGES="$(find $PKG_DIR -type f -name '*#*pkg.tar.gz')" +} + +# 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="" + +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 + +# install all packages +pkgnum=0 +for pkg in $PACKAGES; do + sudo pkgadd -r $TMP_DIR $pkg && echo "Installing $pkg" || exit 1 + 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 .. + +echo "Installed packages: $pkgnum" +sudo rm -rf $TMP_DIR +echo "Release done: $RELEASE_DIR/$RELEASE_NAME.tar.bz2" + +# End of file -- 2.26.2