aboutsummaryrefslogtreecommitdiff
path: root/trunk/utils/mkslackbuild
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/utils/mkslackbuild')
-rwxr-xr-xtrunk/utils/mkslackbuild255
1 files changed, 174 insertions, 81 deletions
diff --git a/trunk/utils/mkslackbuild b/trunk/utils/mkslackbuild
index effe00e..2a7c0c2 100755
--- a/trunk/utils/mkslackbuild
+++ b/trunk/utils/mkslackbuild
@@ -9,7 +9,7 @@
# Slackbuilds são scripts utilizados no Slackware para gerar
# pacotes tgz.
#
-# Version 0.9.2
+# Version 0.9.3
#
#--------------------------------------------------------------------
# Functions
@@ -46,11 +46,12 @@ function clean_all()
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
- [ -e /tmp/$MK_PKGNAME ] && rm -rf /tmp/$MK_PKGNAME
- [ ! -z $CONFIG_HELP ] && rm $CONFIG_HELP 2>/dev/null
+ rm -rf /tmp/$MK_PKGNAME 2>/dev/null
+ rm $CONFIG_HELP 2>/dev/null
fi
}
@@ -71,7 +72,7 @@ function print_lines_to()
# Make slack-desc file
function mk_slackdesc()
{
- print_lines_to "slackdesc" "\[\[" $SB_MODEL
+ print_lines_to "slackdesc" "|-----" $SB_MODEL
echo -n $MK_PKGNAME | tr [a-z\-] " "
echo -n "|-----handy-ruler"
let N=18+${#MK_PKGNAME}
@@ -123,27 +124,34 @@ function edit_file()
# Unpackage source
function unpkg_source()
{
- dialog --backtitle "mkSlackBuild $PROG_VERSION [$MK_PKGNAME]" \
- --infobox "Uncompress source in /tmp/$MK_PKGNAME. Wait" 3 45
- [ $? -ne 0 ] && mk_exit 0
- 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/`"
-
- DOC_FILES=`find $MK_TMPSRC -type f -maxdepth 1 -name "[A-Z]*" | sed 's/.*\/\(.*\)$/\1/'`
+ # FIXME: if MK_DECOMPRESSOR -ne bunzip2 or gunzip...
+ if [ $MK_DECOMPRESSOR = "bunzip2" -o $MK_DECOMPRESSOR = "gunzip" ]; then
+ dialog --backtitle "mkSlackBuild $PROG_VERSION [$MK_PKGNAME]" \
+ --infobox "Uncompress source in /tmp/$MK_PKGNAME. Wait" 3 45
+ [ $? -ne 0 ] && mk_exit 0
+ 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/`"
+
+ DOC_FILES=`find $MK_TMPSRC -type f -maxdepth 1 -name "[A-Z]*" | sed 's/.*\/\(.*\)$/\1/'`
+ else
+ dialog --backtitle "mkSlackBuild $PROG_VERSION [$MK_PKGNAME]" \
+ --msgbox "$MK_DECOMPRESSOR not configurated..." 5 45
+ fi
}
# Download source
function download_url()
{
clear
- wget --limit-rate=$MK_LIMITRATE $MK_URL -P $MK_SOURCEDIR/
+ mkdir -p $MK_SOURCEDIR/$MK_PKGNAME 2>/dev/null
+ wget --limit-rate=$MK_LIMITRATE $MK_URL -P $MK_SOURCEDIR/$MK_PKGNAME/
if [ $? -ne 0 ]; then
echo "URL error"
return 0
fi
- MK_SOURCE=$MK_SOURCEDIR/$MK_SRCNAME
+ MK_SOURCE=$MK_SOURCEDIR/$MK_PKGNAME/$MK_SRCNAME
}
# Select source file
@@ -215,6 +223,24 @@ function edit_pkgname()
MK_EXTENSION=`echo $ANS | awk '{print $3}'`
}
+# Edit MK_DECOMPRESSOR and MK_DECOMPRESSOR_TEST_FLAG
+function edit_decompress_arg()
+{
+ # 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 "mkSlackBuild $PROG_VERSION [$MK_PKGNAME]" \
+ --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 ] && mk_exit 0
+
+ MK_DECOMPRESSOR=`echo $ANS3 | awk '{print $1}'`
+ MK_DECOMPRESSOR_TEST_FLAG=`echo $ANS3 | awk '{print $2}'`
+}
+
# Edit configure options
function edit_configure()
{
@@ -302,7 +328,7 @@ function edit_docfiles()
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 | grep $i`" != "" ]; then
+ if [ "`echo NEWS TODO README AUTHORS INSTALL ChangeLog MAINTAINERS COPYING | grep $i`" != "" ]; then
DOCMENU="$DOCMENU $i \"\" on"
else
DOCMENU="$DOCMENU $i \"\" off"
@@ -336,15 +362,17 @@ function change_strings()
# Build initial sections
function start_build()
{
- change_strings "AUTHOR" "$MK_AUTHOR"
- change_strings "AUTHOR INITIALS" $MK_AUTHOR_INITIALS
- change_strings "SOURCE NAME" "${MK_SRCNAME//.$MK_EXTENSION}"
+ change_strings "SLACKBUILD AUTHOR" "$MK_AUTHOR"
+ change_strings "SLACKBUILD AUTHOR INITIALS" $MK_AUTHOR_INITIALS
+ change_strings "SOURCE NAME" "$MK_PKGNAME"
change_strings "PROGRAM NAME" "$MK_PKGNAME"
change_strings "PACKAGE NAME" "$MK_PKGNAME"
- change_strings "PROGRAM URL" "$MK_URL"
+ change_strings "DECOMPRESSOR" "$MK_DECOMPRESSOR"
+ change_strings "DECOMPRESSOR TEST FLAG" "$MK_DECOMPRESSOR_TEST_FLAG"
+ change_strings "PROGRAM URL" "${MK_URL//$MK_SRCNAME}"
change_strings "ARCH" "$MK_ARCH"
change_strings "VERSION" $MK_VERSION
- change_strings "SOURCE EXTENSION" $MK_EXTENSION
+ change_strings "SOURCE EXTENSION" ${MK_EXTENSION#tar.}
change_strings "DOWNLOAD FOLDER URL" "`dirname $MK_URL`"
change_strings "OTHER CONFIGURE ARGS" "$MK_OPTIONS"
change_strings "DOCUMENTATION FILES" "$MK_DOCFILES"
@@ -357,6 +385,7 @@ function mount_slackbuild()
dialog --backtitle "mkSlackBuild $PROG_VERSION [$MK_PKGNAME]" --infobox "SlackBuild save in $SLACKBUILD" 5 30
rm $SLACKBUILD 2>/dev/null
+# [ ! -e `dirname $SLACKBUILD` ] && mkdir `dirname $SLACKBUILD`
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
@@ -365,6 +394,27 @@ function mount_slackbuild()
done
}
+# Mount SlackBuild to section $1
+function mount_slackbuild_to()
+{
+ if [ $# -eq 1 ]; then
+ END_SECTION=$1
+ dialog --backtitle "mkSlackBuild $PROG_VERSION [$MK_PKGNAME]" --infobox "SlackBuild save in $SLACKBUILD.test" 5 30
+
+ rm $SLACKBUILD.test 2>/dev/null
+# [ ! -e `dirname $SLACKBUILD` ] && mkdir `dirname $SLACKBUILD`
+ 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
+}
+
# Make files section
function make_file_sections()
{
@@ -397,12 +447,49 @@ function make_file_sections()
function get_source_dialog()
{
- dialog --stdout --backtitle "mkSlackBuild $PROG_VERSION [$MK_PKGNAME]" \
- --yesno " Download $MK_SRCNAME? " 5 50
- if [ $? -eq 0 ]; then
- download_url
+ if [ ! -e $MK_SOURCE ]; then
+ dialog --stdout --backtitle "mkSlackBuild $PROG_VERSION [$MK_PKGNAME]" \
+ --yesno " Download $MK_SRCNAME? " 5 50
+ if [ $? -eq 0 ]; then
+ download_url
+ else
+ select_source
+ fi
+ fi
+}
+
+
+function test_source()
+{
+ local TEST=1
+ local ANS=0
+
+ while [ $TEST -ne 0 ]; do
+ $MK_DECOMPRESSOR $MK_DECOMPRESSOR_TEST_FLAG $MK_SOURCE
+ TEST=$?
+ if [ $TEST -ne 0 ]; then
+ dialog --stdout --backtitle "mkSlackBuild $PROG_VERSION [$MK_PKGNAME]" --yesno "Source uncompress error. Download source again?" 6 50
+ if [ $? -eq 0 ]; then
+ rm $MK_SOURCE
+ get_source_dialog
+ else
+ TEST=0
+ fi
+ fi
+ done
+}
+
+function set_source_test()
+{
+ MK_SOURCE=$MK_SOURCEDIR/$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
- select_source
+ edit_decompress_arg
fi
}
@@ -424,27 +511,14 @@ function create_slackbuild()
# Compile arch
edit_arch
+ # Set source test vadiables
+ set_source_test
+
# Get source file
- if [ ! -e $MK_SOURCEDIR/$MK_SRCNAME ]; then
- get_source_dialog
- else
- MK_SOURCE=$MK_SOURCEDIR/$MK_SRCNAME
- if [ "$MK_EXTENSION" = gz ]; then
- if ( bzip2 -t $MK_SOURCE ); then
- echo "Ok"
- else
- rm $MK_SOURCE
- get_source_dialog
- fi
- elif [ "$MK_EXTENSION" = bz2 ]; then
- if ( gzip -t $MK_SOURCE ); then
- echo "Ok"
- else
- rm $MK_SOURCE
- get_source_dialog
- fi
- fi
- fi
+ get_source_dialog
+
+ # Test source
+ test_source
# Uncompress source
unpkg_source
@@ -461,9 +535,10 @@ function create_slackbuild()
make_file_sections $SB_MODEL
# Slackbuild script name
- SLACKBUILD=$MK_SLACKBUILDDIR/$MK_PKGNAME.Slackbuild
+ SLACKBUILD=$BASEDIR/$MK_PKGNAME.Slackbuild
# mkSlackBuild script name
+ # FIXME: make an MODELDIR???
MKSLACKBUILD=$BASEDIR/$MK_PKGNAME.mkslackbuild
mk_slackdesc > slackdesc_$MK_PKGNAME.mkbuild
@@ -488,42 +563,29 @@ function open_mkslackbuild()
source $MKSLACKBUILD
# SlackBuild scrit name
- SLACKBUILD=$MK_SLACKBUILDDIR/$MK_PKGNAME.Slackbuild
+ SLACKBUILD=$BASEDIR/$MK_PKGNAME.Slackbuild
# Create files sections
make_file_sections $MKSLACKBUILD
[ -e $BASEDIR/slack-required ] && ( cp $BASEDIR/slack-required $DEPENDENCY_LIST )
- # Main-Menu
- #edit_menu
else
dialog --backtitle "mkSlackBuild $PROG_VERSION [$MK_PKGNAME]" \
--msgbox "$MKSLACKBUILD most be a file" 0 0
fi
+ # CHECK:
+ # Set source test vadiables
+ set_source_test
+
# Get source file
- if [ ! -e $MK_SOURCEDIR/$MK_SRCNAME ]; then
- get_source_dialog
- else
- MK_SOURCE=$MK_SOURCEDIR/$MK_SRCNAME
- if [ "$MK_EXTENSION" = gz ]; then
- if ( bzip2 -t $MK_SOURCE ); then
- echo "Ok"
- else
- rm $MK_SOURCE
- get_source_dialog
- fi
- elif [ "$MK_EXTENSION" = bz2 ]; then
- if ( gzip -t $MK_SOURCE ); then
- echo "Ok"
- else
- rm $MK_SOURCE
- get_source_dialog
- fi
- fi
- fi
+ get_source_dialog
+
+ # Test source
+ test_source
+ # Uncompress source
unpkg_source
}
@@ -542,6 +604,8 @@ function save_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
@@ -550,7 +614,7 @@ function save_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 "</${SECTION_NAME[i]}> ${SECTION_FLAG[i]}" >> $MKSLACKBUILD
+ echo "</${SECTION_NAME[i]}>" >> $MKSLACKBUILD
echo "" >> $MKSLACKBUILD
done
@@ -591,6 +655,37 @@ function edit_menu()
done
}
+# Test Menu
+function test_menu()
+{
+ local ANST=0
+ local SECTION=0
+ local EDITMENU=""
+
+ # 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
+
+ while [ "$ANST" != "1" ]; do
+ SECTION=`eval "dialog --stdout --backtitle \"mkSlackBuild $PROG_VERSION [$MK_PKGNAME]\" --menu \"Select section to test end\" 20 40 13 $EDITMENU"`
+ ANST=$?
+ if [ $ANST -ne 1 ]; then
+ mount_slackbuild_to $SECTION
+ clear
+ if [ "$USER" != "root" ]; then
+ su -c "( sh -x $SLACKBUILD.test )"
+ else
+ ( sh -x $SLACKBUILD.test )
+ fi
+ echo -n "Enter 1 to end test: "
+ read ANST
+ fi
+ done
+}
+
# Dependency list edit
function edit_dependency()
{
@@ -613,9 +708,9 @@ function exec_script()
#--------------------------------------------------------------------
#
# turn off debug
-##set +x
+set +x
# Start variables
-PROG_VERSION=0.9.2
+PROG_VERSION=0.9.3
LANG=us
BASEDIR=`pwd`
AUX_TMP=`mktemp -p /tmp/ aux_tmp.XXXXXX`
@@ -647,13 +742,11 @@ MK_LIMITRATE="100k"
MK_SOURCEDIR=\`pwd\`
MK_ARCH="i468"
#MK_URL="ftp://localhost"
-#MK_SLACKBUILDDIR=/slackbuild-dir
EOF
)
fi
source ~/.mkslackbuild
MK_SOURCEDIR=${MK_SOURCEDIR:=$BASEDIR}
-MK_SLACKBUILDDIR=${MK_SLACKBUILDDIR:=$BASEDIR}
MK_ARCH=${MK_ARCH:="i486"}
# Config Author
@@ -677,10 +770,10 @@ while [ $ANS0 -ne 0 ]; do
"2" "Open MkSlackBuild" \
"3" "Save MkSlackBuild" \
"4" "Make Slackbuild" \
- "5" "Edit setions menu" \
- "6" "Edit dependency list" \
- "7" "Test SlackBuild script" \
- "8" "View doc-files" \
+ "5" "Edit Script Sections" \
+ "6" "Edit Dependency List" \
+ "7" "Test SlackBuild Script" \
+ "8" "View Doc-Files" \
"0" "Exit"`
EXIT_STATUS=$?
fi
@@ -709,13 +802,13 @@ while [ $ANS0 -ne 0 ]; do
edit_dependency
;;
7)
- exec_script
+ test_menu
;;
8)
view_docs
;;
*)
- true
+ echo "Exit..."
;;
esac
done