aboutsummaryrefslogtreecommitdiff
path: root/src/createpkg
diff options
context:
space:
mode:
authorrudson <rudson@04377dda-e619-0410-9926-eae83683ac58>2006-11-19 02:25:40 +0000
committerrudson <rudson@04377dda-e619-0410-9926-eae83683ac58>2006-11-19 02:25:40 +0000
commit55e9fd24a85611ecc801d5d32679a48d138db97c (patch)
treef9ed93ab81376d228e8701ba693989beee6c385b /src/createpkg
parent4356b650caced7e2d73a40026169baceb1228b47 (diff)
downloadsimplepkg-55e9fd24a85611ecc801d5d32679a48d138db97c.tar.gz
simplepkg-55e9fd24a85611ecc801d5d32679a48d138db97c.tar.bz2
createpkg: * adição das opções --info (function info_build); * --list; * --help; * e curingas ao search (alteração do find_script); * alteração na estrutura de análise de opções (mais clara); * Adição da variável SCRIPT_NAME com basename BUILD_SCRIPT; * Incremento do CREATEPKG_CHILD com let;
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@34 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'src/createpkg')
-rw-r--r--src/createpkg171
1 files changed, 130 insertions, 41 deletions
diff --git a/src/createpkg b/src/createpkg
index 6adf502..8118715 100644
--- a/src/createpkg
+++ b/src/createpkg
@@ -24,10 +24,10 @@
# TODO
#
# - optionally show a dependency tree before create the package
-# - think if its better to change function check_config to directly source
+# - ok - ??? think if its better to change function check_config to directly source
# both /root/.slackbuildrc and /etc/slackbuildrc
-# - option --list to list all available slackbuilds
-# - option --search allowing use of wildcards or just part of the package name
+# - ok - option --list to list all available slackbuilds
+# - ok - option --search allowing use of wildcards or just part of the package name
# - in function solve_dep: resolve program versions
#
@@ -38,7 +38,9 @@ function handle_error {
# this function deals with internal createpkg errors
# and also with non-zero exit codes from slackbuilds
-
+ # Input: $1 - error code
+ # Output: Error mensage
+ #
# check slackbuild exit status are:
#
# ERROR_WGET=31; ERROR_MAKE=32; ERROR_INSTALL=33
@@ -55,10 +57,10 @@ function handle_error {
# exit codes
case $1 in
- 2) usage ;;
- 3) echo -e "$CL_ALERT $BASENAME: could not update the repository $2 $CL_OFF" ;;
- 4) echo -e "$CL_ALERT $BASENAME: could not create folder $2 $CL_OFF" ;;
- 5) echo -e "$CL_ALERT $BASENAME: script not found for $2 $CL_OFF" ;;
+ 2) usage ;;
+ 3) echo -e "$CL_ALERT $BASENAME: could not update the repository $2 $CL_OFF" ;;
+ 4) echo -e "$CL_ALERT $BASENAME: could not create folder $2 $CL_OFF" ;;
+ 5) echo -e "$CL_ALERT $BASENAME: script not found for $2 $CL_OFF" ;;
31) echo -e "$CL_ERROR $BASENAME: error downloading source for $2 $CL_OFF" ;;
32) echo -e "$CL_ERROR $BASENAME: error compiling $2 source code $CL_OFF" ;;
33) echo -e "$CL_ERROR $BASENAME: error installing $2 $CL_OFF" ;;
@@ -70,7 +72,7 @@ function handle_error {
39) echo -e "$CL_ERROR $BASENAME: error verifying GPG signature the source code for $2 $CL_OFF" ;;
40) echo -e "$CL_ERROR $BASENAME: error patching the source code for $2 $CL_OFF" ;;
41) echo -e "$CL_ERROR $BASENAME: error downloading $2 source from version control system $CL_OFF" ;;
- *) echo -e "$CL_ERROR $BASENAME: unknown error or user interrupt $CL_OFF"
+ *) echo -e "$CL_ERROR $BASENAME: unknown error or user interrupt $CL_OFF" ;;
esac
exit $1
@@ -91,10 +93,13 @@ function build_repo {
function usage {
- echo -e "$CL_COMMU usage: createpkg [--install] package-name $CL_OFF"
+ echo -e "$CL_COMMU Usage: createpkg [--install] package-name $CL_OFF"
echo -e "$CL_COMMU createpkg --no-deps package-name $CL_OFF"
- echo -e "$CL_COMMU createpkg --search package-name $CL_OFF"
- echo -e "$CL_COMMU createpkg --sync $CL_OFF"
+ echo -e "$CL_COMMU createpkg --search package-name $CL_OFF"
+ echo -e "$CL_COMMU createpkg --info package-name $CL_OFF"
+ echo -e "$CL_COMMU createpkg --list $CL_OFF"
+ echo -e "$CL_COMMU createpkg --sync $CL_OFF"
+ echo -e "$CL_COMMU createpkg --help $CL_OFF"
}
@@ -122,7 +127,8 @@ function solve_dep {
cond="$2"
ver="$3"
- if [ "$cond" != "equal" ] && [ "$cond" != "less" ] && [ "$cond" != "equalorgreater" ] && [ "$cond" != "lessequal" ] && [ ! -z "$cond" ]; then
+ #if [ "$cond" != "e" ] && [ "$cond" != "l" ] && [ "$cond" != "ge" ] && [ "$cond" != "le" ] && [ ! -z "$cond" ]; then
+ if [ ! -z "$cond" ]; then
# slack-required has a wrong logical sentence, so we ignore it
check_version="no"
fi
@@ -176,17 +182,76 @@ function find_script {
}
+function info_builds {
+
+ # Show packages info
+ if [ "$PKG_PATH" != "" ]; then
+ for i in $PKG_PATH; do
+ PACKAGE=`basename $i .SlackBuild`
+ NAME_UP=`echo $PACKAGE | tr [a-z] [A-Z]`
+ echo -e "$CL_COMMU $NAME_UP: $CL_OFF"
+ eval "cat $i | grep '^$PACKAGE:' | cut -f2- -d:"
+ echo -e "$CL_OFF"
+ done
+ fi
+
+}
+
+function list_builds {
+
+ # List all available SlackBuilds
+ # find $SLACKBUILDS -name *.SlackBuild | sed -r 's,.*/(.*)\.SlackBuild$,\1,' | sort
+ cd $SLACKBUILDS
+ echo "Sarava SlackBuilds list"
+ # level 1
+ for i in *; do
+ if [ -d $i ]; then
+ echo -e " $i: "
+ (
+ cd $i
+ # level 2
+ for j in *; do
+ if [ -d $j ]; then
+ echo -e "$CL_COMMU $j $CL_OFF"
+ (
+ cd $j
+ BUILD="`ls *.SlackBuild 2>/dev/null`"
+ if [ "$BUILD" != "" ]; then
+ # level 3
+ for k in $BUILD; do
+ echo -e "$CL_MENSG $k $CL_OFF"
+ done
+ else
+ BUILD=""
+ fi
+ for k in *; do
+ if [ -d $k ]; then
+ echo -e "$CL_MENSG $k.SlackBuild $CL_OFF"
+ fi
+ done
+ )
+ fi
+ done
+ )
+ fi
+ done
+}
+
#---------------------------------------------------
# Starting createpkg
#---------------------------------------------------
# Common functions
COMMON="/usr/libexec/simplepkg/common.sh"
+
+# TODO: SLACKBUILDRC is need?
if [ -f ~/.slackbuildrc ]; then
- source ~/.slackbuildrc
+ SLACKBUILDRC=~/.slackbuildrc
else
- source /etc/slackbuildrc 2>/dev/null
+ SLACKBUILDRC=/etc/slackbuildrc
fi
+source $SLACKBUILDRC 2>/dev/null
+
# Select color mode: gray, color or none (*)
# CL_COMMU - Communication
# CL_MENSG - Commum messages
@@ -228,7 +293,8 @@ fi
if [ -z "$CREATEPKG_CHILD" ]; then
CREATEPKG_CHILD="1"
else
- CREATEPKG_CHILD="`echo $CREATEPKG_CHILD + 1 | bc -l`"
+ #CREATEPKG_CHILD="`echo $CREATEPKG_CHILD + 1 | bc -l`"
+ let CREATEPKG_CHILD++
fi
BASENAME="`basename $0`[$CREATEPKG_CHILD]"
@@ -236,56 +302,80 @@ BASENAME="`basename $0`[$CREATEPKG_CHILD]"
check_config
check_repo
-if [ -z "$1" ]; then
- handle_error 2
-elif [ "$#" == "2" ]; then
- if [ "$1" == "--search" ]; then
+case $1 in
+ '--search')
+ [ $# -ne 2 ] && handle_error 2 # two parameters is required
find_script $2
exit
- elif [ "$1" == "--install" ]; then
+ ;;
+ '--info')
+ [ $# -ne 2 ] && handle_error 2 # two parameters is required
+ PKG_PATH=`find_script $2`
+ info_builds
+ exit
+ ;;
+ '--install')
+ [ $# -ne 2 ] && handle_error 2 # two parameters is required
PACKAGE="$2"
INSTALL="1"
- elif [ "$1" == "--no-deps" ]; then
+ ;;
+ '--no-deps')
+ [ $# -ne 2 ] && handle_error 2 # two parameters is required
NO_DEPS="1"
PACKAGE="$2"
- else
- handle_error 2
- fi
-elif [ "$1" == "--sync" ]; then
- sync_repo
- exit
-elif [ "${1:0:1}" != "-" ]; then
- PACKAGE="$1"
-else
- handle_error 2
-fi
+ ;;
+ '--sync')
+ sync_repo
+ exit
+ ;;
+ '--help'|'')
+ usage
+ exit
+ ;;
+ '--list')
+ list_builds
+ exit
+ ;;
+ *)
+ if [ "${1:0:1}" != "-" ]; then
+ PACKAGE="$1"
+ else
+ handle_error 2
+ fi
+ ;;
+esac
+# Synchronize repository
if [ "$SYNC" == "yes" ]; then
sync_repo
fi
+# Get SlackBuild script
BUILD_SCRIPT="`find_script $PACKAGE`"
+# Check SlackBuild script found
if [ -z "$BUILD_SCRIPT" ]; then
handle_error 5 $PACKAGE
fi
+# Get dirname and script name from slackbuild
SCRIPT_BASE="`dirname $BUILD_SCRIPT`"
+SCRIPT_NAME="`basename $BUILD_SCRIPT`"
echo -e "$CL_MENSG $BASENAME: found script $PACKAGE.SlackBuild, now checking for dependencies $CL_OFF"
-# sets the package's slack-required
+# 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
SLACK_REQ="$SCRIPT_BASE/slack-required"
fi
-if [ ! -z "$SLACK_REQ" ] && [ "$NO_DEPS" != "1" ]; then
+if [ ! -z "$SLACK_REQ" -a "$NO_DEPS" != "1" ]; then
# this routine checks for dependencies in package's slack-required
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/'`"
+ condition="`echo $dep | awk '{ print $2 }' | tr [=\>\<] [egl]`"
version="`echo $dep | awk '{ print $3 }' | tr -dc '[:digit:]'`"
solve_dep $program $condition $version
fi
@@ -295,13 +385,13 @@ else
echo -e "$CL_MENSG $BASENAME: no unmet dependencies for $PACKAGE $CL_OFF"
fi
-echo -e "$CL_MENSG $BASENAME: processing `basename $BUILD_SCRIPT` $CL_OFF"
+echo -e "$CL_MENSG $BASENAME: processing $SCRIPT_NAME $CL_OFF"
-# built package
+# Built package
cd $SCRIPT_BASE
-INTERACT=no ./`basename $BUILD_SCRIPT`
+INTERACT=no ./$SCRIPT_NAME
-# check if package was built
+# Check if package was built
handle_error $? $PACKAGE
if [ "$INSTALL" == "1" ]; then
@@ -310,4 +400,3 @@ if [ "$INSTALL" == "1" ]; then
PACKAGE="`ls -1 -c $REPOS/$PACKAGE-*-*-*tgz | head -n 1`"
upgradepkg --install-new $PACKAGE
fi
-