aboutsummaryrefslogtreecommitdiff
path: root/branches/0.6/src/mkbuild
blob: 24130080a07e50b747dbfb063ce91ad509a6e83d (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
#!/bin/bash
#
# 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
# pacotes tgz.
#
# Version 0.9.5
PROG_VERSION=0.9.5

#--------------------------------------------------------------------
# Functions
#--------------------------------------------------------------------
function mkbuild_use()

{
    # mkbuild help function
    echo "
NAME
        mkbuild - create SlackBuild script from mkbuild_file input

SYNOPSIS
        mkbuild [OPIONS] [mkbuild_file]

DESCRIPTION
        <mkbuild_file> input file with build rules and variables

        Input options:
            -a, --author <author_name>
                author name
            -ai, --author_initials <initials>
                author signature
            -cs, --const_string <string>
                construction string to source name
            -u, --url <url_address>
                url address to source
            -pn, --pkg_name <package_name>
                package name
            -sn, --src_name <source_name>
                source name
            -pv, --pkg_version <version>
                package version
            -md, --model <SlackBuild_model>
                SlackBuild model file
            -j, --jobs <jobs_number>
                Number of jobs to run simultaneously
            --prefix <install_dir>
                Prefix install directory

        Program options:
        -h, --help
            this help mesage
        -c, --commit
            commit SlackBuilds in local svn tree
        -v, --version
            program version

EXAMPLES
        mkbuild --prefix /usr/local pyrex.mkbuild
            build pyrex.SlackBuild with prefix /usr/local and pyrex.mkbuild variables and options definitions.

AUTHOR
        Written by Rduson R. Alves

REPORTING BUGS
        Report bugs to <alves_list@yahoo.com.br>

COPYRIGHT
        Copyright � 2006 Free Software Foundation, Inc.
        This is free software. You may redistribute copies of it under the
        terms of the GNU General Public License
        <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the
        extent permitted by law.
" | less
}

function error_codes {

    # Start error codes function
    NULL_STRING=499
    ERROR_FILE_NOT_FOUND=500
    ERROR_CONSTRUCTION=501
    ERROR_PROGRAM=502
    ERROR_INPUT_PAR=503
}

function mkbuild_error {

    # Error function
    case $1 in
        "$ERROR_FILE_NOT_FOUND")
            echo "File $2 not found!"
        ;;
        "$ERROR_CONSTRUCTION")
            echo "Construction error in $2 variable."
        ;;
        "$ERROR_PROGRAM")
            echo "Program logical error."
        ;;
        "$ERROR_INPUT_PAR")
            echo "Input parameter $2 error. See \"mkbuild --help\"."
        ;;
        *)
            echo "Unknow error!"
        ;;
    esac
    exit $1
}

