aboutsummaryrefslogtreecommitdiff
path: root/branches/0.6/utils/exec-slackbuild
blob: 0d92f28e00f923c8139f0d6098a928439b753788 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash -x
#
# Script to execute SlackBuild and pass parameters
#
# by Rudson R. Alves
#
# Version 0.0.1
PROG_VERSION=0.0.1
LANG=en_US
BACK_TITLE="Exec SlackBuild $PROG_VERSION [$1]"

if [ $# -ne 2 ]; then
    echo "Use: exec-slackbuild <SlackBuild_script> <output_file>"
    exit 0
fi

SLACKBUILD=$1
AUX_TMP=$2

# Load slackbuildrc
if [ -f ~/.slackbuildrc ]; then
  source ~/.slackbuildrc
elif [ -f /etc/slackbuildrc ]; then
  source /etc/slackbuildrc
fi

# set do default null variables
[ -z $SRC_DIR ]      && SRC_DIR="default"
[ -z $REPOS ]        && REPOS="default"
[ -z $TMP ]          && TMP="default"
[ -z $ARCH ]         && ARCH="default"
[ -z $CLEANUP ]      && CLEANUP="default"
[ -z $NUMJOBS ]      && NUMJOBS="default"
[ -z $BUILD ]        && BUILD="default"
[ -z $CONF_OPTIONS ] && CONF_OPTIONS="default"

# Edit variables
ANS=`dialog --separate-widget "rudson" --stdout --backtitle "$BACK_TITLE" \
    --title "Set variables" --form "Use down key to more variables; default = null argument; use \" to set several arguments." \
    19 52 11 \
    "SRC_DIR:"       1 1 "$SRC_DIR"          1 15 30 60 \
    "REPOS:"         3 1 "$REPOS"            3 15 30 60 \
    "TMP:"           5 1 "$TMP"              5 15 30 60 \
    "ARCH:"          7 1 "$ARCH"             7 15 30 60 \
    "CLEANUP:"       9 1 "$CLEANUP"          9 15 30 60 \
    "NUMJOBS:"      11 1 "$NUMJOBS"         11 15 30 60 \
    "BUILD:"        13 1 "$BUILD"           13 15 30 60 \
    "CONF_OPTIONS:" 15 1 "$CONF_OPTIONS"    15 15 30 60`
[ $? -ne 0 ] && exit 11

# Remove "s
     SRC_DIR=`echo $ANS | awk '{print $1}' | tr -d \"`
       REPOS=`echo $ANS | awk '{print $2}' | tr -d \"`
         TMP=`echo $ANS | awk '{print $3}' | tr -d \"`
        ARCH=`echo $ANS | awk '{print $4}' | tr -d \"`
     CLEANUP=`echo $ANS | awk '{print $5}' | tr -d \"`
     NUMJOBS=`echo $ANS | awk '{print $6}' | tr -d \"`
       BUILD=`echo $ANS | awk '{print $7}' | tr -d \"`
CONF_OPTIONS=`echo $ANS | awk '{print $8}' | tr -d \"`

# Set to null ("") variables with default value
     [ "$SRC_DIR" = "default" ] && SRC_DIR=""
       [ "$REPOS" = "default" ] && REPOS=""
         [ "$TMP" = "default" ] && TMP=""
        [ "$ARCH" = "default" ] && ARCH=""
     [ "$CLEANUP" = "default" ] && CLEANUP=""
     [ "$NUMJOBS" = "default" ] && NUMJOBS=""
       [ "$BUILD" = "default" ] && BUILD=""
[ "$CONF_OPTIONS" = "default" ] && CONF_OPTIONS=""

# Select debug level
DEBUG=`dialog --stdout --backtitle "$BACK_TITLE" \
    --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=""

# Check sintax from SlackBuild
sh -n $SLACKBUILD || exit 11

# Execute SlackBuild in background
SRC_DIR="$SRC_DIR" REPOS="$REPOS" TMP="$TMP" ARCH="$ARCH" CLEANUP="$CLEANUP" NUMJOBS="$NUMJOBS" BUILD="$BUILD" CONF_OPTIONS="$CONF_OPTIONS" sh $DEBUG $SLACKBUILD > $AUX_TMP 2>&1 & PID=$!

# Return pid from process
echo $PID