From 014f0374d20bf965427fcff7aeca0536523d4cfa Mon Sep 17 00:00:00 2001 From: rhatto Date: Mon, 23 Jul 2007 22:45:12 +0000 Subject: merged branches/0.6 into trunk git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@403 04377dda-e619-0410-9926-eae83683ac58 --- trunk/src/createpkg | 146 ++++++++++++++++++++++++++++------------------------ 1 file changed, 80 insertions(+), 66 deletions(-) (limited to 'trunk/src/createpkg') diff --git a/trunk/src/createpkg b/trunk/src/createpkg index a80b033..373c8cc 100644 --- a/trunk/src/createpkg +++ b/trunk/src/createpkg @@ -31,7 +31,7 @@ # Createpkg functions #--------------------------------------------------- -CREATEPKG_VERSION="1.0.4.1" +CREATEPKG_VERSION="1.1.1" function error_codes { @@ -55,16 +55,6 @@ function error_codes { SCRIPT_OR_PACKAGE_NOT_FOUND=202 # Script or package not found } -function eecho { - - # echoes a message - # usage: eecho - # message-type can be: commun, messag, error, normal - - echo -e "${1}${2}${normal}" - -} - function handle_error { # This function deals with internal createpkg errors @@ -140,7 +130,7 @@ function build_repo { function usage { - # Help mensage + # Help message eecho $commun "Createpkg version $CREATEPKG_VERSION\n" eecho $commun "Usage: createpkg [--install/-i] package-name" eecho $commun " createpkg --no-deps/-np package-name" @@ -155,14 +145,15 @@ function check_config { # check the configuration TMP=${TMP:=/tmp}; - REPOS=${REPOS:=$TMP}; + REPOS=${REPOS:=$MAKEPKG_REPOS}; # Create $TMP and $REPOS if need [ ! -e $TPM ] && mkdir $TMP [ ! -e $REPOS ] && mkdir $REPOS # SLACKBUILDS_DIR=${SLACKBUILDS_DIR:=/var/slackbuilds} SVN=${SVN:=svn://slack.sarava.org/slackbuilds} - SYNC=${SYNC:=no} + SYNC=${SYNC:=$no} + SYNC=`convert_boolean $SYNC` BASEDIR="`dirname $SLACKBUILDS_DIR`" } @@ -184,7 +175,7 @@ function solve_dep { if [ $CHECK -ne 0 ]; then # Check package in SlackBuilds tree eecho $messag "$BASENAME: processing $PACKAGE dependency $PACK" - SYNC=no CREATEPKG_CHILD=$CREATEPKG_CHILD createpkg --install $PACK + SYNC=$no CREATEPKG_CHILD=$CREATEPKG_CHILD createpkg --install $PACK # check if the package was built and installed EXIT_CODE="$?" @@ -193,8 +184,8 @@ function solve_dep { # exit code 5 == slackbuild not found # try to use simplaret - ARCH=$DEFAULT_ARCH simplaret --update - ARCH=$DEFAULT_ARCH simplaret --install $PACK + ARCH=$CREATE_ARCH simplaret --update + ARCH=$CREATE_ARCH simplaret --install $PACK EXIT_CODE="$?" if [ "$EXIT_CODE" != "0" ]; then handle_error $SCRIPT_OR_PACKAGE_NOT_FOUND $PACK @@ -220,7 +211,7 @@ function sync_repo { # Synchronize repository cd $SLACKBUILDS_DIR - svn update || build_repo + exit # svn update || build_repo #simplaret --update } @@ -299,37 +290,19 @@ function list_builds { } -function color_select { - - # Select color mode: gray, color or none (*) - # commun - Communication - # messag - Commum messages - # error - Error messages - # normal - turn off color - case "$1" in - 'gray') - commun="\033[37;1m" - messag="\033[37;1m" - error="\033[30;1m" - alert="\033[37m" - normal="\033[m" - ;; - 'color') - commun="\033[34;1m" # green - messag="\033[32;1m" # blue - error="\033[31;1m" # red - alert="\033[33;1m" # yellow - normal="\033[m" # normal - ;; - *) - commun="" - messag="" - error="" - alert="" - normal="" - ;; - esac +function load_parameters { + + # Load Createpkg parameters + MAKEPKG_REPOS="`eval_parameter MAKEPKG_REPOS /var/simplaret/repos`" + SOURCE_DIR="`eval_parameter SOURCE_DIR /var/simplaret/sources`" + SLACKBUILDS_DIR="`eval_parameter SLACKBUILDS_DIR /var/simplaret/slackbuilds`" + + COLOR_MODE="`eval_parameter COLOR_MODE none`" + CREATE_ARCH="`eval_parameter CREATE_ARCH $(default_arch)`" + CREATE_CLEANUP="`eval_boolean_parameter CREATE_CLEANUP $yes`" + REMOVE_OLD_PACKAGE="`eval_boolean_parameter REMOVE_OLD_PACKAGE $off`" + MOVE_BIN_PACKAGE="`eval_boolean_parameter MOVE_BIN_PACKAGE $off`" } #--------------------------------------------------- @@ -338,17 +311,24 @@ function color_select { # Common functions COMMON="/usr/libexec/simplepkg/common.sh" SIMPLEPKG_CONF="/etc/simplepkg/simplepkg.conf" +BASENAME="`basename $0`" + +if [ -f "$COMMON" ]; then + source $COMMON +else + echo "error: file $COMMON found, check your $BASENAME installation" + mk_exit 0 +fi + +set_constants + +# Load simplepkg.conf variables +load_parameters +#eval_config $BASENAME # Loading error codes error_codes -# First load simplepkg helper functions -source $COMMON && source $SIMPLEPKG_CONF -if [ $? -ne 0 ]; then - eecho $error "error: file $COMMON not found, check your $BASENAME installation" - exit 1 -fi - # Load slackbuildrc definitions if [ -f ~/.slackbuildrc ]; then source ~/.slackbuildrc @@ -357,11 +337,11 @@ else fi # Select color mode: gray, color or none (*) -color_select $COLOR +color_select $COLOR_MODE # This is used to show how many children process we have if [ -z "$CREATEPKG_CHILD" ]; then - CREATEPKG_CHILD="1" + CREATEPKG_CHILD=1 else let CREATEPKG_CHILD++ fi @@ -371,6 +351,9 @@ BASENAME="`basename $0`[$CREATEPKG_CHILD]" check_config check_repo +INSTALL=$off +NO_DEPS=$off + case $1 in '--search'|'-s') [ $# -ne 2 ] && handle_error 2 # two parameters is required @@ -386,11 +369,11 @@ case $1 in '--install'|'-i') [ $# -ne 2 ] && handle_error 2 # two parameters is required PACKAGE="$2" - INSTALL="1" + INSTALL=$on ;; '--no-deps'|'-nd') [ $# -ne 2 ] && handle_error 2 # two parameters is required - NO_DEPS="1" + NO_DEPS=$on PACKAGE="$2" ;; '--sync') @@ -415,7 +398,7 @@ case $1 in esac # Synchronize repository -[ "$SYNC" == "yes" ] && sync_repo +[ $SYNC -eq $yes ] && sync_repo # Get SlackBuild script BUILD_SCRIPT="`find_slackbuild $PACKAGE`" @@ -460,7 +443,7 @@ elif [ -f "$SCRIPT_BASE/slack-required" ]; then SLACK_REQUIRED="$SCRIPT_BASE/slack-required" fi -if [ ! -z "$SLACK_REQUIRED" -a "$NO_DEPS" != "1" ]; then +if [ ! -z "$SLACK_REQUIRED" -a $NO_DEPS -ne $on ]; then # this routine checks for dependencies in package's slack-required ( grep '^[^#]' $SLACK_REQUIRED | while read dep; do if [ ! -z "$dep" ]; then @@ -485,17 +468,48 @@ eecho $messag "$BASENAME: processing $SCRIPT_NAME" # Change to script base directory cd $SCRIPT_BASE -# Execute SlackBuild script with variables protection -( INTERACT=no sh ./$SCRIPT_NAME ) +# Make MAKEPKG_REPOS +[ ! -e $MAKEPKG_REPOS ] && mkdir -p $MAKEPKG_REPOS + +# Run SlackBuild script +( + SRC_DIR=${SRC_DIR:=$SOURCE_DIR} \ + SRC=${SRC_DIR:=$SOURCE_DIR} \ + ARCH=${ARCH:=$CREATE_ARCH} \ + COLOR=${COLOR:=$COLOR_MODE} \ + REPOS=${REPOS:=$MAKEPKG_REPOS} \ + CLEANUP=${CLEANUP:=$CREATE_CLEANUP} \ + INTERACT=no sh ./$SCRIPT_NAME +) # Check if package was built handle_error $? $PACKAGE -PKG_TGZ="`ls -1 -c $REPOS/$PACKAGE-*-*-*.tgz | head -n 1`" +# Get package name +PKG_NAME="`ls -1 -c $MAKEPKG_REPOS/$PACKAGE-*-*-*.tgz | head -n 1 | xargs basename`" -if [ "$INSTALL" == "1" ]; then +# Select repository directory +[ $MOVE_BIN_PACKAGE -eq $on ] && NEW_REPOS=$MAKEPKG_REPOS/$( echo ${SCRIPT_BASE#$SLACKBUILDS_DIR/} ) || NEW_REPOS=$MAKEPKG_REPOS + +# Create repository directory +[ ! -e $NEW_REPOS ] && mkdir -p $NEW_REPOS 2>/dev/null + +# Remove old packages from repository tree +[ $REMOVE_OLD_PACKAGE -eq $on ] && rm $NEW_REPOS/$PACKAGE-*-*-*.tgz 2>/dev/null + +# Move package to SlackBuilds-like tree +[ $MOVE_BIN_PACKAGE -eq $on ] && mv $MAKEPKG_REPOS/$PKG_NAME $NEW_REPOS/ + +# Install package +if [ "$INSTALL" -eq $on ]; then # as we dont have the full package file name, we'll # use the newer file name that matches our wildcard: - upgradepkg --install-new $PKG_TGZ + upgradepkg --install-new $NEW_REPOS/$PKG_NAME fi + +# Update repository FILELIST.TXT, ... +( + cd $MAKEPKG_REPOS + gen_filelist +) -- cgit v1.2.3