aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/createpkg47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/createpkg b/src/createpkg
index 54295bf..9ad52f0 100644
--- a/src/createpkg
+++ b/src/createpkg
@@ -24,10 +24,6 @@
# TODO
#
# - optionally show a dependency tree before create the package
-# - ok - ??? think if its better to change function check_config to directly source
-# both /root/.slackbuildrc and /etc/slackbuildrc
-# - 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
#
@@ -36,7 +32,7 @@
#---------------------------------------------------
function handle_error {
- # this function deals with internal createpkg errors
+ # This function deals with internal createpkg errors
# and also with non-zero exit codes from slackbuilds
# Input: $1 - error code
# Output: Error mensage
@@ -55,7 +51,7 @@ function handle_error {
return
fi
- # exit codes
+ # Exit codes
case $1 in
2) usage ;;
3) echo -e "$CL_ALERT $BASENAME: could not update the repository $2 $CL_OFF" ;;
@@ -81,8 +77,7 @@ function handle_error {
function build_repo {
- # checkout a new slackbuild working copy
-
+ # Checkout a new slackbuild working copy
BASEDIR="`dirname $SLACKBUILDS`"
mkdir -p $BASEDIR || handle_error 4 $BASEDIR
cd $BASEDIR
@@ -93,6 +88,7 @@ function build_repo {
function usage {
+ # Help mensage
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"
@@ -106,12 +102,6 @@ function usage {
function check_config {
# check the configuration
-
- # TODO: eval also ~/.slackbuildrc
- #if [ -f "$SLACKBUILDRC" ]; then
- # source $SLACKBUILDRC
- #fi
-
TMP=${TMP:=/tmp}
REPOS=${REPOS:=$TMP}
SLACKBUILDS=${SLACKBUILDS:=/var/slackbuilds}
@@ -123,6 +113,7 @@ function check_config {
function solve_dep {
+ # Solve dependency
pack="$1"
cond="$2"
ver="$3"
@@ -133,6 +124,8 @@ function solve_dep {
check_version="no"
fi
+ found="0"
+
for candidate in `ls /var/log/packages/$pack* 2> /dev/null`; do
candidate="`package_name $candidate`"
if [ "$pack" == "$candidate" ]; then
@@ -162,6 +155,7 @@ function solve_dep {
function check_repo {
+ # Verify if repository exist
if [ ! -d "$SLACKBUILDS" ]; then
build_repo
fi
@@ -170,6 +164,7 @@ function check_repo {
function sync_repo {
+ # Synchronize repository
cd $SLACKBUILDS
svn update || build_repo
@@ -177,6 +172,7 @@ function sync_repo {
function find_script {
+ # Find SlackBuild script in the repository
find $SLACKBUILDS -name $1.SlackBuild
}
@@ -189,8 +185,15 @@ function info_builds {
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"
+
+ PKG_DIR=`dirname $i`
+ if [ -e $PKG_DIR/slack-desc ]; then
+ eval "cat $PKG_DIR/slack-desc | grep '^$PACKAGE:' | cut -f2- -d:"
+ echo -e "$CL_OFF"
+ else
+ eval "cat $i | grep '^$PACKAGE:' | cut -f2- -d:"
+ echo -e "$CL_OFF"
+ fi
done
fi
@@ -302,23 +305,23 @@ check_config
check_repo
case $1 in
- '--search')
+ '--search'|'-s')
[ $# -ne 2 ] && handle_error 2 # two parameters is required
find_script $2
exit
;;
- '--info')
+ '--info'|'-f')
[ $# -ne 2 ] && handle_error 2 # two parameters is required
PKG_PATH=`find_script $2`
info_builds
exit
;;
- '--install')
+ '--install'|'-i')
[ $# -ne 2 ] && handle_error 2 # two parameters is required
PACKAGE="$2"
INSTALL="1"
;;
- '--no-deps')
+ '--no-deps'|'-nd')
[ $# -ne 2 ] && handle_error 2 # two parameters is required
NO_DEPS="1"
PACKAGE="$2"
@@ -327,11 +330,11 @@ case $1 in
sync_repo
exit
;;
- '--help'|'')
+ '--help'|'-h'|'')
usage
exit
;;
- '--list')
+ '--list'|'-l')
list_builds
exit
;;