aboutsummaryrefslogtreecommitdiff
path: root/trunk/src
diff options
context:
space:
mode:
authorrudson <rudson@04377dda-e619-0410-9926-eae83683ac58>2008-01-11 16:30:15 +0000
committerrudson <rudson@04377dda-e619-0410-9926-eae83683ac58>2008-01-11 16:30:15 +0000
commit8663857fe8799ad580f4127b995e4635f525331d (patch)
treedb47a5db2170b030244fb9520919d689e7d2410e /trunk/src
parent9c2229a6d5fd623a09a3a8fa9a0f49d3981b8a0e (diff)
downloadsimplepkg-8663857fe8799ad580f4127b995e4635f525331d.tar.gz
simplepkg-8663857fe8799ad580f4127b995e4635f525331d.tar.bz2
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@483 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'trunk/src')
-rwxr-xr-xtrunk/src/mkbuild22
-rw-r--r--trunk/src/mkpatch131
2 files changed, 151 insertions, 2 deletions
diff --git a/trunk/src/mkbuild b/trunk/src/mkbuild
index cddfa5d..e11d2da 100755
--- a/trunk/src/mkbuild
+++ b/trunk/src/mkbuild
@@ -19,7 +19,7 @@
# Based in model generic.SlackBuild of Luiz
#
# Version:
-PROG_VERSION=1.1.11
+PROG_VERSION=1.1.12
PROG_NAME=`basename $0`
#--------------------------------------------------------------------
@@ -317,6 +317,7 @@ function clear_files {
# Remove temporary files
rm $AUX_TMP 2>/dev/null
rm $SLACKBUILD_TEMP 2>/dev/null
+ rm $DIFF_FILE 2>/dev/null
chmod 755 *.SlackBuild 2>/dev/null
}
@@ -483,6 +484,18 @@ function get_slackbuild_path {
echo $AUX_PATH | tr [A-Z] [a-z]
}
+function apply_mkpatch {
+
+ # Apply mkpatch if exist
+ sed -n '/#p>/,/#p</ { /^#/ b; p }' $MKBUILD_NAME > $DIFF_FILE
+ if [ -s $DIFF_FILE ]; then
+ mkpatch $DIFF_FILE $SLACKBUILD_TEMP > $AUX_TMP || handle_error $?
+ [ ! -s $AUX_TMP ] && handle_error 1
+ cp $AUX_TMP $SLACKBUILD_TEMP
+ [ $VERBOSE -eq $on ] && ( echo -e "\nApply mkpath ..."; cat $DIFF_FILE )
+ fi
+}
+
# ----------------------------------------------------------------
# ------------------- svn functions ------------------------------
function commit_slackbuild {
@@ -642,7 +655,7 @@ LANG=en_US
if [ -f "$COMMON_SH" ]; then
source $COMMON_SH
else
- handle_error $ERROR_COMMON_NOT_FOUND
+ echo $error "$BASENAME: file $COMMON_SH not found. Check your $BASENAME installation"
fi
# Start constants
@@ -662,6 +675,7 @@ color_select $COLOR_MODE
# Auxiliar file
AUX_TMP=/tmp/mkbuild_tmp.$RANDOM
+DIFF_FILE=/tmp/mkbuild.diff.$RANDOM
# Derectory to SlackBuild models
MODEL_DIR=${MODEL_DIR:="/etc/simplepkg/defaults/mkbuild"}
# SlackDesk line length
@@ -821,6 +835,10 @@ case $ACTION in
SLACKBUILD_TEMP=$SLACKBUILD.tmp
cp $MODEL_DIR/$MODEL $SLACKBUILD_TEMP
+ # Apply mkpatch
+ [ $VERBOSE -eq $on ] && echo -e "\nMkpatch section ..."
+ apply_mkpatch
+
# On/Off sections
[ $VERBOSE -eq $on ] && echo -e "\nEnable/desable sections ..."
activate_sections
diff --git a/trunk/src/mkpatch b/trunk/src/mkpatch
new file mode 100644
index 0000000..35f5839
--- /dev/null
+++ b/trunk/src/mkpatch
@@ -0,0 +1,131 @@
+#!/bin/bash
+#
+# mkpatch: Simple patch program to .mkbuild models
+# feedback: rudsonaalves at yahoo.com.br | gpl
+#
+# mkbuild is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or any later version.
+#
+# mkbuild is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+# Place - Suite 330, Boston, MA 02111-1307, USA
+#
+# Input:
+# - $1 Diff_File
+# - #2 Source_File
+#
+# Version:
+PROG_VERSION=1.0
+BASENAME=`basename $0`
+
+function get_line {
+
+ # get a line $1 from file $2
+ [ $# -ne 2 ] && exit $ERROR_PAR_NUMBER
+ ! is_number $1 && exit $ERROR_NOT_NUMBER
+ [ ! -e $2 ] && exit $ERROR_FILE_NOTFOUND
+
+ sed -n "$1 p" $2
+}
+
+function get_diff_line {
+
+ # get diff line e return:
+ # - Action in Diff_Action
+ # - Diff Line in Diff_Str_Line
+ if [ $1 -gt $Diff_N_Lines ]; then
+ Diff_Action=" "
+ Diff_Str_Line=""
+ return 0
+ fi
+ Line=`get_line $1 $2`
+ Diff_Action=`echo "$Line" | cut -c1`
+ Diff_Str_Line=`echo "$Line" | cut -c2-`
+}
+
+
+# ----------------------------------------------------------------
+# ------------------- mkpatch program ----------------------------
+# common.sh library start
+COMMON_SH="/usr/libexec/simplepkg/common.sh"
+if [ -f "$COMMON_SH" ]; then
+ source $COMMON_SH
+else
+ echo $error "$BASENAME: file $COMMON_SH not found. Check your $BASENAME installation"
+fi
+# Load error codes
+error_codes
+# ----------------
+
+# Check input parameters
+[ $# -ne 2 ] && exit $ERROR_PAR_NUMBER
+[ ! -e $1 ] && exit $ERROR_FILE_NOTFOUND
+[ ! -e $2 ] && exit $ERROR_FILE_NOTFOUND
+
+# Start variables
+Diff_File=$1
+Source_File=$2
+Diff_N_Lines=`wc -l $1 | cut -f1 -d" "`
+Source_N_Lines=`wc -l $2 | cut -f1 -d" "`
+
+# Start vars
+Diff_Line=1
+Diff_Pointer=1
+Status_Diff=0
+
+# Get frist Diff_File line
+get_diff_line $Diff_Line $Diff_File || exit $?
+
+Source_Line=1
+while [ $Source_Line -le $Source_N_Lines ]; do
+ # Get Source_File line
+ Source_Str_Line=`get_line $Source_Line $Source_File` || return $?
+ # make Actions
+ case $Diff_Action in
+ '-')
+ if [ "$Source_Str_Line" = "$Diff_Str_Line" ]; then
+ let Diff_Line++
+ else
+ Diff_Line=$Diff_Pointer
+ echo "$Source_Str_Line"
+ fi
+ get_diff_line $Diff_Line $Diff_File || return $?
+ ;;
+ '+')
+ echo "$Diff_Str_Line"
+ let Diff_Line++
+ get_diff_line $Diff_Line $Diff_File || return $?
+ let Source_Line--
+ ;;
+ ' ')
+ echo "$Source_Str_Line"
+ ;;
+ '=')
+ let Diff_Line++
+ Diff_Pointer=$Diff_Line
+ get_diff_line $Diff_Line $Diff_File || return $?
+ echo "$Source_Str_Line"
+ ;;
+ '*')
+ exit $ERROR_MKPATCH
+ ;;
+ esac
+ if [ "$Diff_Action" = " " -a "$Source_Str_Line" = "$Diff_Str_Line" ]; then
+ Status_Diff=1
+ let Diff_Line++
+ get_diff_line $Diff_Line $Diff_File || return $?
+ fi
+ let Source_Line++
+done
+
+# Make others addline "+" in the end file
+while [ "$Diff_Action" = "+" -a $Diff_Line -le $Diff_N_Lines ]; do
+ echo "$Diff_Str_Line"
+ let Diff_Line++
+ get_diff_line $Diff_Line $Diff_File || return $?
+done