diff options
author | rudson <rudson@04377dda-e619-0410-9926-eae83683ac58> | 2007-04-10 03:08:50 +0000 |
---|---|---|
committer | rudson <rudson@04377dda-e619-0410-9926-eae83683ac58> | 2007-04-10 03:08:50 +0000 |
commit | 6ff7619159dad5aa2bf914520ca2ca494ecb0819 (patch) | |
tree | 49763777168a42ce1e964767d4ac107cace03edd /trunk/src | |
parent | e676563572242c50db6a20759168be4d9f44d90f (diff) | |
download | simplepkg-6ff7619159dad5aa2bf914520ca2ca494ecb0819.tar.gz simplepkg-6ff7619159dad5aa2bf914520ca2ca494ecb0819.tar.bz2 |
mkbuild: 0.9.17
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@329 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'trunk/src')
-rwxr-xr-x | trunk/src/mkbuild | 223 |
1 files changed, 188 insertions, 35 deletions
diff --git a/trunk/src/mkbuild b/trunk/src/mkbuild index 1ec1b6b..dc3dceb 100755 --- a/trunk/src/mkbuild +++ b/trunk/src/mkbuild @@ -1,19 +1,19 @@ #!/bin/bash -x # -# Script para gerar Slackbuild +# Script para gerar SlackBuild # Por Rudson R. Alves # # Este script auxilia a criação de SlackBuilds, com o modelo # do Luiz do Sarava Linux # -# Slackbuilds são scripts utilizados no Slackware para gerar +# SlackBuilds são scripts utilizados no Slackware para gerar # pacotes tgz. # # Turn off debug set +x # -# Version 0.9.16 -PROG_VERSION=0.9.16 +# Version 0.9.17 +PROG_VERSION=0.9.17 #-------------------------------------------------------------------- # Functions @@ -89,7 +89,7 @@ function mk_slackdesc() print_lines "slackdesc" $SB_MODEL | sed '1,/\]\]/ d' } -# Get label status from Slackbuild model +# Get label status from SlackBuild model function get_status() { [ $# -ne 2 ] && mk_exit 1 @@ -148,7 +148,7 @@ function download_url() { clear mkdir -p $MK_SOURCEDIR/$MK_PKGNAME 2>/dev/null - wget --limit-rate=$MK_LIMITRATE $MK_URL -P $MK_SOURCEDIR/$MK_PKGNAME/ + wget --continue --limit-rate=$MK_LIMITRATE $MK_URL -P $MK_SOURCEDIR/$MK_PKGNAME/ if [ $? -ne 0 ]; then echo "URL error" return 0 @@ -192,7 +192,21 @@ function edit_author() MK_SOURCEDIR=`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_SOURCEDIR" ~/.mkslackbuild - MK_ARCH=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --inputbox "Enter default architecture to Slackbuild:" 8 60 "i468"` + if [ "$USER" != "root" ]; then + SLACKBUILDRC=`[ -e ~/.slackbuildrc ] && echo ~/.slackbuildrc || echo /etc/slackbuildrc` + MK_REPOS=`grep 'REPOS=' $SLACKBUILDRC | sed 's/REPOS=\(.*\)/\1/'` + 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" ~/.mkslackbuild + + MK_SLACKBUILD_DIR=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --inputbox "Enter with binary repository directory:" 8 60 "$MK_SLACKBUILD_DIR"` + edit_file "SLACKBUILD DIR" "$MK_SLACKBUILD_DIR" ~/.mkslackbuild + + 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" ~/.mkslackbuild MK_LIMITRATE=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --inputbox "Enter wget limit rate:" 8 60 "120k"` @@ -202,6 +216,7 @@ function edit_author() # Edit source URL function edit_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 } @@ -220,7 +235,7 @@ function edit_pkgname() { # 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_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/'` @@ -266,8 +281,9 @@ function edit_configure() $MK_TMPSRC/configure --help > $CONFIG_HELP config_help - [ "$( cat $CONFIG_HELP | egrep '/usr/local')" != "" ] && MK_PREFIX=/usr || MK_PREFIX=/opt/kde - MK_OPTIONS=" " + #[ "$( 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 @@ -393,7 +409,11 @@ function start_build() change_strings "VERSION" $MK_VERSION change_strings "SOURCE EXTENSION" ${MK_EXTENSION#tar.} change_strings "DOWNLOAD FOLDER URL" "`dirname $MK_URL`" - change_strings "OTHER CONFIGURE ARGS" "$MK_OPTIONS" + if [ -z $MK_OPTIONS ]; then + change_strings "OTHER CONFIGURE ARGS" "\"\"" + else + change_strings "OTHER CONFIGURE ARGS" "$MK_OPTIONS" + fi change_strings "DOCUMENTATION FILES" "$MK_DOCFILES" change_strings "PREFIX" "$MK_PREFIX" } @@ -411,6 +431,7 @@ function mount_slackbuild() echo "" >> $SLACKBUILD fi done + chmod +x $SLACKBUILD } # Mount SlackBuild to section $1 @@ -461,6 +482,7 @@ function make_file_sections() let INDEX-- MAXSECTION=$INDEX + md5sum *.mkbuild > md5sum } function get_source_dialog() @@ -555,7 +577,7 @@ function edit_md5sum() #-------------------------------------------------------------------- # Main functions #-------------------------------------------------------------------- -# Create new Slackbuild +# Create new SlackBuild function create_slackbuild() { # Config package URL @@ -605,8 +627,8 @@ function create_slackbuild() # Create files sections make_file_sections $SB_MODEL - # Slackbuild script name - SLACKBUILD=$BASEDIR/$MK_PKGNAME.Slackbuild + # SlackBuild script name + SLACKBUILD=$BASEDIR/$MK_PKGNAME.SlackBuild # mkSlackBuild script name # FIXME: make an MODELDIR??? @@ -641,7 +663,7 @@ function open_mkslackbuild() source $MKSLACKBUILD # SlackBuild scrit name - SLACKBUILD=$BASEDIR/$MK_PKGNAME.Slackbuild + SLACKBUILD=$BASEDIR/$MK_PKGNAME.SlackBuild # Create files sections make_file_sections $MKSLACKBUILD @@ -670,7 +692,7 @@ function open_mkslackbuild() unpkg_source } -# Save mkSlackbuild +# Save mkSlackBuild function save_mkslackbuild() { dialog --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --title "$MK_TITLE" --infobox "mkSlackBuild save in $MKSLACKBUILD" 5 30 @@ -850,9 +872,8 @@ function menu_dependency() 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" \ - "0" "Main Menu"` + "1" "Edit dependency list" \ + "2" "Test dependency list"` [ $? -ne 0 ] && ANSD=0 @@ -864,7 +885,6 @@ function menu_dependency() test_dependency ;; esac - done } @@ -904,13 +924,119 @@ function test_dependency() fi } +# Add/commit one SlackBuild +function commit_SlackBuild() +{ + # Mount SlackBuild + mount_slackbuild + MK_TITLE="Commit SlackBuild" + + # Find SlackBuild + SB_PATH=`find $MK_SLACKBUILD_DIR -iname $MK_PKGNAME` + + # Change to SlackBuild directory + cd $MK_SLACKBUILD_DIR + + # Check for new SlackBuild + if [ -z $SB_PATH ]; then + # New SlackBuild + AUX="" + while [ -z $AUX ]; do + dialog --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" --infobox "lynx -dump http://gentoo-portage.com/Search?search=$MK_PKGNAME. 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 " "` + # Default directory + 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 + 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 + echo "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 +} + +# Compile SlackBuild and install +function compile_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 +} + # #-------------------------------------------------------------------- # Start Program #-------------------------------------------------------------------- # # Start variables -LANG=us +LANG=en_US BASEDIR=`pwd` AUX_TMP=`mktemp -p /tmp/ aux_tmp.XXXXXX` SLACKDESC_TMP=`mktemp -p /tmp/ slackdesc_tmp.XXXXXX` @@ -926,7 +1052,7 @@ if [ -z $SB_MODEL ]; then mk_exit 0 fi fi -[ $# -ne 0 ] && MKSLACKBUILD=$1 +[ $# -ne 0 ] && MKSLACKBUILD=${1//.*}.mkslackbuild # Clear dialog dialog --clear @@ -940,9 +1066,11 @@ if [ ! -e ~/.mkslackbuild ]; then MK_AUTHOR="[[AUTHOR NAME]]" MK_AUTHOR_INITIALS="[[AUTHOR INITIALS]]" MK_EDITOR=[[EDITOR]] +MK_REPOS=[[REPOS DIR]] MK_LIMITRATE=[[LIMIT RATE]] MK_SOURCEDIR=[[SOURCE DIR]] MK_ARCH=[[DEFAULT ARCH]] +MK_SLACKBUILD_DIR=[[SLACKBUILD DIR]] #SB_MODEL="my_model" EOF ) @@ -998,34 +1126,55 @@ while [ $ANS0 -ne 0 ]; do else ANS0=`dialog --stdout --backtitle "Make SlackBuild $PROG_VERSION [$MK_PKGNAME]" \ --cancel-label "Exit" --menu "Main Menu:" 0 0 0 \ - "1" "Edit Sections" \ - "2" "Dependency Menu" \ - "3" "Test Script" \ + "1" "Edit SlackBuild sections" \ + "2" "Edit dependency list" \ + "3" "Test SlackBuild script" \ "4" "View Doc-Files" \ - "0" "Exit and Save..."` + "5" "Save SlackBuild and mkslackbuild" \ + "6" "Compile/install package" \ + "7" "Remove package" \ + "8" "Commit SlackBuild to Sarava"` if [ $? -ne 0 ]; then ANS0=0 fi case $ANS0 in - 1) + 1) # Edit Sections MK_TITLE=" Edit Menu " edit_menu ;; - 2) + 2) # Dependency Menu MK_TITLE=" Dependency Menu " menu_dependency ;; - 3) + 3) # Test Script MK_TITLE=" Test Menu " test_menu ;; - 4) + 4) # View Doc-Files MK_TITLE=" View Docs " view_docs ;; - *) - echo "Exit..." + 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 @@ -1033,10 +1182,14 @@ while [ $ANS0 -ne 0 ]; do fi done +# Check changes if [ ! -z $MK_PKGNAME ]; then - MKSLACKBUILD=$BASEDIR/$MK_PKGNAME.mkslackbuild - save_mkslackbuild - mount_slackbuild + md5sum -c md5sum + if [ $? -ne 0 ]; then + MKSLACKBUILD=$BASEDIR/$MK_PKGNAME.mkslackbuild + save_mkslackbuild + mount_slackbuild + fi fi mk_exit 0 |