diff options
author | rhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58> | 2006-10-19 17:52:38 +0000 |
---|---|---|
committer | rhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58> | 2006-10-19 17:52:38 +0000 |
commit | aefb82a795b8666a3c5e1145f1024fb20e20e2f7 (patch) | |
tree | 2df30a7dd5c8d5a22207fcd6e5d15af7f1057205 /src | |
parent | 560edbaa13345acaff93c319446cb8faaeb135fb (diff) | |
download | simplepkg-aefb82a795b8666a3c5e1145f1024fb20e20e2f7.tar.gz simplepkg-aefb82a795b8666a3c5e1145f1024fb20e20e2f7.tar.bz2 |
simplepkg 0.4.9pre6
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@20 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'src')
-rw-r--r-- | src/createpkg | 108 |
1 files changed, 57 insertions, 51 deletions
diff --git a/src/createpkg b/src/createpkg index c38b17a..c7b35a8 100644 --- a/src/createpkg +++ b/src/createpkg @@ -25,42 +25,51 @@ COMMON="/usr/libexec/simplepkg/common.sh" SLACKBUILDRC="/etc/slackbuildrc" -# firts load simplepkg helper functions +# first load simplepkg helper functions if [ -f "$COMMON" ]; then source $COMMON else - echo "error: file $COMMON found, check your `basename $0` installation" + echo "error: file $COMMON found, check your $BASENAME installation" exit 1 fi -function safe_exit { +function handle_error { # this function deals with internal createpkg errors - # and also non-zero exit codes from slackbuilds + # and also with non-zero exit codes from slackbuilds # check slackbuild exit status are: # # ERROR_WGET=31; ERROR_MAKE=32; ERROR_INSTALL=33 # ERROR_MD5=34; ERROR_CONF=35; ERROR_HELP=36 - # ERROR_TAR=37; ERROR_MKPKG=38 ERROR_GPG=? - # ERROR_PATCH=? - # Thanks to Rudson rudsonalves at yahoo.com.br for this spec. + # ERROR_TAR=37; ERROR_MKPKG=38 ERROR_GPG=39 + # ERROR_PATCH=40; ERROR_VCS=41 + # + # thanks to rudsonalves at yahoo.com.br for this spec. + + # we don't want to process when exit status = 0 + if [ "$1" == "0" ]; then + return + fi # exit codes case $1 in 2) usage ;; - 3) echo Could not update the repository $2 ;; - 4) echo Could not create folder $2 ;; - 5) echo Script not found ;; - 31) echo Error downloading package ;; - 32) echo Error compiling the program ;; - 33) echo Error installing program ;; - 34) echo Error on source code integrity check ;; - 35) echo Error configuring the program ;; + 3) echo $BASENAME: could not update the repository $2 ;; + 4) echo $BASENAME: could not create folder $2 ;; + 5) echo $BASENAME: script not found for $2 ;; + 31) echo $BASENAME: error downloading source for $2 ;; + 32) echo $BASENAME: error compiling $2 source code ;; + 33) echo $BASENAME: error installing $2 ;; + 34) echo $BASENAME: error on source code integrity check for $2 ;; + 35) echo $BASENAME: error configuring the source code for $2 ;; 36) exit 0 ;; # its supposed to never happen here :P - 37) echo Error decompressing source code ;; - 38) echo Error creating the package ;; - *) exit 1 + 37) echo $BASENAME: error decompressing source code for $2 ;; + 38) echo $BASENAME: error creating package $2 ;; + 39) echo $BASENAME: error verifying GPG signature the source code for $2 ;; + 40) echo $BASENAME: error patching the source code for $2 ;; + 41) echo $BASENAME: error downloading $2 source from version control system ;; + *) echo $BASENAME: unknown error or user interrupt esac exit $1 @@ -72,7 +81,7 @@ function build_repo { # checkout a new slackbuild working copy BASEDIR="`dirname $SLACKBUILDS`" - mkdir -p $BASEDIR || safe_exit 4 $BASEDIR + mkdir -p $BASEDIR || handle_error 4 $BASEDIR cd $BASEDIR svn checkout $SVN cd $SLACKBUILDS @@ -129,9 +138,14 @@ function solve_dep { done if [ "$found" != "1" ]; then - createpkg --install $pack + echo $BASENAME: processing $PACKAGE dependency $pack + SYNC=no CREATEPKG_CHILD=$CREATEPKG_CHILD createpkg --install $pack # check if the package was built and installed - check_exit_status $? + exit_code="$?" + if [ "$exit_code" != "0" ]; then + echo $BASENAME: received an error when processing $pack, aborting + exit $exit_code + fi else found="0" fi @@ -159,21 +173,20 @@ function find_script { } -function check_exit_status { - - # check whether exit status is 0 or not - # if not, call safe_exit to end the program +# this is used to show how many children process we have +if [ -z "$CREATEPKG_CHILD" ]; then + CREATEPKG_CHILD="1" +else + CREATEPKG_CHILD="`echo $CREATEPKG_CHILD + 1 | bc -l`" +fi - if [ "$1" != "0" ]; then - safe_exit $1 - fi -} +BASENAME="`basename $0`[$CREATEPKG_CHILD]" check_config check_repo if [ -z "$1" ]; then - safe_exit 2 + handle_error 2 elif [ "$#" == "2" ]; then if [ "$1" == "--search" ]; then find_script $2 @@ -185,7 +198,7 @@ elif [ "$#" == "2" ]; then NO_DEPS="1" PACKAGE="$2" else - safe_exit 2 + handle_error 2 fi elif [ "$1" == "--sync" ]; then sync_repo @@ -193,7 +206,7 @@ elif [ "$1" == "--sync" ]; then elif [ "${1:0:1}" != "-" ]; then PACKAGE="$1" else - safe_exit 2 + handle_error 2 fi if [ "$SYNC" == "yes" ]; then @@ -203,7 +216,7 @@ fi BUILD_SCRIPT="`find_script $PACKAGE`" if [ -z "$BUILD_SCRIPT" ]; then - safe_exit 5 + handle_error 5 $PACKAGE fi SCRIPT_BASE="`dirname $BUILD_SCRIPT`" @@ -215,43 +228,36 @@ elif [ -f "$SCRIPT_BASE/slack-required" ]; then SLACK_REQ="$SCRIPT_BASE/slack-required" fi +echo $BASENAME: found script $PACKAGE.SlackBuild, now checking for dependencies + if [ ! -z "$SLACK_REQ" ] && [ "$NO_DEPS" != "1" ]; then # this routine checks for dependencies in package's slack-required - cat $SLACK_REQ | while read dep; do + while read dep; do if [ ! -z "$dep" ]; then program="`echo $dep | awk '{ print $1 }'`" condition="`echo $dep | awk '{ print $2 }' | sed -e 's/>=/equalorgreater/' -e 's/=</equalorless/' -e 's/</less/' -e 's/>/greater/' -e 's/=/equal/'`" version="`echo $dep | awk '{ print $3 }' | tr -dc '[:digit:]'`" solve_dep $program $condition $version fi - done + done < <( cat $SLACK_REQ ) fi +echo $BASENAME: processing `basename $BUILD_SCRIPT` + # built package cd $SCRIPT_BASE INTERACT=no ./`basename $BUILD_SCRIPT` # check if package was built -check_exit_status $? - -# this doesn't work always -# -# VERSION="`grep -e '^VERSION=' $BUILD_SCRIPT | head -n 1 | sed -e "s/VERSION//g" -e 's/=//g' -e 's/-//g' | cut -d ":" -f 2 | cut -d "}" -f 1`" -# BUILD="`grep -e '^BUILD=' $BUILD_SCRIPT | head -n 1 | sed -e "s/BUILD//g" -e 's/=//g' | cut -d ":" -f 2 | cut -d "}" -f 1`" -# _ARCH="`grep -e '^ARCH' $BUILD_SCRIPT | head -n 1 | cut -d "=" -f 2 | sed -e 's/"//g'`" -# -# if [ "$_ARCH" == "noarch" ]; then -# ARCH="noarch" -# fi +handle_error $? $PACKAGE if [ "$INSTALL" == "1" ]; then - # we can do the following cause we dont have the full package name: - # upgradepkg --install-new $REPOS/$PACKAGE-$VERSION-$ARCH-$BUILD.tgz - - # so we do this: - upgradepkg --install-new $REPOS/$PACKAGE-*-*-*tgz + # as we dont have the full package file name, we'll + # use the newer file name that matches our wildcard: + PACKAGE="`ls -1 -c $REPOS/$PACKAGE-*-*-*tgz | head -n 1`" + upgradepkg --install-new $PACKAGE fi |