function is_number {

    # Check if argument is a number
    local -i int
    if [ $# -eq 0 ]; then
            return 1
    else
            (let int=$1)  2>/dev/null
            return $?       # Exit status of the let thread
    fi
}

function set_parameters {

    # Get and set mkbuild variables with parameters input
    # Use: set_parameters $@
    #           where $@ are the parameters input
    #
    ALL_PAR=( $@ )      # carrega todos os par�metros
    N_PAR=$#            # carrega o n�mero de par�metros

    i=0                 # inicia o contador
    # Checa todos os par�metros passados
    while [ $i -lt $N_PAR ]; do
        # get parameter[i]
        PAR=${ALL_PAR[$i]}
        case $PAR in
            '-c'|'--commit')
                # Commit directory
                COMMIT=1
            ;;
            '-d'|'--debug')
                # Debug mode
                set -x
            ;;
            '-h'|'--help' )
                # Show help mesage
                mkbuild_use && exit 0
            ;;
            '-v'|'--version')
                # Show program version
                echo -e "\nmkbuild version $PROG_VERSION\n" && exit 0
            ;;
            '-a'|'--author')
                # Enter with author name
                let i++
                AUTHOR=${ALL_PAR[$i]}
                [ ${AUTHOR:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR AUTHOR
            ;;
            '-ai'|'--author_initials')
                # Enter with author name
                let i++
                AUTHOR_INITIALS=${ALL_PAR[$i]}
                [ ${AUTHOR_INITIALS:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR AUTHOR_INITIALS
            ;;
            '-cs'|'--const_string')
                # Enter with construction source name string
                let i++
                CONST_STRING=${ALL_PAR[$i]}
                [ ${CONST_STRING:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR CONST_STRING
            ;;
            '-md'|'--model')
                # Enter with SlackBuild model
                let i++
                MODEL=${ALL_PAR[$i]}
                [ ${MODEL:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR MODEL
            ;;
            '-j'|'--jobs')
                # Enter with SlackBuild model
                let i++
                NUMJOBS=${ALL_PAR[$i]}
                [ ${NUMJOBS:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR NUMJOBS
                [ ! is_number $NUMJOBS ] &&  mkbuild_error $ERROR_INPUT_PAR NUMJOBS
                NUMJOBS="-j$NUMJOBS"
            ;;
            '--prefix')
                # Enter with SlackBuild model
                let i++
                PREFIX=${ALL_PAR[$i]}
                [ ${PREFIX:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR PREFIX
            ;;
            '-pn'|'--pkg_name')
                # Enter with package name
                let i++
                PKG_NAME=${ALL_PAR[$i]}
                [ ${PKG_NAME:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR PKG_NAME
            ;;
            '-pv'|'pkg_version')
                # Enter with package version
                let i++
                VERSION=${ALL_PAR[$i]}
                [ ${VERSION:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR VERSION
            ;;
            '-sn'|'--src_name')
                # Enter with source name
                let i++
                SRC_NAME=${ALL_PAR[$i]}
                [ ${SRC_NAME:0:1} = '-' ] && mkbuild_error $ERROR_INPUT_PAR SRC_NAME
            ;;
            '-u'|'--url')
                # Enter with url address
                let i++
                URL=${ALL_PAR[$i]}
                [ ${URL:0:1} = '-' ] && mkbuild_error $ERROR_INPUT_PAR URL
            ;;
            *)
                # mkbuild input file
                MK_INPUT_FILE="${PAR//.mkbuild}.mkbuild"
                [ ! -e $MK_INPUT_FILE ] && mkbuild_error $ERROR_FILE_NOT_FOUND $MK_INPUT_FILE
            ;;
        esac
        let i++
    done
}

function get_variable {

    # Get variable value from mkbuild file (MK_INPUT_FILE)
    [ $# -ne 1 ] && mkbuild_error $ERROR_PROGRAM
    [ -z $MK_INPUT_FILE ] && echo "Warning: no [mkbuild_file]." && return 0

    grep "^\[\[${1}\]\]" $MK_INPUT_FILE | cut -f2 -d\"
}

function edit_file {

    # Edit file  $3, by change string [[$1]] to $2
    local STR_OLD
    local STR_NEW

    [ $# -ne 3 ] && mkbuild_error $ERROR_PROGRAM
    STR_OLD=$( echo $1 | sed 's/\//\\\//g' )
    STR_NEW=$( echo $2 | sed 's/\//\\\//g' )
    eval "sed 's/\[\[$STR_OLD\]\]/$STR_NEW/' $3 > $AUX_TMP"
    mv $AUX_TMP $3
}

function edit_file_full {

    # Edit file  $3, by change string $1 to $2
    local STR_OLD
    local STR_NEW

    [ $# -ne 3 ] && mkbuild_error $ERROR_PROGRAM
    STR_OLD=$( echo $1 | sed 's/\//\\\//g' )
    STR_NEW=$( echo $2 | sed 's/\//\\\//g' )
    eval "sed 's/$STR_OLD/$STR_NEW/' $3 > $AUX_TMP"
    mv $AUX_TMP $3
}

function start_build  {

    # Build initial sections
    [ $# -ne 1 ] && mkbuild_error $ERROR_PROGRAM

    edit_file "SLACKBUILD AUTHOR" "$AUTHOR" $1
    edit_file "SLACKBUILD AUTHOR INITIALS" $AUTHOR_INITIALS $1
    edit_file "SOURCE NAME" "$SRC_NAME" $1
    edit_file "PROGRAM NAME" "$PKG_NAME" $1
    edit_file "PACKAGE NAME" "$PKG_NAME" $1
    edit_file "DECOMPRESSOR" "$DECOMPRESSOR" $1
    edit_file "DECOMPRESSOR TEST FLAG" "$DECOMPRESSOR_TEST_FLAG" $1
    edit_file "PROGRAM URL" "$URL" $1
    edit_file "ARCH" "$ARCH" $1
    edit_file "NUMBER OF JOBS" "$NUMJOBS" $1
    edit_file "VERSION" $VERSION $1
    edit_file "SOURCE NAME CONSTRUCTION STRING" "$CONST_STRING" $1
    edit_file "EXTENSION" "$EXTENSION" $1
    edit_file "DOWNLOAD FOLDER URL" "$URL" $1
    edit_file "OTHER CONFIGURE ARGS" "$OPTIONS" $1
    edit_file "DOCUMENTATION FILES" "$DOCFILES" $1
    edit_file "PREFIX" "$PREFIX" $1

    edit_file_full "\$EXTENSION" "$EXTENSION" $1
}

function clear_files {

    # Remove temporary files
    rm $AUX_TMP 2>/dev/null
    rm $SLACKBUILD_TEMP 2>/dev/null
}

function set_status {

    # Set status section
    # $1 - Section
    # $2 - Status
    # $3 - file
    [ $# -ne 3 ] && mkbuild_error $ERROR_PROGRAM
    if [ "`get_status $1 $3`" != "all" ]; then
        eval "sed 's/^<$1>.*$/<$1> $2/' $3" > $AUX_TMP
        mv $AUX_TMP $3
    else
        echo "Warning: Section $1 have status all. Can't change!"
    fi
}

function get_status {

    # Get status from section
    # $1 - Section
    # $2 - file
    [ $# -ne 2 ] && mkbuild_error $ERROR_PROGRAM
    eval "sed '/^<$1>.*$/! d' $2"
}

function activate_sections {

    # Enable and desable sections
    ACTIONS_LIST=`sed '/^#>>/,/<</ ! d; /^#/ d ' $MK_INPUT_FILE | tr -d ' '`
    for i in $ACTIONS_LIST; do
        STATUS=`echo $i | cut -f1 -d:`
        SECTION=`echo $i | cut -f2 -d:`
        set_status $SECTION $STATUS $SLACKBUILD_TEMP
    done
}

function build_slackbuild {

    # Remove off sections
    [ -e $SLACKBUILD ] && mv $SLACKBUILD $SLACKBUILD.old
    sed '/^<[a-z].*> off/, /^<\/[a-z].*>$/ d' $SLACKBUILD_TEMP > $AUX_TMP
    # Remove sections names
    sed '/^<.*$/ d' $AUX_TMP > $SLACKBUILD_TEMP
    # Remove clear lines
    sed ':i ; $! N; s/\n/<NL>/ ; t i' $SLACKBUILD_TEMP | sed 's/<NL><NL><NL>/<NL><NL>/g' | sed 's/<NL><NL><NL>/<NL><NL>/g' | sed 's/<NL>/\n/g' > $AUX_TMP
    sed '1,/^#\!/ {/^#\!/ b; d }' $AUX_TMP > $SLACKBUILD
}

function section_edit {

    # Edit sections by change you values
    [ -z $MK_INPUT_FILE ] && return 0

    SECTION_LIST=`grep '^#>[a-z]' $MK_INPUT_FILE | cut -c3-`

    # Check for sections change
    [ -z "$SECTION_LIST" ] && return 0

    # Change sections
    for i in $SECTION_LIST; do
        if [ "$i" = "slackdesc" ]; then
            # Special slackdesc section
            slackdesc_edit > $AUX_TMP
            mv $AUX_TMP $SLACKBUILD_TEMP
        else
            # Others sections
            section_change $i
        fi
    done
}

function slackdesc_edit {

    # Edit slackdesc section
    sed -n '1,/|-----/ { /<slackdesc>/ b; /|-----/ b; p; }' $SLACKBUILD_TEMP
    echo -n $PKG_NAME | tr [a-z+\-] " "
    echo -n "|-----handy-ruler"
    let N=18+${#PKG_NAME}
    for i in `seq $N $SLACKDESC_LEN`; do
        echo -n "-"
    done
    echo -en "|\n"

    sed -n '/#>slackdesc/,/#<slackdesc/ { /^#/ b; p }' $MK_INPUT_FILE
    sed '1, /\[\[SLACK-DESC\]\]/ d' $SLACKBUILD_TEMP
}

function section_change {

    # Change section lines
    [ $# -ne 1 ] && mkbuild_error $ERROR_PROGRAM

    # Copy first half
    eval "sed '1,/^<$1>/! d' $SLACKBUILD_TEMP > $AUX_TMP"
    # Paste new section
    eval "sed -n '/#>$1/,/#<$1/ { /^#>/ b; /^#</ b; p }' $MK_INPUT_FILE >> $AUX_TMP"
    # Copy second halt
    eval "sed '/^<\/$1>/,$ ! d' $SLACKBUILD_TEMP >> $AUX_TMP"

    mv $AUX_TMP $SLACKBUILD_TEMP
}

function make_slack_required {

    # Build slack-required file
    [ -e slack-required ] && mv slack-required slack-required.old
    [ -z "$SLACK_REQUIRED" ] && return 0

    echo -e "# Dependency list to broffice\n#\n# dependency [condition] [version]]" > slack-required

    echo $SLACK_REQUIRED | sed 's/:/\n/g' | while read i; do
        REQ=`echo $i | awk '{ print $1 }'`
        CON=`echo $i | awk '{ print $2 }'`
        VER=`echo $i | awk '{ print $3 }'`
        echo -e "$REQ\t\t$CON\t\t$VER" >> slack-required
    done
}

function change_others_fields {

    # Change others fields started by '[[' in .mkbuild file
    grep '\[\[[A-Za-z]' $MK_INPUT_FILE | while read i; do
        CHANGE="`echo $i | sed 's/\[\[\(.*\)\]\]=\"\(.*\)\"/\1/'`"
        VALUE="`echo $i | sed 's/\[\[\(.*\)\]\]=\"\(.*\)\"/\2/'`"
        edit_file "$CHANGE" "$VALUE" $SLACKBUILD
    done
}

function commit_slackbuild {

    AUX=`lynx -dump http://gentoo-portage.com/Search?search=$PKG_NAME | sed -n '/Results:/,+1 { /Results:/ b ; p }' | head --lines=1 | tr -d " "`
    [ -z $AUX ] && echo $SLACKBUILD path not found! && return 0

    SLACKBUILD_PATH="`dirname $AUX | tr - /`/`basename $AUX`"

    # change to SlackBuilds directory
    cd $SLACKBUILDS_DIR/

    # Add SlackBuild scripts
    # check path
    [ ! -e $SLACKBUILD_PATH ] && svn_mkdir $SLACKBUILD_PATH
    # add SlackBuild
    svn_add $SLACKBUILD $SLACKBUILD_PATH

    # check slack-required
    # add slack-required
    svn_add slack-required $SLACKBUILD_PATH

    cd $WORK
}

function svn_mkdir {

    # svn make directory
    [ $# -ne 1 ] && mkbuild_error 0

    echo "svn_mkdir $1  $2"
    DIR_LIST=`echo $1 | tr '/' ' '`

    DIR=""
    for i in $DIR_LIST; do
        DIR=$DIR/$i
        [ ! -e ${DIR:1} ] && svn mkdir ${DIR:1}
    done
}

function svn_add {

    # svn add file
    [ $# -ne 2 ] && mkbuild_error 0

    # copy file
    if [ -e $2/$1 ]; then
        echo "$2/$1 exist. Overwriter it."
        cp $WORK/$1 $2/
    else
        cp $WORK/$1 $2/
        # add file to svn tree
        svn add $2/$1
    fi
}

#=============================
#        Main Program
#=============================
#-----------------------------
# Common functions
COMMON="/usr/libexec/simplepkg/common.sh"
SIMPLEPKG_CONF="/etc/simplepkg/simplepkg.conf"
WORK=`pwd`
LANG=en_US
COMMIT=0

if [ -f "$COMMON" ]; then
  source $COMMON
else
  echo "error: file $COMMON found, check your $BASENAME installation"
  mk_exit 0
fi

# createpkg and mkbuild section
SLACKBUILDS_DIR="`eval_parameter SLACKBUILDS_DIR /var/slackbuilds`"
#MAKEPKG_REPOS="`eval_parameter MAKEPKG_REPOS /var/simplaret/binaries`"
#-----------------------------

# Start variables
DOWNLOAD_SOURCE=0       # desable download source
# Auxiliar file
AUX_TMP=/tmp/mkbuild_tmp.$RANDOM
# Derectory to SlackBuild models
MODEL_DIR=${MODEL_DIR:="/etc/simplepkg/defaults/mkbuild"}
# SlackDesk line length
SLACKDESC_LEN=78

# Load error codes
error_codes

[ $# -eq 0 ] && mkbuild_use && exit 1

# Configure input parameters
set_parameters $@

# Get values
AUTHOR=${AUTHOR:="`get_variable "SLACKBUILD AUTHOR"`"}
[ -z "$AUTHOR" ] && mkbuild_error $ERROR_CONSTRUCTION "SLACKBUILD AUTHOR"

AUTHOR_INITIALS=${AUTHOR_INITIALS:="`get_variable "SLACKBUILD AUTHOR INITIALS"`"}
[ -z $AUTHOR_INITIALS ] && mkbuild_error $ERROR_CONSTRUCTION "SLACKBUILD AUTHOR INITIALS"

URL=${URL:="`get_variable "DOWNLOAD FOLDER URL"`"}
EXTENSION=${EXTENSION:="`echo $URL | rev | cut -c1-3 | rev | tr -d '.'`"}
if [ $EXTENSION = "gz" -o $EXTENSION = "tgz" -o $EXTENSION = "bz2" -o $EXTENSION = "zip" ]; then
    SOURCE_NAME=`basename $URL`
    URL_BASE=`dirname $URL`
else
    EXTENSION=`get_variable "EXTENSION"`
    [ -z $EXTENSION ] && mkbuild_error $ERROR_CONSTRUCTION "EXTENSION"
    URL_BASE=$URL
fi

# Source name
SRC_NAME=${SRC_NAME:="`get_variable "SOURCE NAME"`"}
[ -z $SRC_NAME ] && SRC_NAME=`echo $SOURCE_NAME | sed -r 's/(.*)-(.*)\.(.*\..*)$/\1/'`
[ -z $SRC_NAME ] && mkbuild_error $ERROR_CONSTRUCTION "SOURCE NAME"

# Package name
PKG_NAME=${PKG_NAME:="`get_variable "PACKAGE NAME"`"}
[ -z $PKG_NAME ] && PKG_NAME=`echo $SRC_NAME | tr [A-Z_] [a-z\-]`

# Version
VERSION=${VERSION:="`get_variable "VERSION"`"}
[ -z $VERSION ] && VERSION=`echo $SRC_NAME | sed -r 's/(.*)-(.*)\.(.*\..*)$/\2/'`
[ -z $VERSION ] && mkbuild_error $ERROR_CONSTRUCTION "VERSION"

# Construction source name string
CONST_STRING=${CONST_STRING:="`get_variable "SOURCE NAME CONSTRUCTION STRING"`"}
[ -z "$CONST_STRING" ] && CONST_STRING="\$SRC_NAME-\$VERSION.tar.$EXTENSION"

# Build Source Name
[ -z $SOURCE_NAME ] && SOURCE_NAME=`eval "echo $CONST_STRING"`

# Decompressor program and test flag
DECOMPRESSOR=${DECOMPRESSOR:="`get_variable "DECOMPRESSOR"`"}
if [ -z $DECOMPRESSOR ]; then
    case $EXTENSION in
        'gz'|'GZ')
            DECOMPRESSOR="gunzip"
            DECOMPRESSOR_TEST_FLAG="-t"
        ;;
        'bz2'|'BZ2')
            DECOMPRESSOR="bunzip2"
            DECOMPRESSOR_TEST_FLAG="-t"
        ;;
        'zip'|'ZIP')
            DECOMPRESSOR="unzip"
            DECOMPRESSOR_TEST_FLAG="-t"
        ;;
        *)
            mkbuild_error $ERROR_CONSTRUCTION "DECOMPRESSOR"
        ;;
    esac
fi
[ -z $DECOMPRESSOR_TEST_FLAG ] && DECOMPRESSOR_TEST_FLAG=`get_variable "DECOMPRESSOR TEST FLAG"`
[ -z $DECOMPRESSOR_TEST_FLAG ] && mkbuild_error $ERROR_CONSTRUCTION "DECOMPRESSOR TEST FLAG"

# Documentations list
DOCFILES=${DOCFILES:="`get_variable "DOCUMENTATION FILES"`"}
if [ -z "$DOCFILES" ]; then
    DOCFILES="NEWS TODO README AUTHORS INSTALL ChangeLog MAINTAINERS COPYING readme.*"
fi

# ./configure option
OPTIONS=${OPTIONS:="`get_variable "OTHER CONFIGURE ARGS"`"}

# PREFIX
PREFIX=${PREFIX:="`get_variable "PREFIX"`"}
[ -z $PREFIX ] && PREFIX="/usr"

# Number of jobs
NUMJOBS=${NUMJOBS:="`get_variable "NUMBER OF JOBS"`"}

# Make slack-required file.
SLACK_REQUIRED=${SLACK_REQUIRED:="`get_variable "SLACK REQUIRED"`"}
[ -z "$SLACK_REQUIRED" ] && make_slack_required

# SlackBuild model
MODEL=${MODEL:="`get_variable "SLACKBUILD MODEL"`"}
[ -z $MODEL ] && MODEL="generic.mkSlackbuild"

#
# Start build SlackBuild
SLACKBUILD=${PKG_NAME}.SlackBuild
SLACKBUILD_TEMP=$SLACKBUILD.tmp
cp $MODEL_DIR/$MODEL $SLACKBUILD_TEMP

# Change Strings from model
start_build $SLACKBUILD_TEMP

# On/Off sections
activate_sections

# Change sections
section_edit

# Remove off sections
build_slackbuild

# Make slack-required file
make_slack_required

if [ -e slack-required ]; then
    DEPENDENCY_LIST="`cat slack-required | awk '{print $1}' | grep '^[a-z]' | tr '\012' ' '`"
    edit_file "REQUIRES" "$DEPENDENCY_LIST" $SLACKBUILD
fi

# Others changes
change_others_fields

# Clear temporary files
clear_files

[ $COMMIT -eq 1 ] && commit_slackbuild