From 96c62a78b61d993eaeae2ca136085bffc2c5fc7c Mon Sep 17 00:00:00 2001 From: rudson Date: Wed, 28 Nov 2007 17:36:31 +0000 Subject: várias mudanças: lspkg, createpkg, mkbuild, common.sh, simplepkg.conf.new, generic.mkSlackBuild, model.mkbuild MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@458 04377dda-e619-0410-9926-eae83683ac58 --- trunk/conf/simplepkg.conf.new | 12 ++- trunk/lib/common.sh | 162 ++++++++++++++++++++++++++++- trunk/mkbuild/generic.mkSlackBuild | 7 +- trunk/mkbuild/model.mkbuild | 39 ++++--- trunk/src/createpkg | 139 +++---------------------- trunk/src/lspkg | 4 + trunk/src/mkbuild | 206 +++++++++++++++++-------------------- 7 files changed, 311 insertions(+), 258 deletions(-) diff --git a/trunk/conf/simplepkg.conf.new b/trunk/conf/simplepkg.conf.new index b5eb5e7..465a78c 100644 --- a/trunk/conf/simplepkg.conf.new +++ b/trunk/conf/simplepkg.conf.new @@ -129,12 +129,18 @@ TEMPLATE_STORAGE_STYLE="own-folder" # Set SlackBuilds default directory from scripts SLACKBUILDS_DIR="/var/simplepkg/slackbuilds" +# Set mkbuild default directory from parameters files +MKBUILDS_DIR="/var/simplepkg/mkbuild" + +# Set SlackBuilds svn default repository +SLACKBUILDS_SVN="svn://slack.sarava.org/slackbuilds" + +# Set mkbuilds svn default repository +MKBUILDS_SVN="svn://slack.sarava.org/slackbuilds" + # Set binaries default repository directory MAKEPKG_REPOS="/var/simplepkg/repos" -# Set mkbuild default repository directory -MKBUILD_REPOS="/var/simplepkg/mkbuild" - # Set sources default directory SOURCE_DIR="/var/simplepkg/sources" diff --git a/trunk/lib/common.sh b/trunk/lib/common.sh index 91f715f..ef5d62a 100644 --- a/trunk/lib/common.sh +++ b/trunk/lib/common.sh @@ -689,6 +689,156 @@ function gen_meta { } +# ----------------------------------------------- +# Error functions +# ----------------------------------------------- +function error_codes { + + # Slackbuilds error codes ** not change ** + ERROR_WGET=31 # wget error + ERROR_MAKE=32 # make source error + ERROR_INSTALL=33 # make install error + ERROR_MD5=34 # md5sum error + ERROR_CONF=35 # ./configure error + ERROR_HELP=36 # dasable + ERROR_TAR=37 # tar error + ERROR_MKPKG=38 # makepkg error + ERROR_GPG=39 # gpg check error + ERROR_PATCH=40 # patch error + ERROR_VCS=41 # cvs error + ERROR_MKDIR=42 # make directory error + # Slackbuilds error codes ** not change ** + + # Commum error codes + ERROR_FILE_NOTFOUND=100 # file not found + + # Createpkg error codes + ERROR_CREATEPKG_INSTALLPKG=200 # installpkg error + ERROR_CREATEPKG_DEPENDENCY=201 # dependency error + ERROR_CREATEPKG_SLACKBUILD_NOTFOUND=202 # Script or package not found + + # Mkbuild error codes + ERROR_MKBUILD_FILE_NOT_FOUND=500 + ERROR_MKBUILD_CONSTRUCTION=501 + ERROR_MKBUILD_PROGRAM=502 + ERROR_MKBUILD_INPUT_PAR=503 + +} + +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 + # ERROR_MD5=34; ERROR_CONF=35; ERROR_HELP=36 + # ERROR_TAR=37; ERROR_MKPKG=38 ERROR_GPG=39 + # ERROR_PATCH=40; ERROR_VCS=41; ERROR_MKDIR=42 + # + + # we don't want to process when exit status = 0 + [ "$1" == "0" ] && return + + # Exit codes + case $1 in + # + # Slackbuilds errors + $ERROR_WGET) + eecho $error "$BASENAME: error downloading source/package for $2" ;; + $ERROR_MAKE) + eecho $error "$BASENAME: error compiling $2 source code" ;; + $ERROR_INSTALL) + eecho $error "$BASENAME: error installing $2" ;; + $ERROR_MD5) + eecho $error "$BASENAME: error on source code integrity check for $2" ;; + $ERROR_CONF) + eecho $error "$BASENAME: error configuring the source code for $2" ;; + $ERROR_HELP) + exit 0 ;; # its supposed to never happen here :P + $ERROR_TAR) + eecho $error "$BASENAME: error decompressing source code for $2" ;; + $ERROR_MKPKG) + eecho $error "$BASENAME: error creating package $2" ;; + $ERROR_GPG) + eecho $error "$BASENAME: error verifying GPG signature the source code for $2" ;; + $ERROR_PATCH) + eecho $error "$BASENAME: error patching the source code for $2" ;; + $ERROR_VCS) + eecho $error "$BASENAME: error downloading $2 source from version control system" ;; + $ERROR_MKDIR) + eecho $error "$BASENAME: make directory $2 error, aborting" ;; + # + # General errors + $ERROR_FILE_NOTFOUND) + eecho $error "$BASENAME: file $2 not found!" ;; + # + # Createpkg errors + $ERROR_CREATEPKG_INSTALLPKG) + eecho $error "$BASENAME: install package $2 error, aborting" ;; + $ERROR_CREATEPKG_DEPENDENCY) + eecho $error "$BASENAME: dependency solve error, aborting" ;; + $ERROR_CREATEPKG_SLACKBUILD_NOTFOUND) + eecho $error "$BASENAME: SlackBuild or package not found" ;; + # + # Mkbuild errors + $ERROR_MKBUILD_CONSTRUCTION) + eecho $error "$BASENAME: Construction error in $2 variable." ;; + $ERROR_MKBUILD_PROGRAM) + eecho $error "$BASENAME: Program logical error." ;; + $ERROR_MKBUILD_INPUT_PAR) + eecho $error "$BASENAME: Input parameter $2 error. See \"mkbuild --help\"." ;; + # + # Others errors + *) + eecho $error "$BASENAME: unknown error or user interrupt" ;; + esac + + exit $1 + +} + +# ----------------------------------------------- +# svn functions +# ----------------------------------------------- +function build_repo { + + # Checkout a new slackbuild working copy + # input: $1 - svn directory name + # $2 - svn address + [ $# -ne 2 ] && exit 5 + SVN_BASEDIR="`dirname $1`" + mkdir -p $SVN_BASEDIR || exit 4 + cd $SVN_BASEDIR + svn checkout $2 + cd $1 + +} + +function check_repo { + + # Verify if repository exist + # input: $1 - svn directory name + # $2 - svn address + [ $# -ne 2 ] && exit 5 + [ ! -d "$1" ] && build_repo $1 $2 + +} + +function sync_repo { + + # Synchronize repository + # input: $1 - svn directory name + # $2 - svn address + [ $# -ne 2 ] && exit 5 + cd $1 + svn update || build_repo $1 $2 + +} + # ----------------------------------------------- # misc functions # ----------------------------------------------- @@ -733,7 +883,6 @@ function color_select { } - function eecho { # echoes a message @@ -744,3 +893,14 @@ function eecho { } +function is_number { + + # Check if $1 is a number + local -i int + if [ $# -eq 0 ]; then + return 1 + else + (let int=$1) 2>/dev/null + return $? # Exit status of the let thread + fi +} diff --git a/trunk/mkbuild/generic.mkSlackBuild b/trunk/mkbuild/generic.mkSlackBuild index 72f8917..6e9e222 100644 --- a/trunk/mkbuild/generic.mkSlackBuild +++ b/trunk/mkbuild/generic.mkSlackBuild @@ -50,7 +50,7 @@ TMP=${TMP:=/tmp} PKG=${PKG:=$TMP/package-$PKG_NAME} REPOS=${REPOS:=$TMP} PREFIX=${PREFIX:=[[PREFIX]]} -PKG_SRC="$TMP/$SRC_NAME-$SRC_VERSION" +PKG_WORK="$TMP/$SRC_NAME" CONF_OPTIONS=${CONF_OPTIONS:="[[OTHER CONFIGURE ARGS]]"} NUMJOBS=${NUMJOBS:="[[NUMBER OF JOBS]]"} @@ -90,6 +90,8 @@ rm -rf "$PKG" 2> /dev/null mkdir -p "$SRC_DIR" || exit $ERROR_MKDIR mkdir -p "$PKG" || exit $ERROR_MKDIR mkdir -p "$REPOS" || exit $ERROR_MKDIR +mkdir -p "$PKG_WORK" || exit $ERROR_MKDIR + off @@ -138,8 +140,9 @@ gpg --verify "$SRC_DIR/$SRC.sig" "$SRC_DIR/$SRC" || exit $ERROR_GPG off # Untar -cd "$TMP" +cd "$PKG_WORK" [[UNPACKER]] [[UNPACKER FLAGS]] "$SRC_DIR/$SRC" || exit $ERROR_TAR +PKG_SRC=`ls -l | awk '/^d/ { print $8 }'` cd "$PKG_SRC" diff --git a/trunk/mkbuild/model.mkbuild b/trunk/mkbuild/model.mkbuild index c6953db..1e7fa69 100644 --- a/trunk/mkbuild/model.mkbuild +++ b/trunk/mkbuild/model.mkbuild @@ -2,17 +2,17 @@ # Personal variables #-------------------- # Author name -[[SLACKBUILD AUTHOR]]="Your name" +[[SLACKBUILD AUTHOR]]="[[YOUR NAME]]" # Initials author name -[[SLACKBUILD AUTHOR INITIALS]]="initials" +[[SLACKBUILD AUTHOR INITIALS]]="[[YOUR SIGNATURE]]" #------------------------ # Construction Variables #------------------------ # # Complete URL address or URL base address ( without $SRC_NAME-$VERSION... ) -[[DOWNLOAD FOLDER URL]]="http://downloads.sourceforge.net/[[NAME]]/" +[[DOWNLOAD FOLDER URL]]="[[DEFAULT URL]]/[[PACKAGE NAME]]/" # Source base name. if different from package name. Null ("") to default value. # Auto-set, get SRC_NAME from URL: http://.../$SRC_NAME-$VERSION.tar.$EXTENSION' @@ -23,9 +23,9 @@ [[PACKAGE NAME]]="" # -# Source Name construction string -# Default value is: $SRC_NAME-$VERSION.tar.$EXTENSION -[[SOURCE NAME CONSTRUCTION STRING]]="$SRC_NAME-$VERSION.tar.$EXTENSION" +# Package default ARCH +# Default set is i486 +[[ARCH]]="" # # Package version. Null ("") to auto-set. @@ -37,6 +37,11 @@ # Auto-set, get EXTENSION from URL: http://.../$SRC_NAME-$VERSION.tar.$EXTENSION' [[EXTENSION]]="" +# +# Source Name construction string +# Default value is: $SRC_NAME-$VERSION.tar.$EXTENSION +[[SOURCE NAME CONSTRUCTION STRING]]="$SRC_NAME-$VERSION.tar.$EXTENSION" + # # Unpacker programa ("") to auto-set. Default "tar" # Unpacke Flags ("") to auto-set. Default flags to tar "--no-same-owner --no-same-permissions -xvf" @@ -131,15 +136,15 @@ off: postinstall_script # Sections changes #------------------ #>slackdesc -[[NAME]]: [[NAME]] by Slack.Sarava -[[NAME]]: -[[NAME]]: -[[NAME]]: -[[NAME]]: -[[NAME]]: -[[NAME]]: -[[NAME]]: -[[NAME]]: -[[NAME]]: -[[NAME]]: +[[PACKAGE NAME]]: [[PACKAGE NAME]] by Slack.Sarava +[[PACKAGE NAME]]: +[[PACKAGE NAME]]: +[[PACKAGE NAME]]: +[[PACKAGE NAME]]: +[[PACKAGE NAME]]: +[[PACKAGE NAME]]: +[[PACKAGE NAME]]: +[[PACKAGE NAME]]: +[[PACKAGE NAME]]: +[[PACKAGE NAME]]: # start a new mkbuild configure file -v, --version @@ -97,42 +101,6 @@ COPYRIGHT " | less } -function error_codes { - - # Start error codes function - NULL_STRING=499 - ERROR_FILE_NOT_FOUND=500 - ERROR_CONSTRUCTION=501 - ERROR_PROGRAM=502 - ERROR_INPUT_PAR=503 -} - -function mkbuild_error { - - # Error function - case $1 in - "$ERROR_FILE_NOT_FOUND") - echo "File $2 not found!" - ;; - "$ERROR_CONSTRUCTION") - echo "Construction error in $2 variable." - ;; - "$ERROR_PROGRAM") - echo "Program logical error." - ;; - "$ERROR_INPUT_PAR") - echo "Input parameter $2 error. See \"mkbuild --help\"." - ;; - "$NULL_STRING") - mkbuild_use - ;; - *) - echo "Unknow error!" - ;; - esac - exit $1 -} - function set_parameters { # Get and set mkbuild variables with parameters input @@ -143,15 +111,24 @@ function set_parameters { # Parameters analyze while [ "$1" ]; do case $1 in - '-c'|'--commit') - # Commit directory - COMMIT=$on + '-cs'|'--commit-slackbuild') + # Commit SlackBuild file + COMMIT_SLACKBUILD=$on + ;; + '-cm'|'--commit-mkbuild') + # commit mkbuild file + COMMIT_MKBUILD=$on + ;; + '-c'|'--commit-all') + # Commit SlackBuild and mkbuild file + COMMIT_SLACKBUILD=$on + COMMIT_MKBUILD=$on ;; '-n'|'--new') # New mkbuild configure file let i++ MKBUILD_NAME=$2 - [ ${MKBUILD_NAME:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR "--new " + [ ${MKBUILD_NAME:0:1} = "-" ] && handle_error $ERROR_MKBUILD_INPUT_PAR "--new " shift ;; '-d'|'--debug') @@ -174,36 +151,36 @@ function set_parameters { # Enter with author name let i++ AUTHOR=$2 - [ ${AUTHOR:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR AUTHOR + [ ${AUTHOR:0:1} = "-" ] && handle_error $ERROR_MKBUILD_INPUT_PAR AUTHOR shift ;; '-ai'|'--author_initials') # Enter with author name let i++ AUTHOR_INITIALS=$2 - [ ${AUTHOR_INITIALS:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR AUTHOR_INITIALS + [ ${AUTHOR_INITIALS:0:1} = "-" ] && handle_error $ERROR_MKBUILD_INPUT_PAR AUTHOR_INITIALS shift ;; '-cs'|'--const_string') # Enter with construction source name string let i++ CONST_STRING=$2 - [ ${CONST_STRING:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR CONST_STRING + [ ${CONST_STRING:0:1} = "-" ] && handle_error $ERROR_MKBUILD_INPUT_PAR CONST_STRING shift ;; '-md'|'--model') # Enter with SlackBuild model let i++ MODEL=$2 - [ ${MODEL:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR MODEL + [ ${MODEL:0:1} = "-" ] && handle_error $ERROR_MKBUILD_INPUT_PAR MODEL shift ;; '-j'|'--jobs') # Enter with SlackBuild model let i++ NUMJOBS=$2 - [ ${NUMJOBS:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR NUMJOBS - [ ! is_number $NUMJOBS ] && mkbuild_error $ERROR_INPUT_PAR NUMJOBS + [ ${NUMJOBS:0:1} = "-" ] && handle_error $ERROR_MKBUILD_INPUT_PAR NUMJOBS + [ ! is_number $NUMJOBS ] && handle_error $ERROR_MKBUILD_INPUT_PAR NUMJOBS NUMJOBS="-j$NUMJOBS" shift ;; @@ -211,41 +188,41 @@ function set_parameters { # Enter with SlackBuild model let i++ PREFIX=$2 - [ ${PREFIX:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR PREFIX + [ ${PREFIX:0:1} = "-" ] && handle_error $ERROR_MKBUILD_INPUT_PAR PREFIX shift ;; '-pn'|'--pkg_name') # Enter with package name let i++ PKG_NAME=$2 - [ ${PKG_NAME:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR PKG_NAME + [ ${PKG_NAME:0:1} = "-" ] && handle_error $ERROR_MKBUILD_INPUT_PAR PKG_NAME shift ;; '-pv'|'pkg_version') # Enter with package version let i++ VERSION=$2 - [ ${VERSION:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR VERSION + [ ${VERSION:0:1} = "-" ] && handle_error $ERROR_MKBUILD_INPUT_PAR VERSION shift ;; '-sn'|'--src_name') # Enter with source name let i++ SRC_NAME=$2 - [ ${SRC_NAME:0:1} = '-' ] && mkbuild_error $ERROR_INPUT_PAR SRC_NAME + [ ${SRC_NAME:0:1} = '-' ] && handle_error $ERROR_MKBUILD_INPUT_PAR SRC_NAME shift ;; '-u'|'--url') # Enter with url address let i++ URL=$2 - [ ${URL:0:1} = '-' ] && mkbuild_error $ERROR_INPUT_PAR URL + [ ${URL:0:1} = '-' ] && handle_error $ERROR_MKBUILD_INPUT_PAR URL shift ;; *) # mkbuild input file MK_INPUT_FILE="${1//.mkbuild}.mkbuild" - [ ! -e $MK_INPUT_FILE ] && mkbuild_error $ERROR_FILE_NOT_FOUND $MK_INPUT_FILE + [ ! -e $MK_INPUT_FILE ] && handle_error $ERROR_FILE_NOTFOUND $MK_INPUT_FILE ;; esac shift @@ -255,7 +232,7 @@ function set_parameters { function get_variable { # Get variable value from mkbuild file (MK_INPUT_FILE) - [ $# -ne 1 ] && mkbuild_error $ERROR_PROGRAM + [ $# -ne 1 ] && handle_error $ERROR_MKBUILD_PROGRAM [ -z $MK_INPUT_FILE ] && echo "Warning: no [mkbuild_file]." && return 0 grep "^\[\[${1}\]\]" $MK_INPUT_FILE | cut -f2- -d= | sed -e 's/^"//' -e 's/"$//' @@ -267,7 +244,7 @@ function edit_file { local STR_OLD local STR_NEW - [ $# -ne 3 ] && mkbuild_error $ERROR_PROGRAM + [ $# -ne 3 ] && handle_error $ERROR_MKBUILD_PROGRAM STR_OLD=$( echo $1 | sed 's/\//\\\//g' ) STR_NEW=$( echo $2 | sed 's/\//\\\//g' ) eval "sed 's/\[\[$STR_OLD\]\]/$STR_NEW/' $3 > $AUX_TMP" @@ -280,7 +257,7 @@ function edit_file_full { local STR_OLD local STR_NEW - [ $# -ne 3 ] && mkbuild_error $ERROR_PROGRAM + [ $# -ne 3 ] && handle_error $ERROR_MKBUILD_PROGRAM STR_OLD=$( echo $1 | sed 's/\//\\\//g' ) STR_NEW=$( echo $2 | sed 's/\//\\\//g' ) eval "sed 's/$STR_OLD/$STR_NEW/' $3 > $AUX_TMP" @@ -290,7 +267,7 @@ function edit_file_full { function start_build { # Build initial sections - [ $# -ne 1 ] && mkbuild_error $ERROR_PROGRAM + [ $# -ne 1 ] && handle_error $ERROR_MKBUILD_PROGRAM edit_file "SLACKBUILD AUTHOR" "$AUTHOR" $1 edit_file "SLACKBUILD AUTHOR INITIALS" $AUTHOR_INITIALS $1 @@ -301,7 +278,6 @@ function start_build { edit_file "DECOMPRESSOR TEST FLAG" "$DECOMPRESSOR_TEST_FLAG" $1 edit_file "PROGRAM URL" "$URL" $1 edit_file "ARCH" "$ARCH" $1 - [ `is_number $NUMJOBS` ] && NUMJOBS="-j${NUMJOBS}" edit_file "NUMBER OF JOBS" "$NUMJOBS" $1 edit_file "VERSION" $VERSION $1 edit_file "SOURCE NAME CONSTRUCTION STRING" "$CONST_STRING" $1 @@ -330,7 +306,7 @@ function set_status { # $1 - Section # $2 - Status # $3 - file - [ $# -ne 3 ] && mkbuild_error $ERROR_PROGRAM + [ $# -ne 3 ] && handle_error $ERROR_MKBUILD_PROGRAM if [ "`get_status $1 $3`" != "all" ]; then [ $VERBOSE -eq $on ] && echo "Section $1 $2" eval "sed 's/^<$1>.*$/<$1> $2/' $3" > $AUX_TMP @@ -345,7 +321,7 @@ function get_status { # Get status from section # $1 - Section # $2 - file - [ $# -ne 2 ] && mkbuild_error $ERROR_PROGRAM + [ $# -ne 2 ] && handle_error $ERROR_MKBUILD_PROGRAM eval "sed '/^<$1>.*$/! d' $2" } @@ -418,7 +394,7 @@ function slackdesc_edit { function section_change { # Change section lines - [ $# -ne 1 ] && mkbuild_error $ERROR_PROGRAM + [ $# -ne 1 ] && handle_error $ERROR_MKBUILD_PROGRAM # Copy first half eval "sed '1,/^<$1>/! d' $SLACKBUILD_TEMP > $AUX_TMP" @@ -472,15 +448,12 @@ function commit_slackbuild { echo "Only root can commit SlackBuilds..." return 1 fi + echo -e "\nCommit $SLACKBUILD" # check SlackBuilds directory [ ! -e $SLACKBUILDS_DIR ] && createpkg --sync # Get SlackBuild path - # Get SlackBuild path in parameter file - SLACKBUILD_PATH=`validate_parameter "$SLACKBUILD_PATH" "SLACKBUILD PATH" ""` - [ $VERBOSE -eq $on ] && echo "[[SLACKBUILD PATH]]=\"$SLACKBUILD_PATH\"" - # Get SlackBuild path in slackbuild local tree if [ -z $SLACKBUILD_PATH ]; then SLACKBUILD_PATH=`find $SLACKBUILDS_DIR -name $SLACKBUILD | xargs dirname` 2>/dev/null @@ -517,17 +490,18 @@ function commit_mkbuild { echo "Only root can commit mkbuild..." return 1 fi + echo -e "\nCommit $MK_INPUT_FILE" # check mkbuild directory - [ ! -e $MKBUILD_REPOS ] && createpkg --sync + [ ! -e $MKBUILDS_DIR ] && build_repo $MKBUILDS_DIR $MKBUILDS_SVN # Get mkbuild path in parameter file MKBUILD_PATH=`validate_parameter "$SLACKBUILD_PATH" "SLACKBUILD PATH" ""` - [ $VERBOSE -eq $on ] && echo "[[SLACKBUILD PATH]]=\"$SLACKBUILD_PATH\"" + #[ $VERBOSE -eq $on ] && echo "[[SLACKBUILD PATH]]=\"$SLACKBUILD_PATH\"" # Get mkbuild path in slackbuild local tree if [ -z $MKBUILD_PATH ]; then - MKBUILD_PATH=`find $MKBUILD_REPOS -name $MKBUILD_NAME | xargs dirname` 2>/dev/null + MKBUILD_PATH=`find $MKBUILDS_DIR -name $MK_INPUT_FILE | xargs dirname` 2>/dev/null fi # Get SlackBuild path in gentoo-portage tree @@ -545,7 +519,7 @@ function commit_mkbuild { # check path [ ! -e $MKBUILD_PATH ] && svn_mkdir $MKBUILD_PATH # add SlackBuild - svn_add $MKBUILD_NAME $MKBUILD_PATH + svn_add $MK_INPUT_FILE $MKBUILD_PATH cd $WORK } @@ -553,9 +527,8 @@ function commit_mkbuild { function svn_mkdir { # svn make directory - [ $# -ne 1 ] && mkbuild_error 0 + [ $# -ne 1 ] && handle_error 0 - echo "svn_mkdir $1 $2" DIR_LIST=`echo $1 | tr '/' ' '` DIR="" @@ -568,7 +541,7 @@ function svn_mkdir { function svn_add { # svn add file - [ $# -ne 2 ] && mkbuild_error 0 + [ $# -ne 2 ] && handle_error 0 # copy file if [ -e $2/$1 ]; then @@ -584,27 +557,17 @@ function svn_add { # ---------------------------------------------------------------- # ------------------- general functions -------------------------- -function is_number { - - # Check if $1 is a number - local -i int - if [ $# -eq 0 ]; then - return 1 - else - (let int=$1) 2>/dev/null - return $? # Exit status of the let thread - fi -} - function validate_parameter { # Validate parameter in .mkbuild file + [ $# -ne 3 ] && return 1 + if [ ! -z "$1" ]; then echo "$1" else local STRING="`get_variable "$2"`" if [ -z "$STRING" ]; then - [ ! -z "$3" ] && echo "$3" || return 1 + echo "$3" else echo "$STRING" fi @@ -628,7 +591,7 @@ function decompress_find { DECOMPRESSOR_TEST_FLAG="-t" ;; *) - mkbuild_error $ERROR_CONSTRUCTION "DECOMPRESSOR" + handle_error $ERROR_MKBUILD_CONSTRUCTION "DECOMPRESSOR" ;; esac } @@ -636,8 +599,10 @@ function decompress_find { function load_parameters { # Load Createpkg parameters - MKBUILD_REPOS="`eval_parameter MAKEPKG_REPOS /var/simplaret/repos`" SLACKBUILDS_DIR="`eval_parameter SLACKBUILDS_DIR /var/simplaret/slackbuilds`" + MKBUILDS_DIR="`eval_parameter MKBUILDS_DIR /var/simplaret/mkbuilds`" + SLACKBUILDS_SVN="`eval_parameter SLACKBUILDS_DIR svn://slack.sarava.org/slackbuilds`" + MKBUILDS_SVN="`eval_parameter MKBUILDS_SVN svn://slack.sarava.org/mkbuilds`" COLOR_MODE="`eval_parameter COLOR_MODE none`" } @@ -650,6 +615,7 @@ function load_parameters { # Common functions COMMON_SH="/usr/libexec/simplepkg/common.sh" SIMPLEPKG_CONF="/etc/simplepkg/simplepkg.conf" +BASENAME="`basename $0`" WORK=`pwd` LANG=en_US @@ -657,14 +623,15 @@ if [ -f "$COMMON_SH" ]; then source $COMMON_SH else echo "error: file $COMMON_SH not found. Check your $BASENAME installation" - mkbuild_error 0 + handle_error 0 fi # Start constants set_constants # Set commit off -COMMIT=$off +COMMIT_SLACKBUILD=$off +COMMIT_MKBUILD=$off # Set verbose off VERBOSE=$off @@ -681,33 +648,42 @@ SLACKDESC_LEN=78 # Load error codes error_codes -[ $# -eq 0 ] && mkbuild_error $NULL_STRING +[ $# -eq 0 ] && mkbuild_use && exit 1 # Configure input parameters set_parameters $@ [ $VERBOSE -eq $on ] && echo -e "$PROG_NAME version $PROG_VERSION\n" - if [ ! -z $MKBUILD_NAME ]; then - # Start new mkbuild config-file + # Create a new .mkbuild parameters-file cp $MODEL_DIR/model.mkbuild ${MKBUILD_NAME}.mkbuild - edit_file "NAME" "${MKBUILD_NAME}" ${MKBUILD_NAME}.mkbuild - edit_file "NAME" "${MKBUILD_NAME}" ${MKBUILD_NAME}.mkbuild + # Package Author + [ -z $AUTHOR ] && edit_file "YOUR NAME" "${AUTHOR}" ${MKBUILD_NAME}.mkbuild + # Package Author Signature + [ -z $AUTHOR_INITIAL ] && edit_file "YOUR SIGNATURE" "${AUTHOR_INITIAL}" ${MKBUILD_NAME}.mkbuild + # Change Default SourceForge URL + [ -z $URL ] && URL="http://downloads.sourceforge.net/[[PACKAGE NAME]]" + edit_file "DEFAULT URL" "${URL}" ${MKBUILD_NAME}.mkbuild + # Change Package Name + edit_file "PACKAGE NAME" "${MKBUILD_NAME}" ${MKBUILD_NAME}.mkbuild + edit_file "PACKAGE NAME" "${MKBUILD_NAME}" ${MKBUILD_NAME}.mkbuild + + # Print .mkbuild name echo "${MKBUILD_NAME}.mkbuild" else # Get values # Author name AUTHOR=${AUTHOR:="`get_variable "SLACKBUILD AUTHOR"`"} - [ -z "$AUTHOR" ] && mkbuild_error $ERROR_CONSTRUCTION "SLACKBUILD AUTHOR" + [ -z "$AUTHOR" ] && handle_error $ERROR_MKBUILD_CONSTRUCTION "SLACKBUILD AUTHOR" [ $VERBOSE -eq $on ] && echo "[[SLACKBUILD AUTHOR]]=\"$AUTHOR\"" # Author initials STR_MOUNT=`echo $AUTHOR | sed 's/ /\n/g' | sed 's/^\([A-Z]\).*/\1/' | sed ':i; $!N; s/\n//; ti' | tr [A-Z] [a-z]` - AUTHOR_INITIALS="`validate_parameter "$AUTHOR_INITIALS" "SLACKBUILD AUTHOR INITIALS" "$STR_MOUNT"`" || mkbuild_error $ERROR_CONSTRUCTION "SLACKBUILD AUTHOR INITIALS" + AUTHOR_INITIALS="`validate_parameter "$AUTHOR_INITIALS" "SLACKBUILD AUTHOR INITIALS" "$STR_MOUNT"`" || handle_error $ERROR_MKBUILD_CONSTRUCTION "SLACKBUILD AUTHOR INITIALS" [ $VERBOSE -eq $on ] && echo "[[SLACKBUILD AUTHOR INITIALS]]=\"$AUTHOR_INITIALS\"" # URL program - URL=`validate_parameter "$URL" "DOWNLOAD FOLDER URL" ""` || mkbuild_error $ERROR_CONSTRUCTION "URL" + URL=`validate_parameter "$URL" "DOWNLOAD FOLDER URL" ""` || handle_error $ERROR_MKBUILD_CONSTRUCTION "URL" [ $VERBOSE -eq $on ] && echo "[[URL]]=\"$URL\"" STR_MOUNT="`echo $URL | rev | cut -c1-3 | rev | tr -d '.'`" @@ -720,16 +696,16 @@ else [ $VERBOSE -eq $on ] && echo "[[DOWNLOAD FOLDER URL]]=\"$URL_BASE\"" # Extension - EXTENSION=`validate_parameter "$EXTENSION" "EXTENSION" "$STR_MOUNT"` || mkbuild_error $ERROR_CONSTRUCTION "EXTENSION" + EXTENSION=`validate_parameter "$EXTENSION" "EXTENSION" "$STR_MOUNT"` || handle_error $ERROR_MKBUILD_CONSTRUCTION "EXTENSION" [ $VERBOSE -eq $on ] && echo "[[EXTENSION]]=\"$EXTENSION\"" # Unpacker - UNPACKER=`validate_parameter "$UNPACKER" "UNPACKER" "tar"` || mkbuild_error $ERROR_CONSTRUCTION "UNPACKER" + UNPACKER=`validate_parameter "$UNPACKER" "UNPACKER" "tar"` || handle_error $ERROR_MKBUILD_CONSTRUCTION "UNPACKER" [ $VERBOSE -eq $on ] && echo "[[UNPACKER]]=\"$UNPACKER\"" # Unpacker flags - [ "$UNPACKER"=="tar" ] && STR_MOUNT="--no-same-owner --no-same-permissions -xvf" || STRING="" - UNPACKER_FLAGS=`validate_parameter "$UNPACKER_FLAGS" "UNPACKER FLAGS" "$STR_MOUNT"` || mkbuild_error $ERROR_CONSTRUCTION "UNPACKER FLAGS" + [ "$UNPACKER" == "tar" ] && STR_MOUNT="--no-same-owner --no-same-permissions -xvf" || STR_MOUNT="" + UNPACKER_FLAGS=`validate_parameter "$UNPACKER_FLAGS" "UNPACKER FLAGS" "$STR_MOUNT"` || handle_error $ERROR_MKBUILD_CONSTRUCTION "UNPACKER FLAGS" [ $VERBOSE -eq $on ] && echo "[[UNPACKER_FLAGS]]=\"$UNPACKER_FLAGS\"" # Build archteture @@ -738,7 +714,7 @@ else # Source name STR_MOUNT=`echo $SOURCE_NAME | sed -r 's/(.*)-(.*)\.(.*\..*)$/\1/'` - SRC_NAME=`validate_parameter "$SRC_NAME" "SOURCE NAME" "$STR_MOUNT"` || mkbuild_error $ERROR_CONSTRUCTION "SOURCE NAME" + SRC_NAME=`validate_parameter "$SRC_NAME" "SOURCE NAME" "$STR_MOUNT"` || handle_error $ERROR_MKBUILD_CONSTRUCTION "SOURCE NAME" [ $VERBOSE -eq $on ] && echo "[[SOURCE NAME]]=\"$SRC_NAME\"" # Package name @@ -748,7 +724,7 @@ else # Version STR_MOUNT=`echo $SOURCE_NAME | sed -r 's/(.*)-(.*)\.(.*\..*)$/\2/'` - VERSION=`validate_parameter "$VERSION" "VERSION" $STR_MOUNT` || mkbuild_error $ERROR_CONSTRUCTION "VERSION" + VERSION=`validate_parameter "$VERSION" "VERSION" $STR_MOUNT` || handle_error $ERROR_MKBUILD_CONSTRUCTION "VERSION" [ $VERBOSE -eq $on ] && echo "[[VERSION]]=\"$VERSION\"" # Construction source name string @@ -760,10 +736,11 @@ else [ $VERBOSE -eq $on ] && echo "SOURCE_NAME=\"$SOURCE_NAME\"" # Decompressor program and test flag - DECOMPRESSOR=`validate_parameter "$DECOMPRESSOR" "DECOMPRESSOR" ""` || decompress_find + DECOMPRESSOR=`validate_parameter "$DECOMPRESSOR" "DECOMPRESSOR" ""` + [ -z $DECOMPRESSOR ] && decompress_find [ $VERBOSE -eq $on ] && echo "[[DECOMPRESSOR]]=\"$DECOMPRESSOR\"" - DECOMPRESSOR_TEST_FLAG=`validate_parameter "$DECOMPRESSOR_TEST_FLAG" "DECOMPRESSOR TEST FLAG" ""` || mkbuild_error $ERROR_CONSTRUCTION "DECOMPRESSOR TEST FLAG" + DECOMPRESSOR_TEST_FLAG=`validate_parameter "$DECOMPRESSOR_TEST_FLAG" "DECOMPRESSOR TEST FLAG" ""` || handle_error $ERROR_MKBUILD_CONSTRUCTION "DECOMPRESSOR TEST FLAG" [ $VERBOSE -eq $on ] && echo "[[DECOMPRESSOR TEST FLAG]]=\"$DECOMPRESSOR_TEST_FLAG\"" # Documentations list @@ -780,6 +757,7 @@ else # Number of jobs NUMJOBS=`validate_parameter "$NUMJOBS" "NUMBER OF JOBS" ""` + [ `is_number $NUMJOBS` ] && NUMJOBS="-j${NUMJOBS}" [ $VERBOSE -eq $on ] && echo "[[NUMBER OF JOBS]]=\"$NUMJOBS\"" # Make slack-required file @@ -790,8 +768,13 @@ else MODEL=`validate_parameter "$MODEL" "SLACKBUILD MODEL" "generic.mkSlackBuild"` [ $VERBOSE -eq $on ] && echo "[[SLACKBUILD MODEL]]=\"$MODEL\"" - # - # Start build SlackBuild + # SlackBuild path + SLACKBUILD_PATH=`validate_parameter "$SLACKBUILD_PATH" "SLACKBUILD PATH" ""` + [ $VERBOSE -eq $on ] && echo "[[SLACKBUILD PATH]]=\"$SLACKBUILD_PATH\"" + + #-------------------------------------------------------------- + #- Start build SlackBuild - + #-------------------------------------------------------------- [ $VERBOSE -eq $on ] && echo -e "\nStart SlackBuild make" SLACKBUILD=${PKG_NAME}.SlackBuild SLACKBUILD_TEMP=$SLACKBUILD.tmp @@ -829,7 +812,10 @@ else change_others_parameters # Commit SlackBuild - [ $COMMIT -eq $on ] && commit_slackbuild + [ $COMMIT_SLACKBUILD -eq $on ] && commit_slackbuild + + # Commit mkbuild + [ $COMMIT_MKBUILD -eq $on ] && commit_mkbuild fi # Clear temporary files -- cgit v1.2.3