diff options
Diffstat (limited to 'trunk/src/mkbuild')
-rwxr-xr-x | trunk/src/mkbuild | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/trunk/src/mkbuild b/trunk/src/mkbuild index 2ff2435..f9281a2 100755 --- a/trunk/src/mkbuild +++ b/trunk/src/mkbuild @@ -18,7 +18,7 @@ # # Based in model generic.SlackBuild of Luiz # -# Version 1.1.9 +# Version: PROG_VERSION=1.1.9 PROG_NAME=`basename $0` @@ -44,6 +44,8 @@ DESCRIPTION author name -ai, --author_initials <initials> author signature + -bn, --build-number + change build number -cs, --const_string <string> construction string to source name -u, --url <url_address> @@ -110,6 +112,12 @@ function set_parameters { # Parameters analyze while [ "$1" ]; do case $1 in + '-bn'|'--build-number') + # Build Number + BUILD_NUMBER=$2 + is_number $BUILD_NUMBER || handle_error "$ERROR_NOT_NUMBER" "--build-number" + shift + ;; '-cs'|'--commit-slackbuild') # Commit SlackBuild file COMMIT_SLACKBUILD=$on @@ -179,7 +187,7 @@ function set_parameters { let i++ NUMJOBS=$2 [ ${NUMJOBS:0:1} = "-" ] && handle_error $ERROR_MKBUILD_INPUT_PAR NUMJOBS - [ ! is_number $NUMJOBS ] && handle_error $ERROR_MKBUILD_INPUT_PAR NUMJOBS + ! is_number $NUMJOBS && handle_error $ERROR_NOT_NUMBER NUMJOBS NUMJOBS="-j$NUMJOBS" shift ;; @@ -231,7 +239,7 @@ function set_parameters { function get_variable { # Get variable value from mkbuild file (MK_INPUT_FILE) - [ $# -ne 1 ] && handle_error $ERROR_MKBUILD_PROGRAM + [ $# -ne 1 ] && handle_error $ERROR_PAR_NUMBER [ -z $MK_INPUT_FILE ] && echo "Warning: no [mkbuild_file]." && return 0 grep "^\[\[${1}\]\]" $MK_INPUT_FILE | cut -f2- -d= | sed -e 's/^"//' -e 's/"$//' @@ -243,7 +251,7 @@ function edit_file { local STR_OLD local STR_NEW - [ $# -ne 3 ] && handle_error $ERROR_MKBUILD_PROGRAM + [ $# -ne 3 ] && handle_error $ERROR_PAR_NUMBER STR_OLD=$( echo $1 | sed 's/\//\\\//g' ) STR_NEW=$( echo $2 | sed 's/\//\\\//g' ) eval "sed 's/\[\[$STR_OLD\]\]/$STR_NEW/' $3 > $AUX_TMP" @@ -256,7 +264,7 @@ function edit_file_full { local STR_OLD local STR_NEW - [ $# -ne 3 ] && handle_error $ERROR_MKBUILD_PROGRAM + [ $# -ne 3 ] && handle_error $ERROR_PAR_NUMBER STR_OLD=$( echo $1 | sed 's/\//\\\//g' ) STR_NEW=$( echo $2 | sed 's/\//\\\//g' ) eval "sed 's/$STR_OLD/$STR_NEW/' $3 > $AUX_TMP" @@ -266,7 +274,7 @@ function edit_file_full { function start_build { # Build initial sections - [ $# -ne 1 ] && handle_error $ERROR_MKBUILD_PROGRAM + [ $# -ne 1 ] && handle_error $ERROR_PAR_NUMBER edit_file "SLACKBUILD AUTHOR" "$AUTHOR" $1 edit_file "SLACKBUILD AUTHOR INITIALS" $AUTHOR_INITIALS $1 @@ -287,6 +295,7 @@ function start_build { edit_file "PREFIX" "$PREFIX" $1 edit_file "UNPACKER" "$UNPACKER" $1 edit_file "UNPACKER FLAGS" "$UNPACKER_FLAGS" $1 + edit_file "BUILD NUMBER" "$BUILD_NUMBER" $1 edit_file_full "\$EXTENSION" "$EXTENSION" $1 } @@ -305,7 +314,7 @@ function set_status { # $1 - Section # $2 - Status # $3 - file - [ $# -ne 3 ] && handle_error $ERROR_MKBUILD_PROGRAM + [ $# -ne 3 ] && handle_error $ERROR_PAR_NUMBER if [ "`get_status $1 $3`" != "all" ]; then [ $VERBOSE -eq $on ] && echo "Section $1 $2" eval "sed 's/^<$1>.*$/<$1> $2/' $3" > $AUX_TMP @@ -320,7 +329,7 @@ function get_status { # Get status from section # $1 - Section # $2 - file - [ $# -ne 2 ] && handle_error $ERROR_MKBUILD_PROGRAM + [ $# -ne 2 ] && handle_error $ERROR_PAR_NUMBER eval "sed '/^<$1>.*$/! d' $2" } @@ -393,7 +402,7 @@ function slackdesc_edit { function section_change { # Change section lines - [ $# -ne 1 ] && handle_error $ERROR_MKBUILD_PROGRAM + [ $# -ne 1 ] && handle_error $ERROR_PAR_NUMBER # Copy first half eval "sed '1,/^<$1>/! d' $SLACKBUILD_TEMP > $AUX_TMP" @@ -526,7 +535,7 @@ function commit_mkbuild { function svn_mkdir { # svn make directory - [ $# -ne 1 ] && handle_error 0 + [ $# -ne 1 ] && handle_error $ERROR_PAR_NUMBER DIR_LIST=`echo $1 | tr '/' ' '` @@ -540,7 +549,7 @@ function svn_mkdir { function svn_add { # svn add file - [ $# -ne 2 ] && handle_error 0 + [ $# -ne 2 ] && handle_error $ERROR_PAR_NUMBER # copy file if [ -e $2/$1 ]; then @@ -559,16 +568,16 @@ function svn_add { function validate_parameter { # Validate parameter in .mkbuild file - [ $# -ne 3 ] && return 1 + [ $# -ne 3 ] && handle_error $ERROR_PAR_NUMBER if [ ! -z "$1" ]; then echo "$1" else local STRING="`get_variable "$2"`" - if [ -z "$STRING" ]; then - echo "$3" - else + if [ ! -z "$STRING" ]; then echo "$STRING" + else + echo "$3" fi fi } @@ -621,8 +630,7 @@ LANG=en_US if [ -f "$COMMON_SH" ]; then source $COMMON_SH else - echo "error: file $COMMON_SH not found. Check your $BASENAME installation" - handle_error 0 + handle_error $ERROR_COMMON_NOT_FOUND fi # Start constants @@ -703,6 +711,8 @@ else EXTENSION=`validate_parameter "$EXTENSION" "EXTENSION" "$STR_MOUNT"` || handle_error $ERROR_MKBUILD_CONSTRUCTION "EXTENSION" [ $VERBOSE -eq $on ] && echo "[[EXTENSION]]=\"$EXTENSION\"" + BUILD_NUMBER=`validate_parameter "$BUILD_NUMBER" "BUILD NUMBER" "1"` || handle_error $ERROR_MKBUILD_CONSTRUCTION "BUILD NUMBER" + # Unpacker UNPACKER=`validate_parameter "$UNPACKER" "UNPACKER" "tar"` || handle_error $ERROR_MKBUILD_CONSTRUCTION "UNPACKER" [ $VERBOSE -eq $on ] && echo "[[UNPACKER]]=\"$UNPACKER\"" @@ -761,7 +771,7 @@ else # Number of jobs NUMJOBS=`validate_parameter "$NUMJOBS" "NUMBER OF JOBS" ""` - [ `is_number $NUMJOBS` ] && NUMJOBS="-j${NUMJOBS}" + is_number $NUMJOBS && NUMJOBS="-j${NUMJOBS}" [ $VERBOSE -eq $on ] && echo "[[NUMBER OF JOBS]]=\"$NUMJOBS\"" # Make slack-required file |