aboutsummaryrefslogtreecommitdiff
path: root/src/createpkg
diff options
context:
space:
mode:
Diffstat (limited to 'src/createpkg')
-rw-r--r--src/createpkg96
1 files changed, 68 insertions, 28 deletions
diff --git a/src/createpkg b/src/createpkg
index c0581a3..6473b16 100644
--- a/src/createpkg
+++ b/src/createpkg
@@ -25,6 +25,7 @@
COMMON="/usr/libexec/simplepkg/common.sh"
SLACKBUILDRC="/etc/slackbuildrc"
+# firts load simplepkg helper functions
if [ -f "$COMMON" ]; then
source $COMMON
else
@@ -34,12 +35,31 @@ fi
function safe_exit {
+ # this function deals with internal createpkg errors
+ # and also 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.
+
# exit codes
case $1 in
- 2) echo Could not create folder $2;;
+ 2) usage ;;
3) echo Could not update the repository $2 ;;
- 4) usage ;;
- 5) echo Script not found;;
+ 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 ;;
+ 36) exit 0 ;; # its supposed to never happen here :P
+ 37) echo Error decompressing source code ;;
+ 38) echo Error creating the package ;;
*) exit 1
esac
@@ -49,8 +69,10 @@ function safe_exit {
function build_repo {
+ # checkout a new slackbuild working copy
+
BASEDIR="`dirname $SLACKBUILDS`"
- mkdir -p $BASEDIR || safe_exit 2 $BASEDIR
+ mkdir -p $BASEDIR || safe_exit 4 $BASEDIR
cd $BASEDIR
svn checkout $SVN
cd $SLACKBUILDS
@@ -68,6 +90,8 @@ function usage {
function check_config {
+ # check the configuration
+
if [ -f "$SLACKBUILDRC" ]; then
source $SLACKBUILDRC
fi
@@ -83,20 +107,22 @@ function check_config {
function solve_dep {
- # TODO: solve dep with version checking
-
pack="$1"
cond="$2"
ver="$3"
if [ "$cond" != "equal" ] && [ "$cond" != "less" ] && [ "$cond" != "equalorgreater" ] && [ "$cond" != "lessequal" ] && [ ! -z "$cond" ]; then
- # TODO: error
- false
+ # slack-required has a wrong logical sentence, so we ignore it
+ check_version="no"
fi
for candidate in `ls /var/log/packages/$pack* 2> /dev/null`; do
candidate="`package_name $candidate`"
if [ "$pack" == "$candidate" ]; then
+ if [ "$check_version" != "no" ]; then
+ # TODO: check if the pack has the correct version
+ true
+ fi
found="1"
break
fi
@@ -104,12 +130,12 @@ function solve_dep {
if [ "$found" != "1" ]; then
createpkg --install $pack
+ # check if the package was built and installed
+ check_exit_status $?
else
found="0"
fi
- # TODO: check if the package was built and installed
-
}
function check_repo {
@@ -133,11 +159,21 @@ function find_script {
}
+function check_exit_status {
+
+ # check whether exit status is 0 or not
+ # if not, call safe_exit to end the program
+
+ if [ "$1" != "0" ]; then
+ safe_exit $1
+ fi
+}
+
check_config
check_repo
if [ -z "$1" ]; then
- safe_exit 4
+ safe_exit 2
elif [ "$#" == "2" ]; then
if [ "$1" == "--search" ]; then
find_script $2
@@ -149,7 +185,7 @@ elif [ "$#" == "2" ]; then
NO_DEPS="1"
PACKAGE="$2"
else
- safe_exit 4
+ safe_exit 2
fi
elif [ "$1" == "--sync" ]; then
sync_repo
@@ -157,7 +193,7 @@ elif [ "$1" == "--sync" ]; then
elif [ "${1:0:1}" != "-" ]; then
PACKAGE="$1"
else
- safe_exit 4
+ safe_exit 2
fi
if [ "$SYNC" == "yes" ]; then
@@ -172,6 +208,7 @@ fi
SCRIPT_BASE="`dirname $BUILD_SCRIPT`"
+# sets the package's slack-required
if [ -f "$SCRIPT_BASE/$PACKAGE.slack-required" ]; then
SLACK_REQ="$SCRIPT_BASE/$PACKAGE.slack-required"
elif [ -f "$SCRIPT_BASE/slack-required" ]; then
@@ -180,6 +217,8 @@ fi
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
if [ ! -z "$dep" ]; then
program="`echo $dep | awk '{ print $1 }'`"
@@ -191,27 +230,28 @@ if [ ! -z "$SLACK_REQ" ] && [ "$NO_DEPS" != "1" ]; then
fi
+# built package
cd $SCRIPT_BASE
INTERACT=no ./`basename $BUILD_SCRIPT`
-# TODO: check slackbuild exit status code according to the following:
+# check if package was built
+check_exit_status $?
+
+# this doesn't work always
#
-# ERROR_WGET=31; ERROR_MAKE=32; ERROR_INSTALL=33
-# ERROR_MD5=34; ERROR_CONF=35; ERROR_HELP=36
-# ERROR_TAR=37; ERROR_MKPKG=38
+# 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'`"
#
-# Thanks to Rudson rudsonalves at yahoo.com.br for this spec.
-
-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
+# if [ "$_ARCH" == "noarch" ]; then
+# ARCH="noarch"
+# fi
if [ "$INSTALL" == "1" ]; then
- # installpkg $REPOS/$PACKAGE-$VERSION-$ARCH-$BUILD.tgz
- upgradepkg --install-new $REPOS/$PACKAGE-$VERSION-$ARCH-$BUILD.tgz
+ # 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
fi