]> gitweb.fluxo.info Git - simplepkg.git/commitdiff
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@483 04377dda-e619-0410...
authorrudson <rudson@04377dda-e619-0410-9926-eae83683ac58>
Fri, 11 Jan 2008 16:30:15 +0000 (16:30 +0000)
committerrudson <rudson@04377dda-e619-0410-9926-eae83683ac58>
Fri, 11 Jan 2008 16:30:15 +0000 (16:30 +0000)
trunk/lib/common.sh
trunk/simplepkg.SlackBuild
trunk/src/mkbuild
trunk/src/mkpatch [new file with mode: 0644]

index 1a6d4066f46fa2229256b124cf4894c3bcb15199..2e36341fffa9c104ea08ce03481ad03819460a58 100644 (file)
@@ -737,6 +737,8 @@ function error_codes {
   ERROR_MKBUILD_PROGRAM=502
   ERROR_MKBUILD_INPUT_PAR=503
 
+  # Mkpatch error codes
+  ERROR_MKPATCH=600
 }
 
 function handle_error {
@@ -794,8 +796,8 @@ function handle_error {
       eecho $error "$BASENAME: $2 need a number argument" ;;
     $ERROR_PAR_NUMBER)
       eecho $error "$BASENAME: incorrect number of parameters" ;;
-    $ERROR_COMMON_NOT_FOUND)
-      eecho $error "$BASENAME: file $COMMON_SH not found. Check your $BASENAME installation" ;;
+    #$ERROR_COMMON_NOT_FOUND)
+    #  eecho $error "$BASENAME: file $COMMON_SH not found. Check your $BASENAME installation" ;;
 
     #
     # Createpkg errors
@@ -815,6 +817,8 @@ function handle_error {
     $ERROR_MKBUILD_INPUT_PAR)
       eecho $error "$BASENAME: Input parameter $2 error. See \"mkbuild --help\"." ;;
 
+    $ERROR_MKPATCH)
+      eecho $error "$BASENAME: Mkpatch error. Check .mkbuild file." ;;
     #
     # Others errors
     *)
index 08a8db4f74fac49e1fcb101bdeefea1c19957ba8..ca289be20e80a82de04e82edd22c5f5dc49435df 100755 (executable)
 PACKAGE="simplepkg"
 PACK_DIR="package-$PACKAGE"
 BUILD=${BUILD:=1rha}
-VERSION="0.6pre16"
+VERSION="0.6pre17"
 ARCH="noarch"
 LIBEXEC="/usr/libexec/$PACKAGE"
 BINDIR="/usr/bin"
-BINARY_LIST="simplaret repos lspkg mkbuild"
+BINARY_LIST="simplaret repos lspkg mkbuild mkpatch"
 SBINDIR="/usr/sbin"
 SBINARY_LIST="mkjail templatepkg jail-update jail-commit metapkg rebuildpkg createpkg exec-slackbuild simpletrack"
 LIB_LIST="common.sh"
@@ -81,4 +81,3 @@ cd ..
 if [ "$CLEANUP" != "no" ]; then
   rm -rf $PACK_DIR
 fi
-
index cddfa5d95a7f3761a0fb1052ef20360e7792ec76..e11d2da821622a3d443a0398c723ee92351bc663 100755 (executable)
@@ -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 (file)
index 0000000..35f5839
--- /dev/null
@@ -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