From 6ebf28b2bd4aaf32545171565149c5b4e2565985 Mon Sep 17 00:00:00 2001 From: rudson Date: Sun, 10 Jun 2007 15:24:59 +0000 Subject: mkbuild-0.9.1, createpkg-1.0.5.3 e adição de eecho e color_select a common.sh 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@385 04377dda-e619-0410-9926-eae83683ac58 --- branches/0.6/conf/simplepkg.conf.new | 7 + branches/0.6/lib/common.sh | 45 + branches/0.6/mkbuild/generic.mkSlackBuild.new | 34 +- branches/0.6/mkbuild/sample-Pyrex.mkbuild | 153 +++ branches/0.6/src/createpkg | 45 +- branches/0.6/src/mkbuild | 1563 +++++++------------------ 6 files changed, 658 insertions(+), 1189 deletions(-) create mode 100644 branches/0.6/mkbuild/sample-Pyrex.mkbuild diff --git a/branches/0.6/conf/simplepkg.conf.new b/branches/0.6/conf/simplepkg.conf.new index f073224..67c8d56 100644 --- a/branches/0.6/conf/simplepkg.conf.new +++ b/branches/0.6/conf/simplepkg.conf.new @@ -132,6 +132,13 @@ SLACKBUILDS_DIR="/var/slackbuilds" # Set binaries default repository directory MAKEPKG_REPOS="/var/createpkg" +# Set sources default directory +SOURCE_DIR="/var/sources" + +# Set color style +# possible values are: color,gray, none +COLOR_MODE="none" + # Remove old packages from repository tree by createpkg # 0 enable # 1 desable diff --git a/branches/0.6/lib/common.sh b/branches/0.6/lib/common.sh index d7ec5d7..e4ff2ff 100644 --- a/branches/0.6/lib/common.sh +++ b/branches/0.6/lib/common.sh @@ -261,6 +261,7 @@ function eval_config { # createpkg and mkbuild section SLACKBUILDS_DIR="`eval_parameter SLACKBUILDS_DIR /var/slackbuilds`" MAKEPKG_REPOS="`eval_parameter MAKEPKG_REPOS /var/simplaret/binaries`" + SOURCE_DIR="`eval_parameter SOURCE_DIR /var/sources`" REMOVE_OLD_PACKAGE="`eval_boolean_parameter REMOVE_OLD_PACKAGE 1`" MOVE_BIN_PACKAGE="`eval_boolean_parameter MOVE_BIN_PACKAGE 1`" # ---------------------------------------------------------------- @@ -719,3 +720,47 @@ function slash { } +function color_select { + + # Select color mode: gray, color or none (*) + # commun - Communication + # messag - Commum messages + # error - Error messages + # normal - turn off color + case "$1" in + 'gray') + commun="\033[37;1m" + messag="\033[37;1m" + error="\033[30;1m" + alert="\033[37m" + normal="\033[m" + ;; + 'color') + commun="\033[34;1m" # green + messag="\033[32;1m" # blue + error="\033[31;1m" # red + alert="\033[33;1m" # yellow + normal="\033[m" # normal + ;; + *) + commun="" + messag="" + error="" + alert="" + normal="" + ;; + esac + +} + + +function eecho { + + # echoes a message + # usage: eecho + # message-type can be: commun, messag, error, normal + + echo -e "${1}${2}${normal}" + +} + diff --git a/branches/0.6/mkbuild/generic.mkSlackBuild.new b/branches/0.6/mkbuild/generic.mkSlackBuild.new index 7da9a09..4813471 100644 --- a/branches/0.6/mkbuild/generic.mkSlackBuild.new +++ b/branches/0.6/mkbuild/generic.mkSlackBuild.new @@ -27,7 +27,7 @@ # - all + off # Look for slackbuildrc if [ -f ~/.slackbuildrc ]; then source ~/.slackbuildrc @@ -51,8 +51,8 @@ PKG=${PKG:=$TMP/package-$PKG_NAME} REPOS=${REPOS:=$TMP} PREFIX=${PREFIX:=[[PREFIX]]} PKG_SRC="$TMP/$SRC_NAME-$SRC_VERSION" -CONF_OPTIONS=${CONF_OPTIONS:=[[OTHER CONFIGURE ARGS]]} -NUMJOBS=${NUMJOBS:="-j4"} +CONF_OPTIONS=${CONF_OPTIONS:="[[OTHER CONFIGURE ARGS]]"} +NUMJOBS=${NUMJOBS:="[[NUMBER OF JOBS]]"} all @@ -73,7 +73,7 @@ elif [ "$ARCH" = "x86_64" ]; then fi - on + off # Set error codes (used by createpkg) ERROR_WGET=31; ERROR_MAKE=32; ERROR_INSTALL=33 ERROR_MD5=34; ERROR_CONF=35; ERROR_HELP=36 @@ -92,9 +92,10 @@ mkdir -p "$PKG" || exit $ERROR_MKDIR mkdir -p "$REPOS" || exit $ERROR_MKDIR - on + off # Dowload source if necessary -SRC="$SRC_NAME-$SRC_VERSION.tar.[[SOURCE EXTENSION]]" +EXTENSION="[[EXTENSION]]" +SRC="[[CONSTRUCTION SOURCE NAME STRING]]" URL="[[DOWNLOAD FOLDER URL]]/$SRC" if [ ! -s "$SRC_DIR/$SRC" ] || ! [[DECOMPRESSOR]] [[DECOMPRESSOR TEST FLAG]] "$SRC_DIR/$SRC" 2> /dev/null; then @@ -102,7 +103,14 @@ if [ ! -s "$SRC_DIR/$SRC" ] || ! [[DECOMPRESSOR]] [[DECOMPRESSOR TEST FLAG]] "$S fi - off + off +MD5SUM_SRC="$(md5sum "$SRC_DIR/$SRC" | cut -d " " -f 1)" +MD5SUM_URL="[[MD5SUM CODE]]" + +[ "$MD5SUM_SRC" == "$MD5SUM_URL" ] || exit $ERROR_MD5 + + + off # Download source's MD5 checksum if necessary and check it if [ ! -s "$SRC_DIR/$SRC.[[MD5SUM EXTENSION]]" ]; then wget "$URL.[[MD5SUM EXTENSION]]" -O "$SRC_DIR/$SRC.[[MD5SUM EXTENSION]]" || exit $ERROR_WGET @@ -112,7 +120,7 @@ MD5SUM_SRC="$(md5sum "$SRC_DIR/$SRC" | cut -d " " -f 1)" MD5SUM_URL="$(grep "$SRC[ \t]*$" "$SRC_DIR/$SRC.[[MD5SUM EXTENSION]]" | cut -d " " -f 1)" [ "$MD5SUM_SRC" == "$MD5SUM_URL" ] || exit $ERROR_MD5 - + off # Import minimized signing key from @@ -150,7 +158,7 @@ for patch in $patches; do done - on + off # Configure CFLAGS="$SLKCFLAGS" \ CXXFLAGS="$SLKCFLAGS" \ @@ -168,7 +176,7 @@ make $NUMJOBS || exit $ERROR_MAKE make install DESTDIR="$PKG" || exit $ERROR_INSTALL - on + off # Strip binaries ( cd "$PKG" find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | \ @@ -205,14 +213,14 @@ if [ -d "$PKG/$PREFIX/info" ]; then fi - on + off # Install documentation DOCS="[[DOCUMENTATION FILES]]" mkdir -p "$PKG/usr/doc/$PKG_NAME-$PKG_VERSION" || exit $ERROR_MKDIR cp -a $DOCS "$PKG/usr/doc/$PKG_NAME-$PKG_VERSION" - on + off # Add package description (slack-desc) mkdir -p "$PKG/install" || exit $ERROR_MKDIR cat << EODESC > "$PKG/install/slack-desc" @@ -255,7 +263,7 @@ cd "$PKG" makepkg -l y -c n "$REPOS/$PKG_NAME-$PKG_VERSION-$ARCH-$BUILD.tgz" || exit $ERROR_MKPKG - on + off # Delete source and build directories if requested if [ "$CLEANUP" == "yes" ]; then rm -rf "$PKG_SRC" "$PKG" diff --git a/branches/0.6/mkbuild/sample-Pyrex.mkbuild b/branches/0.6/mkbuild/sample-Pyrex.mkbuild new file mode 100644 index 0000000..e3a3a1d --- /dev/null +++ b/branches/0.6/mkbuild/sample-Pyrex.mkbuild @@ -0,0 +1,153 @@ +#-------------------- +# Personal variables +#-------------------- +# Author name +AUTHOR="Rudson R. Alves" + +# Initials author name +AUTHOR_INITIALS="rra" + +#------------------------ +# Construction Variables +#------------------------ +# +# 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' +SRC_NAME="Pyrex" + +# Package name. Null ("") to auto-set +# Auto-set, get PKG_NAME from URL downcase(SRC_NAME): http://.../$SRC_NAME-$VERSION.tar.$EXTENSION' +PKG_NAME="" + +# +# Source Name construction string +# Default value is: $SRC_NAME-$VERSION.tar.$EXTENSION +#CONST_STRING="SOURCE NAME CONSTRUCTION STRING" +CONST_STRING="$SRC_NAME-$VERSION.tar.$EXTENSION" + +# +# Complete URL address or URL base address ( without $SRC_NAME-$VERSION... ) +#URL="http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/Pyrex-0.9.5.1a.tar.gz" +URL="http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/" + +# +# Package version. Null ("") to auto-set. +# Auto-set, get VERSION from URL: http://.../$SRC_NAME-$VERSION.tar.$EXTENSION' +VERSION="0.9.5.1a" + +# +# Package extension. Null ("") to auto-set +# Auto-set, get EXTENSION from URL: http://.../$SRC_NAME-$VERSION.tar.$EXTENSION' +EXTENSION="gz" + +# +# Dependency list input +# Enter string: "dependency_1 [condiction_1] [versio_1]: dependency_2 [condiction_2] [versio_2]" +# Example: +SLACK_REQUIRED="dep1 >= 1.1.1: dep2 >= 2.2.2:dep3:dep4:dep5 = 1.0" +# SLACK_REQUIRED="" + +# +# Decompress program +# gz, tgz, bz2, set null ("") to auto-set +# Auto-set, get DECOMPRESSOR from URL EXTENSION: http://.../$SRC_NAME-$VERSION.tar.$EXTENSION' +DECOMPRESSOR="" + +# +# Decompress check flag +# gz, tgz, bz2, set null ("") to auto-set +DECOMPRESSOR_TEST_FLAG="" + +# +# Documentation files. Null ("") to auto-set commom doc-files: +# NEWS TODO README AUTHORS INSTALL ChangeLog MAINTAINERS COPYING readme.* +DOCFILES="" + +# +# ./configure options +OPTIONS="" + +# +# PREFIX. Default /usr +PREFIX="/usr" + +# +# Number of jobs +NUMJOBS="-j7" + +#--------------------- +# News changes +#--------------------- +#[[PATCH FILES]]="" +[[MD5SUM CODE]]="5a1bb7c76162a987a1d5040ea2d1f670" +#[[MD5SUM EXTENSION]]="" +#[[SIGNING KEY]]="" +#[[SIGNING KEY URL]]="" +#[[PATCH FILES]]="" + +#--------------------- +# SlackBuild Sections +#--------------------- +# SlackBuild model +MODEL="generic.mkSlackBuild" +# +# Default enable sections: +# head, set_variables, slkflags, start_structure, untar_source, +# make_package, install_package, build_package +# Warning: don't remove '#>>' and "#<<" tags. +#>> Start SlackBuild Sections: +#all: head + on: slackbuildrc +#all: set_variables + on: slkflags + on: error_codes +#all: start_structure + on: download_source + on: md5sum_download_and_check_0 +#off: md5sum_download_and_check_1 +#off: gpg_signature_check +#all: untar_source +#off: path_source + on: configure +#all: make_package +#all: install_package + on: strip_binaries +#off: compress_manpages +#off: compress_info_files + on: install_documentation + on: slackdesc +#off: postinstall_script +#all: build_package + on: clean_builds +#<< End SlackBuild Sections + +#------------------ +# Sections changes +#------------------ +#>slackdesc +pyrex: Pyrex by Slack.Sarava +pyrex: +pyrex: Pyrex is a language specially designed for writing Python extension +pyrex: modules. Its designed to bridge the gap between the nice, high-level, +pyrex: easy-to-use world of Python and the messy, low-level world of C. +pyrex: +pyrex: +pyrex: +pyrex: +pyrex: +pyrex: +#untar_source +# Untar program + +# Change to temp dir +cd "$TMP" + +# Uncompress e untar source +gunzip | tar --no-same-owner --no-same-permissions -xvf "$SRC_DIR/$SRC" || exit $ERROR_TAR + +# Change to source dir +cd "$PKG_SRC" +# - # message-type can be: commun, messag, error, normal - - echo -e "${1}${2}${normal}" - -} - function handle_error { # This function deals with internal createpkg errors @@ -299,39 +289,6 @@ function list_builds { } -function color_select { - - # Select color mode: gray, color or none (*) - # commun - Communication - # messag - Commum messages - # error - Error messages - # normal - turn off color - case "$1" in - 'gray') - commun="\033[37;1m" - messag="\033[37;1m" - error="\033[30;1m" - alert="\033[37m" - normal="\033[m" - ;; - 'color') - commun="\033[34;1m" # green - messag="\033[32;1m" # blue - error="\033[31;1m" # red - alert="\033[33;1m" # yellow - normal="\033[m" # normal - ;; - *) - commun="" - messag="" - error="" - alert="" - normal="" - ;; - esac - -} - #--------------------------------------------------- # Starting createpkg #--------------------------------------------------- @@ -371,7 +328,7 @@ else fi # Select color mode: gray, color or none (*) -color_select $COLOR +color_select $COLOR_MODE # This is used to show how many children process we have if [ -z "$CREATEPKG_CHILD" ]; then diff --git a/branches/0.6/src/mkbuild b/branches/0.6/src/mkbuild index bc0786d..631898a 100755 --- a/branches/0.6/src/mkbuild +++ b/branches/0.6/src/mkbuild @@ -1,4 +1,4 @@ -#!/bin/bash -x +#!/bin/bash # # Script para gerar SlackBuild # Por Rudson R. Alves @@ -9,1234 +9,533 @@ # SlackBuilds são scripts utilizados no Slackware para gerar # pacotes tgz. # -# Turn off debug -set +x -# -# Version 0.9.19 -PROG_VERSION=0.9.19 +# Version 0.9.1 +PROG_VERSION=0.9.1 #-------------------------------------------------------------------- # Functions #-------------------------------------------------------------------- -function config_help { - - # Show ./configure --help - view_file "Check ./configure --help" $CONFIG_HELP -} - -function view_file { - - # Show file - # INPUT: $1 string textbox - # $2 file - [ $# -ne 2 ] && return 1 - dialog --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title " $1 " --textbox $2 20 75 -} - -function mk_exit { - # Exit function - clean_all - clear +function mkbuild_use() + +{ + # mkbuild help function + echo " +NAME + mkbuild - create SlackBuild script from mkbuild_file input + +SYNOPSIS + mkbuild [OPIONS] [mkbuild_file] + +DESCRIPTION + input file with build rules and variables + + Input options: + -a, --author + author name + -ai, --author_initials + author signature + -cs, --const_string + construction string to source name + -u, --url + url address to source + -pn, --pkg_name + package name + -sn, --src_name + source name + -pv, --pkg_version + package version + -md, --model + SlackBuild model file + -j, --jobs + Number of jobs to run simultaneously + --prefix + Prefix install directory + + Program options: + -h, --help + this help mesage + -s, --show + show output files + -v, --version + program version + +EXAMPLES + mkbuild --prefix /usr/local pyrex.mkbuild + build pyrex.SlackBuild with prefix /usr/local and pyrex.mkbuild variables and options definitions. + +AUTHOR + Written by Rduson R. Alves + +REPORTING BUGS + Report bugs to + +COPYRIGHT + Copyright © 2006 Free Software Foundation, Inc. + This is free software. You may redistribute copies of it under the + terms of the GNU General Public License + . There is NO WARRANTY, to the + extent permitted by law. +" | 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 variable1." + ;; + "$ERROR_PROGRAM") + echo "Program logical error." + ;; + "$ERROR_INPUT_PAR") + echo "Input parameter $2 error. See \"mkbuild --help\"." + ;; + *) + echo "Unknow error!" + ;; + esac exit $1 } -function clean_all { - - # Clear all temp files - [ -s $DEPENDENCY_LIST ] && cp $DEPENDENCY_LIST $BASEDIR/slack-required +function is_number { - rm $AUX_TMP 2>/dev/null - rm $SLACKDESC_TMP 2>/dev/null - rm $SLACKBUILD.test 2>/dev/null - rm $DEPENDENCY_LIST 2>/dev/null - if [ ! -z $MK_PKGNAME ]; then - rm $BASEDIR/*_$MK_PKGNAME.mkbuild 2>/dev/null - rm -rf /tmp/$MK_PKGNAME 2>/dev/null - rm $CONFIG_HELP 2>/dev/null + # Check if argument 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 print_lines { - - # Print from file $2, the lines betwen <$1> and lines - [ $# -ne 2 ] && mk_exit 1 - eval "sed -n '/<$1>/,/<\/$1>/ { /<$1>/ b; /<\/$1>/ b; p; }' $2" -} - -function print_lines_to { - - # Print from file $2, the lines betwen <$1> and $2 lines - [ $# -ne 3 ] && mk_exit 1 - eval "sed -n '/<$1>/,/$2/ { /<$1>/ b; /$2/ b; p; }' $3" -} - -function mk_slackdesc { - - # Make slack-desc file - print_lines_to "slackdesc" "|-----" $SB_MODEL - echo -n $MK_PKGNAME | tr [a-z+\-] " " - echo -n "|-----handy-ruler" - let N=18+${#MK_PKGNAME} - for i in `seq $N $SLACKDESC_LEN`; do - echo -n "-" - done - echo -en "|\n" +function set_parameters { - for i in `seq 1 11`; do - echo -en "$MK_PKGNAME: \n" + # Get and set mkbuild variables with parameters input + # Use: set_parameters $@ + # where $@ are the parameters input + # + ALL_PAR=( $@ ) # carrega todos os parâmetros + N_PAR=$# # carrega o número de parâmetros + + i=0 # inicia o contador + # Checa todos os parâmetros passados + while [ $i -lt $N_PAR ]; do + # get parameter[i] + PAR=${ALL_PAR[$i]} + case $PAR in + '-h'|'--help' ) + # Show help mesage + mkbuild_use && exit 0 + ;; + '-v'|'--version') + # Show program version + echo -e "\nmkbuild version $PROG_VERSION\n" && exit 0 + ;; + '-a'|'--author') + # Enter with author name + let i++ + AUTHOR=${ALL_PAR[$i]} + [ ${AUTHOR:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR AUTHOR + ;; + '-ai'|'--author_initials') + # Enter with author name + let i++ + AUTHOR_INITIALS=${ALL_PAR[$i]} + [ ${AUTHOR_INITIALS:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR AUTHOR_INITIALS + ;; + '-cs'|'--const_string') + # Enter with construction source name string + let i++ + CONST_STRING=${ALL_PAR[$i]} + [ ${CONST_STRING:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR CONST_STRING + ;; + '-md'|'--model') + # Enter with SlackBuild model + let i++ + MODEL=${ALL_PAR[$i]} + [ ${MODEL:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR MODEL + ;; + '-j'|'--jobs') + # Enter with SlackBuild model + let i++ + NUMJOBS=${ALL_PAR[$i]} + [ ${NUMJOBS:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR NUMJOBS + [ ! is_number $NUMJOBS ] && mkbuild_error $ERROR_INPUT_PAR NUMJOBS + NUMJOBS="-j$NUMJOBS" + ;; + '--prefix') + # Enter with SlackBuild model + let i++ + PREFIX=${ALL_PAR[$i]} + [ ${PREFIX:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR PREFIX + ;; + '-pn'|'--pkg_name') + # Enter with package name + let i++ + PKG_NAME=${ALL_PAR[$i]} + [ ${PKG_NAME:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR PKG_NAME + ;; + '-pv'|'pkg_version') + # Enter with package version + let i++ + VERSION=${ALL_PAR[$i]} + [ ${VERSION:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR VERSION + ;; + '-sn'|'--src_name') + # Enter with source name + let i++ + SRC_NAME=${ALL_PAR[$i]} + [ ${SRC_NAME:0:1} = '-' ] && mkbuild_error $ERROR_INPUT_PAR SRC_NAME + ;; + '-u'|'--url') + # Enter with url address + let i++ + URL=${ALL_PAR[$i]} + [ ${URL:0:1} = '-' ] && mkbuild_error $ERROR_INPUT_PAR URL + ;; + *) + # mkbuild input file + MK_INPUT_FILE="${PAR//.mkbuild}.mkbuild" + [ ! -e $MK_INPUT_FILE ] && mkbuild_error $ERROR_FILE_NOT_FOUND $MK_INPUT_FILE + ;; + esac + let i++ done - print_lines "slackdesc" $SB_MODEL | sed '1,/\]\]/ d' } -function get_status { - - # Get label status from SlackBuild model - [ $# -ne 2 ] && mk_exit 1 - eval "sed -n '/<$1>/ p' $2 | sed 's/.*> \([a-z]\+\)/\1/'" -} +function get_variable { -function mk_status { + # Get variable value from mkbuild file (MK_INPUT_FILE) + [ $# -ne 1 ] && mkbuild_error $ERROR_PROGRAM + [ -z $MK_INPUT_FILE ] && echo "Warning: no [mkbuild_file]." && return 0 - # Get status from edited SlackBuild - # input: $1 -> section name - # output: section status and section number - for i in `seq 0 $MAXSECTION`;do - if [ "${SECTION_NAME[i]}" = "$1" ]; then - echo "${SECTION_FLAG[i]} $i" - return 0 - fi - done - return 1 + grep "^${1}" $MK_INPUT_FILE | cut -f2 -d\" } function edit_file { - # Edit file $3, by change string [[$1]] to $2 + # Edit file $SLACKBUILD, by change string [[$1]] to $2 local STR_OLD local STR_NEW - [ $# -ne 3 ] && mk_exit 1 + [ $# -ne 3 ] && mkbuild_error $ERROR_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" mv $AUX_TMP $3 } -function unpkg_source { - - # Unpackage source - # FIXME: if MK_DECOMPRESSOR -ne bunzip2 or gunzip... - if [ $MK_DECOMPRESSOR = "bunzip2" -o $MK_DECOMPRESSOR = "gunzip" ]; then - dialog --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" \ - --cancel-label "Main Menu" --title "$MK_TITLE" --infobox "Uncompress source in /tmp/$MK_PKGNAME. Wait" 3 45 - [ $? -ne 0 ] && return 100 - mkdir /tmp/$MK_PKGNAME/ 2>/dev/null - tar xvf $MK_SOURCE -C /tmp/$MK_PKGNAME/ 1>/dev/null - [ $? -ne 0 ] && mk_exit 1 - MK_TMPSRC="/tmp/$MK_PKGNAME/`ls /tmp/$MK_PKGNAME/`" +function start_build { - DOC_FILES=`find $MK_TMPSRC -type f -maxdepth 1 -name "[A-Z]*" | sed 's/.*\/\(.*\)$/\1/'` + # Build initial sections + [ $# -ne 1 ] && mkbuild_error $ERROR_PROGRAM + + edit_file "SLACKBUILD AUTHOR" "$AUTHOR" $1 + edit_file "SLACKBUILD AUTHOR INITIALS" $AUTHOR_INITIALS $1 + edit_file "SOURCE NAME" "$SRC_NAME" $1 + edit_file "PROGRAM NAME" "$PKG_NAME" $1 + edit_file "PACKAGE NAME" "$PKG_NAME" $1 + edit_file "DECOMPRESSOR" "$DECOMPRESSOR" $1 + edit_file "DECOMPRESSOR TEST FLAG" "$DECOMPRESSOR_TEST_FLAG" $1 + edit_file "PROGRAM URL" "$URL" $1 + edit_file "ARCH" "$ARCH" $1 + edit_file "NUMBER OF JOBS" "$NUMJOBS" $1 + 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 + if [ -z $OPTIONS ]; then + edit_file "OTHER CONFIGURE ARGS" "\"\"" $1 else - dialog --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" \ - --title "$MK_TITLE" --msgbox "$MK_DECOMPRESSOR not configurated..." 5 45 - fi -} - -function download_url { - - # Download source - clear - mkdir -p $MK_SOURCE_DIR/$MK_PKGNAME 2>/dev/null - wget --continue --limit-rate=$MK_LIMITRATE $MK_URL -P $MK_SOURCE_DIR/$MK_PKGNAME/ - if [ $? -ne 0 ]; then - echo "URL error" - return 0 + edit_file "OTHER CONFIGURE ARGS" "$OPTIONS" $1 fi - MK_SOURCE=$MK_SOURCE_DIR/$MK_PKGNAME/$MK_SRCNAME + edit_file "DOCUMENTATION FILES" "$DOCFILES" $1 + edit_file "PREFIX" "$PREFIX" $1 } -function select_source { +function clear_files { - # Select source file - MK_SOURCE=$BASEDIR - while [ ! -f $MK_SOURCE ]; do - MK_SOURCE=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" \ - --cancel-label "Main Menu" --title " Select source file name (use spaces to select): " --fselect "$MK_SOURCE" 10 70` - [ $? -ne 0 ] && return 100 - if [ ! -f $MK_SOURCE ]; then - MK_SOURCE="$MK_SOURCE/" - fi - done - - MK_SRCNAME=`basename $MK_SOURCE` - MK_SOURCE_DIR=`dirname $MK_SOURCE` + # Remove temporary files + rm $AUX_TMP 2>/dev/null + rm $SLACKBUILD_TEMP 2>/dev/null } -#-------------------------------------------------------------------- -# Edit functions -#-------------------------------------------------------------------- - -function edit_author { - - # Edit authot, Initials and editor - MK_AUTHOR=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --inputbox "Enter with author name:" 8 60 "$MK_AUTHOR"` - edit_file "AUTHOR NAME" "$MK_AUTHOR" $MK_SLACKBUILD_RC - - MK_AUTHOR_INITIALS=`echo $MK_AUTHOR | sed 's/ /\n/g' | sed 's/^\([A-Z]\).*/\1/' | sed ':i; $!N; s/\n//; ti' | tr [A-Z] [a-z]` - MK_AUTHOR_INITIALS=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --inputbox "Enter with author assignature:" 8 60 "$MK_AUTHOR_INITIALS"` - edit_file "AUTHOR INITIALS" "$MK_AUTHOR_INITIALS" $MK_SLACKBUILD_RC +function set_status { - MK_EDITOR=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --inputbox "Enter with editor command:" 8 60 "pico"` - edit_file "EDITOR" "$MK_EDITOR" $MK_SLACKBUILD_RC - - MK_SOURCE_DIR=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --inputbox "Enter with sources directory:" 8 60 "\`pwd\`"` - edit_file "SOURCE DIR" "$MK_SOURCE_DIR" $MK_SLACKBUILD_RC - - if [ "$USER" != "root" ]; then - SLACKBUILDRC=`[ -e ~/.slackbuildrc ] && echo ~/.slackbuildrc || echo /etc/slackbuildrc` - MK_REPOS=`grep 'REPOS=' $SLACKBUILDRC | sed 's/REPOS=\(.*\)/\1/'` + # Set status section + # $1 - Section + # $2 - Status + # $3 - file + [ $# -ne 3 ] && mkbuild_error $ERROR_PROGRAM + if [ "`get_status $1 $3`" != "all" ]; then + eval "sed 's/^<$1>.*$/<$1> $2/' $3" > $AUX_TMP + mv $AUX_TMP $3 else - SLACKBUILDRC=`su -c "[ -e ~/.slackbuildrc ] && echo ~/.slackbuildrc || echo /etc/slackbuildrc" 2>/dev/null` - MK_REPOS=`su -c "grep 'REPOS=' $SLACKBUILDRC | sed 's/REPOS=\(.*\)/\1/'" 2>/dev/null` - fi - - MK_REPOS=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --inputbox "Enter with binary repository directory:" 8 60 "$MK_REPOS"` - edit_file "REPOS DIR" "$MK_REPOS" $MK_SLACKBUILD_RC - - MK_ARCH=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --inputbox "Enter default architecture to SlackBuild:" 8 60 "i468"` - edit_file "DEFAULT ARCH" "$MK_ARCH" $MK_SLACKBUILD_RC - - MK_LIMITRATE=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --inputbox "Enter wget limit rate:" 8 60 "120k"` - edit_file "LIMIT RATE" "$MK_LIMITRATE" $MK_SLACKBUILD_RC -} - -function edit_url { - - # Edit source URL - MK_URL=${MK_URL:="http://downloads.sourceforge.net/"} - MK_URL=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --cancel-label "Main Menu" --title "$MK_TITLE" --inputbox "Enter with complite URL from source:" 8 60 "$MK_URL"` - [ $? -ne 0 ] && return 100 -} - -function edit_source_name { - - # Edit source name - # Carrega nome do arquivo - MK_SRCNAME=`basename $MK_URL` - MK_SRCNAME=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --cancel-label "Main Menu" --title "$MK_TITLE" --inputbox "Enter with source file name:" 8 60 "$MK_SRCNAME"` - [ $? -ne 0 ] && return 100 -} - -function edit_pkgname { - - # Edit MK_PKGNAME, MK_VERSION and MK_EXTENSION - # Remove nome, versão e extensão do nome da fonte - MK_SRC_NAME=`echo $MK_SRCNAME | sed -r 's/(.*)-(.*)\.(.*\..*)$/\1/'` - MK_PKGNAME=`echo $MK_SRC_NAME | tr [A-Z_] [a-z\-]` - MK_VERSION=`echo $MK_SRCNAME | sed -r 's/(.*)-(.*)\.(.*\..*)$/\2/'` - MK_EXTENSION=`echo $MK_SRCNAME | sed -r 's/(.*)-(.*)\.(.*\..*)$/\3/'` - - # Configura nome, versão e extensão do pacote - ANS=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" \ - --cancel-label "Main Menu" --title "$MK_TITLE" \ - --form "Check information below:" 14 52 7 \ - "Source name:" 1 1 "$MK_SRC_NAME" 1 15 30 60 \ - "Package name:" 3 1 "$MK_PKGNAME" 3 15 30 60 \ - "Version:" 5 1 "$MK_VERSION" 5 15 30 60 \ - "Extension:" 7 1 "$MK_EXTENSION" 7 15 30 60` - [ $? -ne 0 ] && return 100 - - MK_SRC_NAME=`echo $ANS | awk '{print $1}'` - MK_PKGNAME=`echo $ANS | awk '{print $2}'` - MK_VERSION=`echo $ANS | awk '{print $3}'` - MK_EXTENSION=`echo $ANS | awk '{print $4}'` -} - -function edit_decompress_arg { - - # Edit MK_DECOMPRESSOR and MK_DECOMPRESSOR_TEST_FLAG - # Remove nome, versão e extensão do nome da fonte - MK_DECOMPRESSOR="" - MK_DECOMPRESSOR_TEST_FLAG="" - - # Configura nome, versão e extensão do pacote - ANS3=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" \ - --cancel-label "Main Menu" --title "$MK_TITLE" \ - --form "Check information below:" 10 55 3 \ - "Uncompress program:" 1 1 "$MK_DECOMPRESSOR" 1 23 25 60 \ - "Uncompress test flag:" 3 1 "$MK_DECOMPRESSOR_TEST_FLAG" 3 23 25 100` - [ $? -ne 0 ] && return 100 - - MK_DECOMPRESSOR=`echo $ANS3 | awk '{print $1}'` - MK_DECOMPRESSOR_TEST_FLAG=`echo $ANS3 | awk '{print $2}'` -} - -function edit_configure { - - # Edit configure options - CONFIG_HELP=`mktemp -p /tmp/ config_$MK_PKGNAME.XXXXXX` - - $MK_TMPSRC/configure --help > $CONFIG_HELP - config_help - #[ "$( cat $CONFIG_HELP | egrep '/usr/local')" != "" ] && MK_PREFIX=/usr || MK_PREFIX=/opt/kde - MK_PREFIX="/usr" - MK_OPTIONS="" - local ANS0=1 - - while [ $ANS0 -eq 1 ]; do - local ANS1="7" - while [ $ANS1 -ne 0 ]; do - ANS1=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" \ - --cancel-label "Continue" --title "$MK_TITLE" \ - --menu "Select one option" 0 0 0 \ - 1 "View ./configure --help" \ - 2 "View documentations" \ - 3 "PREFIX=$MK_PREFIX" \ - 4 "OPTIONS=$MK_OPTIONS" \ - 0 "Continue"` - - case $ANS1 in - '1') - config_help - ;; - '2') - view_docs - ;; - '3') - MK_PREFIX=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --inputbox "Enter with prefix for install $MK_PKGNAME" 8 60 "$MK_PREFIX"` - ;; - '4') - MK_OPTIONS=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --inputbox "Enter with configure options for compile $MK_PKGNAME" 8 60 "$MK_OPTIONS"` - ;; - *) - ANS1=0 - ;; - esac - done - - # Configure - dialog --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title " Execute ./configure below? " --yesno "./configure --prefix=$MK_PREFIX $MK_OPTIONS" 6 70 - if [ $? -eq 0 ]; then - ( - cd $MK_TMPSRC - ./configure --prefix=$MK_PREFIX $MK_OPTIONS - ) - - echo -en "\nPress ENTER to continue" - read ANS0 - fi - - dialog --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title " Configure line is ok? " --yesno "./configure --prefix=$MK_PREFIX $MK_OPTIONS" 6 70 - - ANS0=$? - done -} - -function view_docs { - - # Show Documentations files - local MENU="" - local SELECT="" - local ANS2=0 - - for i in $DOC_FILES; do - MENU="$MENU \"$i\" \"\" " - done - - while [ $ANS2 -eq 0 ]; do - SELECT=`eval "dialog --stdout --backtitle \"Make SlackBuild $PROG_VERSION [$MK_PKGNAME]\" --cancel-label \"Continue\" --title \"$MK_TITLE\" --menu \"Select doc-file below:\" 20 45 13 $MENU"` - ANS2=$? - [ $ANS2 -eq 0 ] && view_file "File: $SELECT" $MK_TMPSRC/$SELECT - done -} - -function edit_docfiles { - - # Edit documentations files - [ -z $MK_TMPSRC ] && return 0 - - if [ -e $MK_TMPSRC ]; then - LIST=`( cd $MK_TMPSRC; find . -type f -maxdepth 1 | cut -c3- )` - DOCMENU="" - for i in $LIST; do - if [ "`echo NEWS TODO README AUTHORS INSTALL ChangeLog MAINTAINERS COPYING | grep $i`" != "" ]; then - DOCMENU="$DOCMENU $i \"\" on" - else - DOCMENU="$DOCMENU $i \"\" off" - fi - done - SELECTDOCS=`eval "dialog --stdout --separate-output --backtitle \"Make SlackBuild $PROG_VERSION [$MK_PKGNAME]\" --title \"$MK_TITLE\" --cancel-label \"Continue\" --checklist \"Select documentation files below:\" 20 45 13 $DOCMENU"` + echo "Warning: Section $1 have status all. Can't change!" fi - - MK_DOCFILES="`echo $SELECTDOCS | sed ':i; N; s/\n/ /; bi'`" } -function edit_arch { +function get_status { - # Edit compiler architecture - MK_ARCH=`dialog --stdout --backtitle "Make SlackBuild documentation files below:" --cancel-label "Main Menu" --title "$MK_TITLE" --inputbox "Set an architecture to compiler:" 8 45 $MK_ARCH` - [ $? -ne 0 ] && return 100 + # Get status from section + # $1 - Section + # $2 - file + [ $# -ne 2 ] && mkbuild_error $ERROR_PROGRAM + eval "sed '/^<$1>.*$/! d' $2" } -#-------------------------------------------------------------------- -# Mount files -#-------------------------------------------------------------------- +function activate_sections { -function change_strings { - - # Change string $1 to $2 in all files in the current directory - [ $# -ne 2 ] && mk_exit 1 - #[ -z "$2" ] && return 0 - eval "grep -l \"\[\[$1\]\]\" *" | while read FILE; do - edit_file "$1" "$2" $FILE + # Enable and desable sections + ACTIONS_LIST=`sed '/^#>>/,/< off/, /^<\/[a-z].*>$/ d' $SLACKBUILD_TEMP > $AUX_TMP + # Remove sections names + sed '/^<.*$/ d' $AUX_TMP > $SLACKBUILD_TEMP + # Remove clear lines + sed ':i ; $! N; s/\n// ; t i' $SLACKBUILD_TEMP | sed 's///g' | sed 's///g' | sed 's//\n/g' > $AUX_TMP + sed '1,/^#\!/ {/^#\!/ b; d }' $AUX_TMP > $SLACKBUILD } -function mount_slackbuild { +function section_edit { - # Mount final SlackBuild - dialog --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --infobox "SlackBuild save in $SLACKBUILD" 5 45 + # Edit sections by change you values + [ -z $MK_INPUT_FILE ] && return 0 - rm $SLACKBUILD 2>/dev/null + SECTION_LIST=`grep '^#>[a-z]' $MK_INPUT_FILE | cut -c3-` - for i in `seq 0 $MAXSECTION`; do - if [ "${SECTION_FLAG[i]}" = "all" -o "${SECTION_FLAG[i]}" = "on" ]; then - cat ${SECTION_NAME[i]}_$MK_PKGNAME.mkbuild >> $SLACKBUILD - echo "" >> $SLACKBUILD - fi - done - chmod +x $SLACKBUILD -} + # Check for sections change + [ -z "$SECTION_LIST" ] && return 0 -function mount_slackbuild_to { - - # Mount SlackBuild to section $1 - if [ $# -eq 1 ]; then - END_SECTION=$1 - dialog --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --infobox "SlackBuild save in $SLACKBUILD.test" 5 45 - - rm $SLACKBUILD.test 2>/dev/null - let i=0 - while [ $i -le $END_SECTION ]; do - if [ "${SECTION_FLAG[i]}" = "all" -o "${SECTION_FLAG[i]}" = "on" ]; then - cat ${SECTION_NAME[i]}_$MK_PKGNAME.mkbuild >> $SLACKBUILD.test - echo "" >> $SLACKBUILD - fi - let i++ - done - echo "" >> $SLACKBUILD - fi -} - -function make_file_sections { - - # Make files section - THIS_MODEL=$1 - - # Create SlackBuilds-sections files - rm *_$MK_PKGNAME.mkbuild 2>/dev/null - - # Make files section - INDEX=0 - while read ITEM; do - SECTION_NAME[INDEX]="$ITEM" - - AUX=${SB_SECTION[$INDEX,0]}_${MK_PKGNAME} - SECTION_FILE=${SECTION_NAME[INDEX]}_${MK_PKGNAME}.mkbuild - rm $SECTION_FILE 2>/dev/null - - STRING=$ITEM - # Save section status flag - SECTION_FLAG[INDEX]=`get_status "$STRING" $THIS_MODEL` - - # Create sections files - print_lines "$STRING" $THIS_MODEL > $SECTION_FILE - let INDEX++ - done < <( cat $THIS_MODEL | grep '^<[a-z_0-9]\+>' | sed 's/<\(.*\)>.*$/\1/' ) - - let INDEX-- - MAXSECTION=$INDEX - md5sum *.mkbuild > md5sum -} - -function get_source_dialog { - - # - if [ ! -e $MK_SOURCE ]; then - dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" \ - --title "$MK_TITLE" --yesno " Download $MK_SRCNAME? " 5 50 - if [ $? -eq 0 ]; then - download_url + # Change sections + for i in $SECTION_LIST; do + if [ "$i" = "slackdesc" ]; then + # Special slackdesc section + slackdesc_edit > $AUX_TMP + mv $AUX_TMP $SLACKBUILD_TEMP else - select_source - [ $? -eq 100 ] && return 100 - fi - fi -} - - -function test_source { - - # - local TEST=1 - local ANS=0 - - while [ $TEST -ne 0 ]; do - dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --infobox "Test source with $MK_DECOMPRESSOR $MK_DECOMPRESSOR_TEST_FLAG $MK_SOURCE" 5 50 - $MK_DECOMPRESSOR $MK_DECOMPRESSOR_TEST_FLAG $MK_SOURCE - TEST=$? - if [ $TEST -ne 0 ]; then - dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --yesno "Source uncompress error. Download source again?" 6 50 - if [ $? -eq 0 ]; then - rm $MK_SOURCE - get_source_dialog - [ $? -eq 100 ] return 100 - else - TEST=0 - fi + # Others sections + section_change $i fi done } -function set_source_test { - - # Configure test source variables - MK_SOURCE=$MK_SOURCE_DIR/$MK_PKGNAME/$MK_SRCNAME - if [ "$MK_EXTENSION" = "tar.gz" -o "$MK_EXTENSION" = "gz" -o "$MK_EXTENSION" = "tgz" ]; then - MK_DECOMPRESSOR=gunzip - MK_DECOMPRESSOR_TEST_FLAG="-t" - elif [ "$MK_EXTENSION" = "tar.bz2" -o "$MK_EXTENSION" = "bz2" ]; then - MK_DECOMPRESSOR=bunzip2 - MK_DECOMPRESSOR_TEST_FLAG="-t" - else - edit_decompress_arg - [ $? -eq 100 ] && return 100 - fi -} - -function edit_signature { - - # Enable MD5 or GPG signature check - # GPG and MD5 test - local ANS=0 - - ANS=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" \ - --title "$MK_TITLE" --menu "Select code validate type:" 0 0 0 \ - "1" "gpg signature" \ - "2" "md5sum" \ - "0" "none"` - - case $ANS in - 1) - edit_gpg - ;; - 2) - edit_md5sum - ;; - esac -} - -function edit_gpg { +function slackdesc_edit { - # Enable GPG signature check - dialog --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" \ - --title "$MK_TITLE" --msgbox "Enter with gpg minimized signing key." 5 50 - $EDITOR $MK_GPGFILEKEY -} - -function edit_md5sum { - - # Enable MD5SUM signature check - echo "none" -} - -#-------------------------------------------------------------------- -# Main functions -#-------------------------------------------------------------------- - -function create_slackbuild { - - # Create new SlackBuild - # Config package URL - edit_url - [ $? -eq 100 ] && return 100 - - # Source Name - edit_source_name - [ $? -eq 100 ] && return 100 - - # Package name, version and extension - edit_pkgname - [ $? -eq 100 ] && return 100 - - # Compile arch - edit_arch - [ $? -eq 100 ] && return 100 - - # Set source test variables - set_source_test - [ $? -eq 100 ] && return 100 - - # Get source file - MK_SOURCE=$MK_SOURCE_DIR/$MK_PKGNAME/$MK_SRCNAME - get_source_dialog - [ $? -eq 100 ] && return 100 - - # Test source - test_source - [ $? -eq 100 ] && return 100 - - # Uncompress source - unpkg_source - [ $? -eq 100 ] && return 100 - - # GPG and MD5 test -# edit_signature - - # Configure compiler options if exist - if [ -e $MK_TMPSRC/configure ]; then - edit_configure - fi - - # Edit documentation list - edit_docfiles - - # Create files sections - make_file_sections $SB_MODEL - - # SlackBuild script name - SLACKBUILD=$BASEDIR/$MK_PKGNAME.SlackBuild - - # mkSlackBuild script name - # FIXME: make an MODELDIR??? - MKSLACKBUILD=$BASEDIR/$MK_PKGNAME.mkslackbuild - - mk_slackdesc > slackdesc_$MK_PKGNAME.mkbuild - - # Edit builds sections - start_build - - # Main-Menu - edit_menu -} - -function open_mkslackbuild_dialog { - - # Open mkslackbuild dialog input - MKSLACKBUILD=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" \ - --title " Select source file name: " \ - --fselect "$BASEDIR/" 10 70` - [ $? -ne 0 ] && return 100 - - open_mkslackbuild - [ $? -eq 100 ] || return 100 -} - -function open_mkslackbuild { - - # Open mkslackbuild - if [ -f $MKSLACKBUILD ]; then - # Start defaults variables - source $MKSLACKBUILD - - # SlackBuild scrit name - SLACKBUILD=$BASEDIR/$MK_PKGNAME.SlackBuild - - # Create files sections - make_file_sections $MKSLACKBUILD - - [ -e $BASEDIR/slack-required ] && ( cp $BASEDIR/slack-required $DEPENDENCY_LIST ) - - else - dialog --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" \ - --title "$MK_TITLE" --msgbox "$MKSLACKBUILD most be a mkslackbuild file" 6 45 - return 100 - fi - - # CHECK: - # Set source test vadiables - set_source_test - [ $? -eq 100 ] && return 100 - - # Get source file - get_source_dialog - [ $? -eq 100 ] && return 100 - - # Test source - test_source - - # Uncompress source - unpkg_source -} - -function save_mkslackbuild { - - # Save mkSlackBuild - dialog --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --infobox "mkSlackBuild save in $MKSLACKBUILD" 5 30 - - rm $MKSLACKBUILD 2>/dev/null - echo '#!/bin/bash' > $MKSLACKBUILD - echo -e "# mkSlackBuild version $MK_VERSION\n" >> $MKSLACKBUILD - echo "MK_SRC_NAME=\"$MK_SRC_NAME\"" >> $MKSLACKBUILD - echo "MK_SRCNAME=\"$MK_SRCNAME\"" >> $MKSLACKBUILD - echo "MK_PKGNAME=\"$MK_PKGNAME\"" >> $MKSLACKBUILD - echo "MK_URL=\"$MK_URL\"" >> $MKSLACKBUILD - echo "MK_AUTHOR=\"$MK_AUTHOR\"" >> $MKSLACKBUILD - echo "MK_AUTHOR_INITIALS=\"$MK_AUTHOR_INITIALS\"" >> $MKSLACKBUILD - echo "MK_VERSION=\"$MK_VERSION\"" >> $MKSLACKBUILD - echo "MK_EXTENSION=\"$MK_EXTENSION\"" >> $MKSLACKBUILD - echo "MK_DECOMPRESSOR=\"$MK_DECOMPRESSOR\"" >> $MKSLACKBUILD - echo "MK_DECOMPRESSOR_TEST_FLAG=\"$MK_DECOMPRESSOR_TEST_FLAG\"" >> $MKSLACKBUILD - echo "MK_DOCFILES=\"$MK_DOCFILES\"" >> $MKSLACKBUILD - echo "MK_OPTIONS=\"$MK_OPTIONS\"" >> $MKSLACKBUILD - echo "MK_PREFIX=\"$MK_PREFIX\"" >> $MKSLACKBUILD - echo "MK_MD5SUM_EXT=\"$MK_MD5SUM_EXT\"" >> $MKSLACKBUILD - echo -e "return 0\n\n" >> $MKSLACKBUILD - - for i in `seq 0 $MAXSECTION`; do - echo "<${SECTION_NAME[i]}> ${SECTION_FLAG[i]}" >> $MKSLACKBUILD - cat ${SECTION_NAME[i]}_$MK_PKGNAME.mkbuild >> $MKSLACKBUILD - echo "" >> $MKSLACKBUILD - echo "" >> $MKSLACKBUILD + # Edit slackdesc section + sed -n '1,/|-----/ { // b; /|-----/ b; p; }' $SLACKBUILD_TEMP + echo -n $PKG_NAME | tr [a-z+\-] " " + echo -n "|-----handy-ruler" + let N=18+${#PKG_NAME} + for i in `seq $N $SLACKDESC_LEN`; do + echo -n "-" done + echo -en "|\n" - [ -s $DEPENDENCY_LIST ] && cp $DEPENDENCY_LIST $BASEDIR/slack-required + sed -n '/#>slackdesc/,/#/! d' $SLACKBUILD_TEMP > $AUX_TMP" + # Paste new section + eval "sed -n '/#>$1/,/#<$1/ { /^#>/ b; /^#> $AUX_TMP" + # Copy second halt + eval "sed '/^<\/$1>/,$ ! d' $SLACKBUILD_TEMP >> $AUX_TMP" - if ( grep '\[\[MD5SUM EXTENSION\]\]' $FILE &>/dev/null ); then - SELECT=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --radiolist "Select one option" 0 0 0 "1" "$MK_SRC_NAME-$MK_VERSION.[[MD5SUM EXT]]" on "2" "$MK_SRCNAME.[[MD5SUM EXT]]" off "3" "MK5SUM CODE" off` - - case $SELECT in - 1) - MK_MD5SUM_EXT="md5sum" - MK_MD5SUM_EXT=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --inputbox "Enter with md5sum extension:" 8 50 $MK_MD5SUM_EXT` - edit_file "MD5SUM EXTENSION" "$MK_MD5SUM_EXT" $FILE - ;; - 2) - MK_MD5SUM_EXT="md5" - MK_MD5SUM_EXT=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --inputbox "Enter with md5sum extension:" 8 50 $MK_MD5SUM_EXT` - eval "sed 's/^MD5SUM_FILE.*$/MD5SUM_FILE=\$SRC.$MK_MD5SUM_EXT/' $FILE > $AUX_TMP" - cp $AUX_TMP $FILE - ;; - 3) - MK_MD5SUM_CODE=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --inputbox "Enter with md5sum extension:" 8 50 $MK_MD5SUM_CODE` - sed '1! d' $FILE > $AUX_TMP - sed -n '2, /^fi/ p' $FILE | while read LINE; do echo "#$LINE" >> $AUX_TMP; done - sed -n '/^fi/, $ { /^fi/ b; p; }' $FILE >> $AUX_TMP - eval "sed 's/^MD5SUM_SRC.*/MD5SUM_SRC=\"$MK_MD5SUM_CODE\"/' $AUX_TMP > $FILE" - ;; - esac - fi - - $MK_EDITOR $FILE + mv $AUX_TMP $SLACKBUILD_TEMP } -function test_menu { +function make_slack_required { - # Test Menu - local ANST=0 - local SECTION=0 - local EDITMENU="" + # Build slack-required file + rm slack-required 2>/dev/null + [ -z "$SLACK_REQUIRED" ] && return 0 - # Create main-menu string - for i in `seq 0 $MAXSECTION`; do - if [ "${SECTION_FLAG[i]}" = "all" -o "${SECTION_FLAG[i]}" = "on" ]; then - EDITMENU="$EDITMENU $i ${SECTION_NAME[i]}" - fi - done + echo -e "# Dependency list to broffice\n#\n# dependency [condition] [version]]" > slack-required - EDITMENU="all \"SlackBuild\" $EDITMENU" - - while [ "$ANST" != "1" ]; do - SECTION=`eval "dialog --stdout --backtitle \"Make SlackBuild $PROG_VERSION [$MK_PKGNAME]\" --cancel-label \"Exit\" --title \"$MK_TITLE\" --menu \"Select section to test end\" 20 40 13 $EDITMENU"` - ANST=$? - - if [ $ANST -ne 1 ]; then - [ "$SECTION" = "all" ] && SECTION=$MAXSECTION - mount_slackbuild_to $SECTION - - # FIXME: -> sintaxe check - clear - echo "---------------------------------------------------------" - echo " --= SINTAX CHECK =--" - sh -n $SLACKBUILD.test - if [ $? -eq 0 ]; then - echo " --= 0K =--" - DEBUG=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" \ - --cancel-label "no debug" --title "$MK_TITLE" \ - --menu "Select debug level" 10 35 3 \ - "-x" "Simple debug" \ - "-xv" "More information" \ - "none" "No debug"` - - [ $? -ne 0 -o "$DEBUG" = "none" ] && DEBUG="" - - clear - echo "---------------------------------------------------------" - echo " --= START BUILDING =--" - if [ "$USER" != "root" ]; then - su -c "( sh $DEBUG $SLACKBUILD.test )" - else - ( sh $DEBUG $SLACKBUILD.test ) - fi - echo "---------------------------------------------------------" - echo " --= END =--" - - echo -n "Enter 1 to end test: " - read ANST - else - echo "Script error..." - read ANST - fi - fi + echo $SLACK_REQUIRED | sed 's/:/\n/g' | while read i; do + REQ=`echo $i | awk '{ print $1 }'` + CON=`echo $i | awk '{ print $2 }'` + VER=`echo $i | awk '{ print $3 }'` + echo -e "$REQ\t\t$CON\t\t$VER" >> slack-required done } -function menu_dependency { - - # Dependency Menu - local ANSD=11 - while [ $ANSD -ne 0 ]; do - ANSD=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" \ - --cancel-label "Main Menu" --title "$MK_TITLE" --menu "Main Menu:" 0 0 0 \ - "1" "Edit dependency list" \ - "2" "Test dependency list"` - - [ $? -ne 0 ] && ANSD=0 +function change_others_fields { - case $ANSD in - 1) - edit_dependency - ;; - 2) - test_dependency - ;; - esac + # Change others fields started by '[[' in .mkbuild file + grep '\[\[[A-Za-z]' $MK_INPUT_FILE | while read i; do + CHANGE="`echo $i | sed 's/\[\[\(.*\)\]\]=\"\(.*\)\"/\1/'`" + VALUE="`echo $i | sed 's/\[\[\(.*\)\]\]=\"\(.*\)\"/\2/'`" + edit_file "$CHANGE" "$VALUE" $SLACKBUILD done } -function edit_dependency { - - # Dependency list edit - if [ ! -s $DEPENDENCY_LIST ]; then - echo -e "# Dependency list to $MK_PKGNAME\n# \n# dependency [condition] [version]]\n" > $DEPENDENCY_LIST - fi - - $MK_EDITOR $DEPENDENCY_LIST -} - -function test_dependency { - - # Check dependency and comment not found dependencies - local DEP_LIST="" - - if [ -s $DEPENDENCY_LIST ]; then - for i in `grep '^[^#]' $DEPENDENCY_LIST | awk '{print $1}' | sort | uniq`; do - if [ `ls /var/log/packages/$i-[0-9]* 2>/dev/null` ]; then - DEP_LIST="$DEP_LIST $i \"intalled\" off" - else - DEP_LIST="$DEP_LIST $i \"unintalled\" on" - fi - done - - DEP_SELECT=`eval "dialog --stdout --separate-output --backtitle \"Make SlackBuild $PROG_VERSION [$MK_PKGNAME]\" --title \"$MK_TITLE\" --checklist \"Select packages to remove from dependency list:\" 0 0 0 $DEP_LIST"` - # 20 45 13 - - for i in $DEP_SELECT; do - eval "sed 's/$i$/#$i/' $DEPENDENCY_LIST > $AUX_TMP " - eval "sed 's/$i /#$i /' $AUX_TMP > $DEPENDENCY_LIST" - eval "sed 's/$i\t/#$i\t/' $DEPENDENCY_LIST > $AUX_TMP" - cp $AUX_TMP $DEPENDENCY_LIST - done - fi -} - -function commit_SlackBuild { - - # Add/commit one SlackBuild - # Mount SlackBuild - mount_slackbuild - MK_TITLE="Commit SlackBuild" - - # Find SlackBuild - SB_PATH=`find $SLACKBUILD_DIR -iname $MK_PKGNAME` - - # Change to SlackBuild directory - cd $SLACKBUILD_DIR - - # Check for dirbase to new SlackBuild - if [ -z $SB_PATH ]; then - # New SlackBuild - AUX="" - while [ -z $AUX ]; do - dialog --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --infobox "lynx search for $MK_PKGNAME path. Wait..." 0 0 - AUX=`lynx -dump http://gentoo-portage.com/Search?search=$MK_PKGNAME | sed -n '/Results:/,+1 { /Results:/ b ; p }' | head --lines=1 | tr -d " "` - - if [ -z $AUX ]; then - dialog --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --yesno "Net search error. Try again?" 0 0 - if [ $? -ne 0 ]; then - # Default directory - AUX="/others/unclass" - SB_PATH=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --inputbox "Enter dir-name to SlackBuild from $MK_PKGNAME:" 8 60 "$AUX"` - fi - else - SB_PATH="`dirname $AUX | tr - /`/`basename $AUX`" - fi - done - - # Make directory and add SlackBuild to svn - svn mkdir $SB_PATH - cp $BASEDIR/$MK_PKGNAME.SlackBuild $SB_PATH/ - svn add $SB_PATH/$MK_PKGNAME.SlackBuild - if [ -e $BASEDIR/slack-required ]; then - cp $BASEDIR/slack-required $SB_PATH/ - svn add $SB_PATH/slack-required - fi - else - cp $BASEDIR/$MK_PKGNAME.SlackBuild $SB_PATH/ - if [ -e $BASEDIR/slack-required ]; then - cp $BASEDIR/slack-required $SB_PATH/ - fi - fi - - # Commit SlackBuild - MK_MSG=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --inputbox "Enter message do commit command:" 8 60` - svn commit -m "$MK_PKGNAME: $MK_MSG" - - cd $BASEDIR - - echo -e "\nPress ENTER to continue." - read ANS1 -} - -function compile_install { - - # Compile SlackBuild and install - local ANS="" - # Mount SlackBuild - mount_slackbuild - - # Clean temporary file - echo " " > $AUX_TMP - - if [ "$USER" = "root" ]; then - # Root user - # Compile pid - PID=`exec-slackbuild $SLACKBUILD $AUX_TMP` - - # Tail messages - tail -s .1 --pid=$PID -f $AUX_TMP - - # Package name - PACKAGE=`tail -10 $AUX_TMP | grep "^Moving $MK_PKGNAME-[0-9].*\.\.\.$" | awk '{ print $2 }' | grep "$MK_PKGNAME-.*\.tgz$"` - - # Install package - if [ ! -z $PACKAGE ]; then - installpkg $MK_REPOS/$PACKAGE - else - echo -e "\nBuild error!" - fi - else - # Commum users - # Compile pid - PID=`su -c "exec-slackbuild $SLACKBUILD $AUX_TMP"` - - # Tail messages - tail -s .1 --pid=$PID -f $AUX_TMP - - # Package name - PACKAGE=`tail -10 $AUX_TMP | grep "^Moving $MK_PKGNAME-[0-9].*\.\.\.$" | awk '{ print $2 }' | grep "$MK_PKGNAME-.*\.tgz$"` - - # Install package - if [ ! -z $PACKAGE ]; then - su -c "installpkg $MK_REPOS/$PACKAGE" - else - echo -e "\nBuild error!" - fi - fi - - echo -e "\nPress ENTER to continue." - read ANS -} - -function create_slackbuildrc { +#============================= +# Main Program +#============================= +# Start variables +DOWNLOAD_SOURCE=0 # desable download source +# Auxiliar file +AUX_TMP=/tmp/mkbuild_tmp.$RANDOM +# Derectory to SlackBuild models +MODEL_DIR=${MODEL_DIR:="/etc/simplepkg/defaults/mkbuild"} +# SlackDesk line length +SLACKDESC_LEN=78 + +# Load error codes +error_codes + +[ $# -eq 0 ] && mkbuild_use && exit 1 + +# Configure input parameters +set_parameters $@ + +# Get values +AUTHOR=${AUTHOR:="`get_variable AUTHOR`"} +[ -z "$AUTHOR" ] && mkbuild_error $ERROR_CONSTRUCTION "AUTHOR" + +AUTHOR_INITIALS=${AUTHOR_INITIALS:="`get_variable AUTHOR_INITIALS`"} +[ -z $AUTHOR_INITIALS ] && mkbuild_error $ERROR_CONSTRUCTION "AUTHOR_INITIALS" + +URL=${URL:="`get_variable 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 + SOURCE_NAME=`basename $URL` + URL_BASE=`dirname $URL` +else + EXTENSION=`get_variable EXTENSION` + [ -z $EXTENSION ] && mkbuild_error $ERROR_CONSTRUCTION "EXTENSION" + URL_BASE=$URL +fi - # Create basic slackbuildrc - cat << EOF > $MK_SLACKBUILD_RC -#!/bin/bash -# mkslackbuild definitions -# -MK_AUTHOR="[[AUTHOR NAME]]" -MK_AUTHOR_INITIALS="[[AUTHOR INITIALS]]" -MK_EDITOR=[[EDITOR]] -MK_REPOS=[[REPOS DIR]] -MK_LIMITRATE=[[LIMIT RATE]] -MK_SOURCE_DIR=[[SOURCE DIR]] -MK_ARCH=[[DEFAULT ARCH]] -#SB_MODEL="my_model" -EOF +# Source name +SRC_NAME=${SRC_NAME:="`get_variable SRC_NAME`"} +[ -z $SRC_NAME ] && SRC_NAME=`echo $SOURCE_NAME | sed -r 's/(.*)-(.*)\.(.*\..*)$/\1/'` +[ -z $SRC_NAME ] && mkbuild_error $ERROR_CONSTRUCTION "SRC_NAME" + +# Package name +PKG_NAME=${PKG_NAME:="`get_variable PKG_NAME`"} +[ -z $PKG_NAME ] && PKG_NAME=`echo $SRC_NAME | tr [A-Z_] [a-z\-]` + +# Version +VERSION=${VERSION:="`get_variable VERSION`"} +[ -z $VERSION ] && VERSION=`echo $SRC_NAME | sed -r 's/(.*)-(.*)\.(.*\..*)$/\2/'` +[ -z $VERSION ] && mkbuild_error $ERROR_CONSTRUCTION "VERSION" + +# Construction source name string +CONST_STRING=${CONST_STRING:="`get_variable CONST_STRING`"} +[ -z "$CONST_STRING" ] && CONST_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" -} +# Documentations list +DOCFILES=${DOCFILES:="`get_variable DOCFILES`"} +if [ -z "$DOCFILES" ]; then + DOCFILES="NEWS TODO README AUTHORS INSTALL ChangeLog MAINTAINERS COPYING readme.*" +fi -function mkslackbuild_config_start { +# ./configure option +OPTIONS=${OPTIONS:="`get_variable OPTIONS`"} - # Check mkslackbuild.conf and start hi - # Create mkslackbuild.conf config script if need - if [ ! -e $MK_SLACKBUILD_RC ]; then - mkdir -p `dirname $MK_SLACKBUILD_RC` 2>/dev/null - create_slackbuildrc - fi +# PREFIX +PREFIX=${PREFIX:="`get_variable PREFIX`"} +[ -z $PREFIX ] && PREFIX="/usr" - # Start mkslackbuild.conf variables - source $MK_SLACKBUILD_RC - MK_SOURCE_DIR=${MK_SOURCE_DIR:=$BASEDIR} - MK_ARCH=${MK_ARCH:="i486"} +# Number of jobs +NUMJOBS=${NUMJOBS:="`get_variable NUMJOBS`"} - # Configure mkslackbuild.conf variables - if [ "$MK_AUTHOR" = "[[AUTHOR NAME]]" ]; then - MK_TITLE=" Personal Config " - edit_author - MK_TITLE="" - fi +# Make slack-required file. +SLACK_REQUIRED=${SLACK_REQUIRED:="`get_variable SLACK_REQUIRED`"} +[ -z "$SLACK_REQUIRED" ] && make_slack_required -} +# SlackBuild model +MODEL=${MODEL:="`get_variable MODEL`"} +[ -z $MODEL ] && MODEL="generic.mkSlackbuild" # -#-------------------------------------------------------------------- -# Start Program -#-------------------------------------------------------------------- -# -# Start variables -LANG=en_US -SLACKDESC_LEN=77 -BASEDIR=`pwd` - -# Start Files ------------------------------------------------------ -AUX_TMP=`mktemp -p /tmp/ aux_tmp.XXXXXX` -SLACKDESC_TMP=`mktemp -p /tmp/ slackdesc_tmp.XXXXXX` -DEPENDENCY_LIST=`mktemp -p /tmp/ slack-required.XXXXXX` -LOCAL_CONF_DIR=~/.local/etc/simplepkg -MK_SLACKBUILD_RC="$LOCAL_CONF_DIR/mkslackbuild.conf" -MK_MODEL_DIR="defaults/mkbuild" - -# Start common.sh functions ---------------------------------------- -COMMON="/usr/libexec/simplepkg/common.sh" -BASENAME="`basename $0`" - -if [ -f "$COMMON" ]; then - source $COMMON -else - echo "error: file $COMMON found, check your $BASENAME installation" - mk_exit 0 -fi +# Start build SlackBuild +SLACKBUILD=${PKG_NAME}.SlackBuild +SLACKBUILD_TEMP=$SLACKBUILD.tmp +cp $MODEL_DIR/$MODEL $SLACKBUILD_TEMP -# Load simplepkg.conf variables -eval_config $BASENAME +# Change Strings from model +start_build $SLACKBUILD_TEMP -# Enable debug mode ----------------------------------------------- -set -x +# On/Off sections +activate_sections -# If model isn't defined, get default model. -if [ -z $SB_MODEL ]; then - if [ -e $LOCAL_CONF_DIR/$MK_MODEL_DIR/generic.mkSlackBuild ]; then - SB_MODEL=$LOCAL_CONF_DIR/$MK_MODEL_DIR/generic.mkSlackBuild - elif [ -e $BASE_CONF/$MK_MODEL_DIR/generic.mkSlackBuild ]; then - SB_MODEL=$BASE_CONF/$MK_MODEL_DIR/generic.mkSlackBuild - else - echo "SlackBuild model (generic.mkSlackBuild) not found" - mk_exit 0 - fi -fi - -# Get mkSlackBuild input -[ $# -ne 0 ] && MKSLACKBUILD=${1//.*}.mkslackbuild - -# Clear dialog -dialog --clear +# Change sections +section_edit -# Check mkslackbuild.conf and start hi -mkslackbuild_config_start - -# Check file.mkslackbuild file to open -if [ ! -z $MKSLACKBUILD ]; then - MK_TITLE=" Open mkSlackBuild " - open_mkslackbuild -fi +# Remove off sections +build_slackbuild -MK_TITLE="" +# Make slack-required file +make_slack_required -ANS0=11 -while [ $ANS0 -ne 0 ]; do - if [ -z $MK_PKGNAME ]; then - ANS0=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" \ - --cancel-label "Exit" --menu "Main Menu:" 0 0 0 \ - "1" "Create New SlackBuild" \ - "2" "Open mkSlackBuild" \ - "0" "Exit"` - - if [ $? -ne 0 ]; then - ANS0=0 - fi - - case $ANS0 in - 1) - MK_TITLE=" Create SlackBuild " - create_slackbuild - [ $? -eq 100 ] && MK_PKGNAME="" - ;; - 2) - MK_TITLE=" Open mkSlackBuild " - open_mkslackbuild_dialog - [ $? -eq 100 ] && MK_PKGNAME="" - ;; - *) - echo "Exit..." - ANS0=0 - ;; - esac - MK_TITLE="" - else - ANS0=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" \ - --cancel-label "Exit" --menu "Main Menu:" 0 0 0 \ - "1" "Edit SlackBuild sections" \ - "2" "Edit dependency list" \ - "3" "Test SlackBuild script" \ - "4" "View Doc-Files" \ - "5" "Save SlackBuild and mkslackbuild" \ - "6" "Compile/install package" \ - "7" "Remove package" \ - "8" "Commit SlackBuild to Sarava tree"` - - if [ $? -ne 0 ]; then - ANS0=0 - fi - case $ANS0 in - 1) # Edit Sections - MK_TITLE=" Edit Menu " - edit_menu - ;; - 2) # Dependency Menu - MK_TITLE=" Dependency Menu " - menu_dependency - ;; - 3) # Test Script - MK_TITLE=" Test Menu " - test_menu - ;; - 4) # View Doc-Files - MK_TITLE=" View Docs " - view_docs - ;; - 5) # Save SlackBuild - save_mkslackbuild - mount_slackbuild - ;; - 6) # Compile/install package - compile_install - ;; - 7) # Remove package - if [ "$USER" = "root" ]; then - removepkg $MK_PKGNAME - else - su -c "( removepkg $MK_PKGNAME )" - fi - echo -e "\nPress ENTER to continue." - read ANS1 - ;; - 8) # Commit SlackBuild to Sarava - commit_SlackBuild - ;; - 0) # Exit - ANS0=0 - ;; - esac - MK_TITLE="" - fi -done - -# Check changes -if [ ! -z $MK_PKGNAME ]; then - md5sum -c md5sum - if [ $? -ne 0 ]; then - MKSLACKBUILD=$BASEDIR/$MK_PKGNAME.mkslackbuild - save_mkslackbuild - mount_slackbuild - fi +if [ -e slack-required ]; then + DEPENDENCY_LIST="`cat slack-required | awk '{print $1}' | grep '^[a-z]' | tr '\012' ' '`" + edit_file "REQUIRES" "$DEPENDENCY_LIST" $SLACKBUILD fi -mk_exit 0 +# Others changes +change_others_fields +# Clear temporary files +clear_files -- cgit v1.2.3