aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbranches/0.6/src/mkbuild154
1 files changed, 89 insertions, 65 deletions
diff --git a/branches/0.6/src/mkbuild b/branches/0.6/src/mkbuild
index 200e2b1..fce2533 100755
--- a/branches/0.6/src/mkbuild
+++ b/branches/0.6/src/mkbuild
@@ -9,8 +9,8 @@
# SlackBuilds são scripts utilizados no Slackware para gerar
# pacotes tgz.
#
-# Version 0.9.7
-PROG_VERSION=0.9.7
+# Version 0.9.8
+PROG_VERSION=0.9.8
#--------------------------------------------------------------------
# Functions
@@ -21,7 +21,7 @@ function mkbuild_use()
# mkbuild help function
echo "
NAME
- mkbuild - create SlackBuild script from mkbuild_file input
+ mkbuild - create SlackBuild script from .mkbuild input file
SYNOPSIS
mkbuild [OPIONS] [mkbuild_file]
@@ -67,6 +67,10 @@ EXAMPLES
AUTHOR
Written by Rduson R. Alves
+AVAILABILITY
+ by svn: svn checkout svn://slack.sarava.org/simplepkg
+ this mkbuild is found in branches/0.6/
+
REPORTING BUGS
Report bugs to <alves_list@yahoo.com.br>
@@ -281,7 +285,7 @@ function start_build {
edit_file "VERSION" $VERSION $1
edit_file "SOURCE NAME CONSTRUCTION STRING" "$CONST_STRING" $1
edit_file "EXTENSION" "$EXTENSION" $1
- edit_file "DOWNLOAD FOLDER URL" "$URL" $1
+ edit_file "DOWNLOAD FOLDER URL" "$URL_BASE" $1
edit_file "OTHER CONFIGURE ARGS" "$OPTIONS" $1
edit_file "DOCUMENTATION FILES" "$DOCFILES" $1
edit_file "PREFIX" "$PREFIX" $1
@@ -425,10 +429,14 @@ function change_others_fields {
function commit_slackbuild {
- AUX=`lynx -dump http://gentoo-portage.com/Search?search=$PKG_NAME | sed -n '/Results:/,+1 { /Results:/ b ; p }' | head --lines=1 | tr -d " "`
- [ -z $AUX ] && echo $SLACKBUILD path not found! && return 0
-
- SLACKBUILD_PATH="`dirname $AUX | tr - /`/`basename $AUX`"
+ # Commit SlackBuild in local Slack.Sarava tree
+ # Get SlackBuild path
+ SLACKBUILD_PATH=`validate_parameter "$SLACKBUILD_PATH" "SLACKBUILD PATH" ""`
+ if [ $? != 0 ]; then
+ # Mount SlackBuild path
+ AUX=`lynx -dump http://gentoo-portage.com/Search?search=$PKG_NAME | sed -n '/Results:/,+1 { /Results:/ b ; p }' | head --lines=1 | tr -d " "`
+ [ ! -z $AUX ] && SLACKBUILD_PATH="`dirname $AUX | tr - /`/`basename $AUX`" || SLACKBUILD_PATH="others/unclassified/$PKG_NAME"
+ fi
# check SlackBuilds directory
[ ! -e $SLACKBUILDS_DIR ] && createpkg --sync
@@ -479,11 +487,11 @@ function svn_add {
fi
}
-function is_number()
-{
+function is_number {
+
+ # Check if $1 is a number
local -i int
- if [ $# -eq 0 ]
- then
+ if [ $# -eq 0 ]; then
return 1
else
(let int=$1) 2>/dev/null
@@ -491,6 +499,43 @@ function is_number()
fi
}
+function validate_parameter {
+
+ # Validate parameter in .mkbuild file
+ if [ ! -z "$1" ]; then
+ echo "$1"
+ else
+ local STRING="`get_variable "$2"`"
+ if [ -z "$STRING" ]; then
+ [ ! -z "$3" ] && echo "$3" || return 1
+ else
+ echo "$STRING"
+ fi
+ fi
+}
+
+function decompress_find {
+
+ # Find decompressor program and test flag
+ case $EXTENSION in
+ 'gz'|'GZ')
+ DECOMPRESSOR="gunzip"
+ DECOMPRESSOR_TEST_FLAG="-t"
+ ;;
+ 'bz2'|'BZ2')
+ DECOMPRESSOR="bunzip2"
+ DECOMPRESSOR_TEST_FLAG="-t"
+ ;;
+ 'zip'|'ZIP')
+ DECOMPRESSOR="unzip"
+ DECOMPRESSOR_TEST_FLAG="-t"
+ ;;
+ *)
+ mkbuild_error $ERROR_CONSTRUCTION "DECOMPRESSOR"
+ ;;
+ esac
+}
+
#=============================
# Main Program
#=============================
@@ -511,7 +556,6 @@ fi
# createpkg and mkbuild section
SLACKBUILDS_DIR="`eval_parameter SLACKBUILDS_DIR /var/slackbuilds`"
-#MAKEPKG_REPOS="`eval_parameter MAKEPKG_REPOS /var/simplaret/binaries`"
#-----------------------------
# Start variables
@@ -532,91 +576,71 @@ error_codes
set_parameters $@
# Get values
+# Author name
AUTHOR=${AUTHOR:="`get_variable "SLACKBUILD AUTHOR"`"}
[ -z "$AUTHOR" ] && mkbuild_error $ERROR_CONSTRUCTION "SLACKBUILD AUTHOR"
-AUTHOR_INITIALS=${AUTHOR_INITIALS:="`get_variable "SLACKBUILD AUTHOR INITIALS"`"}
-[ -z $AUTHOR_INITIALS ] && AUTHOR_INITIALS=`echo $AUTHOR | sed 's/ /\n/g' | sed 's/^\([A-Z]\).*/\1/' | sed ':i; $!N; s/\n//; ti' | tr [A-Z] [a-z]`
-[ -z $AUTHOR_INITIALS ] && mkbuild_error $ERROR_CONSTRUCTION "SLACKBUILD AUTHOR INITIALS"
+# 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"
+
+# URL program
+URL=`validate_parameter "$URL" "DOWNLOAD FOLDER URL" ""` || mkbuild_error $ERROR_CONSTRUCTION "URL"
-URL=${URL:="`get_variable "DOWNLOAD FOLDER URL"`"}
-EXTENSION=${EXTENSION:="`echo $URL | rev | cut -c1-3 | rev | tr -d '.'`"}
-if [ $EXTENSION = "gz" -o $EXTENSION = "tgz" -o $EXTENSION = "bz2" -o $EXTENSION = "zip" ]; then
+STR_MOUNT="`echo $URL | rev | cut -c1-3 | rev | tr -d '.'`"
+if [ $STR_MOUNT = "gz" -o $STR_MOUNT = "tgz" -o $STR_MOUNT = "bz2" -o $STR_MOUNT = "zip" ]; then
SOURCE_NAME=`basename $URL`
URL_BASE=`dirname $URL`
else
- EXTENSION=`get_variable "EXTENSION"`
- [ -z $EXTENSION ] && mkbuild_error $ERROR_CONSTRUCTION "EXTENSION"
URL_BASE=$URL
fi
+# Extension
+EXTENSION=`validate_parameter "$EXTENSION" "EXTENSION" "$STR_MOUNT"` || mkbuild_error $ERROR_CONSTRUCTION "EXTENSION"
+
+# Build archteture
+ARCH=`validate_parameter "$ARCH" "ARCH" "i486"`
+
# Source name
-SRC_NAME=${SRC_NAME:="`get_variable "SOURCE NAME"`"}
-[ -z $SRC_NAME ] && SRC_NAME=`echo $SOURCE_NAME | sed -r 's/(.*)-(.*)\.(.*\..*)$/\1/'`
-[ -z $SRC_NAME ] && mkbuild_error $ERROR_CONSTRUCTION "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"
# Package name
-PKG_NAME=${PKG_NAME:="`get_variable "PACKAGE NAME"`"}
-[ -z $PKG_NAME ] && PKG_NAME=`echo $SRC_NAME | tr [A-Z_] [a-z\-]`
+STR_MOUNT=`echo $SRC_NAME | tr [A-Z_] [a-z\-]`
+PKG_NAME=`validate_parameter "$PKG_NAME" "PACKAGE NAME" "$STR_MOUNT"`
# Version
-VERSION=${VERSION:="`get_variable "VERSION"`"}
-[ -z $VERSION ] && VERSION=`echo $SOURCE_NAME | sed -r 's/(.*)-(.*)\.(.*\..*)$/\2/'`
-[ -z $VERSION ] && mkbuild_error $ERROR_CONSTRUCTION "VERSION"
+STR_MOUNT=`echo $SOURCE_NAME | sed -r 's/(.*)-(.*)\.(.*\..*)$/\2/'`
+VERSION=`validate_parameter "$VERSION" "VERSION" $STR_MOUNT` || mkbuild_error $ERROR_CONSTRUCTION "VERSION"
# Construction source name string
-CONST_STRING=${CONST_STRING:="`get_variable "SOURCE NAME CONSTRUCTION STRING"`"}
-[ -z "$CONST_STRING" ] && CONST_STRING="\$SRC_NAME-\$VERSION.tar.$EXTENSION"
+CONST_STRING="`validate_parameter "$CONST_STRING" "SOURCE NAME CONSTRUCTION STRING" "\\\$SRC_NAME-\\\$VERSION.tar.$EXTENSION"`"
# Build Source Name
[ -z $SOURCE_NAME ] && SOURCE_NAME=`eval "echo $CONST_STRING"`
# Decompressor program and test flag
-DECOMPRESSOR=${DECOMPRESSOR:="`get_variable "DECOMPRESSOR"`"}
-if [ -z $DECOMPRESSOR ]; then
- case $EXTENSION in
- 'gz'|'GZ')
- DECOMPRESSOR="gunzip"
- DECOMPRESSOR_TEST_FLAG="-t"
- ;;
- 'bz2'|'BZ2')
- DECOMPRESSOR="bunzip2"
- DECOMPRESSOR_TEST_FLAG="-t"
- ;;
- 'zip'|'ZIP')
- DECOMPRESSOR="unzip"
- DECOMPRESSOR_TEST_FLAG="-t"
- ;;
- *)
- mkbuild_error $ERROR_CONSTRUCTION "DECOMPRESSOR"
- ;;
- esac
-fi
-[ -z $DECOMPRESSOR_TEST_FLAG ] && DECOMPRESSOR_TEST_FLAG=`get_variable "DECOMPRESSOR TEST FLAG"`
-[ -z $DECOMPRESSOR_TEST_FLAG ] && mkbuild_error $ERROR_CONSTRUCTION "DECOMPRESSOR TEST FLAG"
+DECOMPRESSOR=`validate_parameter "$DECOMPRESSOR" "DECOMPRESSOR" ""` || decompress_find
+
+DECOMPRESSOR_TEST_FLAG=`validate_parameter "$DECOMPRESSOR_TEST_FLAG" "DECOMPRESSOR TEST FLAG" ""` || mkbuild_error $ERROR_CONSTRUCTION "DECOMPRESSOR TEST FLAG"
# Documentations list
-DOCFILES=${DOCFILES:="`get_variable "DOCUMENTATION FILES"`"}
-if [ -z "$DOCFILES" ]; then
- DOCFILES="NEWS TODO README AUTHORS INSTALL ChangeLog MAINTAINERS COPYING readme.*"
-fi
+DOCFILES=`validate_parameter "$DOCFILES" "DOCUMENTATION FILES" "NEWS TODO README AUTHORS INSTALL ChangeLog MAINTAINERS COPYING readme.*"`
# ./configure option
-OPTIONS=${OPTIONS:="`get_variable "OTHER CONFIGURE ARGS"`"}
+OPTIONS=`validate_parameter "$OPTIONS" "OTHER CONFIGURE ARGS" ""`
# PREFIX
-PREFIX=${PREFIX:="`get_variable "PREFIX"`"}
-[ -z $PREFIX ] && PREFIX="/usr"
+PREFIX=`validate_parameter "$PREFIX" "PREFIX" "/usr"`
# Number of jobs
-NUMJOBS=${NUMJOBS:="`get_variable "NUMBER OF JOBS"`"}
+NUMJOBS=`validate_parameter "$NUMJOBS" "NUMBER OF JOBS" ""`
# Make slack-required file.
-SLACK_REQUIRED=${SLACK_REQUIRED:="`get_variable "SLACK REQUIRED"`"}
+SLACK_REQUIRED=`validate_parameter "$SLACK_REQUIRED" "SLACK REQUIRED" ""`
# SlackBuild model
-MODEL=${MODEL:="`get_variable "SLACKBUILD MODEL"`"}
-[ -z $MODEL ] && MODEL="generic.mkSlackBuild"
+MODEL=`validate_parameter "$MODEL" "SLACKBUILD MODEL" "generic.mkSlackBuild"`
#
# Start build SlackBuild
@@ -643,7 +667,7 @@ if [ -e slack-required ]; then
DEPENDENCY_LIST="`cat slack-required | awk '{print $1}' | grep '^[a-z]' | tr '\012' ' '`"
edit_file "REQUIRES" "$DEPENDENCY_LIST" $SLACKBUILD
else
- edit_file "REQUIRES" "Nil" $SLACKBUILD
+ edit_file "REQUIRES" "Null" $SLACKBUILD
fi
# Others changes