aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/pkg
blob: c9f111ceba620cbf253ef0bb3099ccac438e2603 (plain) (blame)
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
#!/bin/bash
#
# /usr/sbin/pkg - Formilux source package manager - version 0.2.3 - 2003-03-20
#
# Copyright (C) 2001-2003 Benoit Dolez & Willy Tarreau
#       mailto: benoit@ant-computing.com,willy@ant-computing.com
#
# This program is licenced under GPLv2 ( http://www.gnu.org/licenses/gpl.txt )

########## WARNING ##########
# this version is not compatible anymore with versions earlier than 0.2.0
#############################

# patch -p1 by default
PATCH_LEVEL=1

function logit {
  echo "$*"
  $*
  return $?
}

function do_compile_only {
  $FLXMAKE
  return $?
}

function pre_prepack {
  if [ "$UID" != "0" -a "$force" != "1" ]; then
    echo "You must specify '--force' to install as non-root"
    exit 1
  fi
  if [ -d `pwd`/.flxdisk ] ; then rm -rf `pwd`/.flxdisk ; fi
}

function post_prepack {
  if [ -d $ROOTDIR/opt ] ; then
    (cd $ROOTDIR/opt ; mkdir bin sbin lib )
    (cd $ROOTDIR/opt ; find */bin  -type f -perm +111 -exec ln -s ../{} bin  \; -printf "ln -s ../%p $ROOTDIR/opt/bin\n" )
    (cd $ROOTDIR/opt ; find */sbin -type f -perm +111 -exec ln -s ../{} sbin \; -printf "ln -s ../%p $ROOTDIR/opt/sbin\n" )
    (cd $ROOTDIR/opt ; find */lib  -type f -perm +111 -exec ln -s ../{} lib  \; -printf "ln -s ../%p $ROOTDIR/opt/lib\n" )
  fi
}

function do_compile {
  do_config_only && do_compile_only
}

function do_build {
  for i in clean compile prepack strip pack ; do
    if declare -f pre_$i > /dev/null ; then ( pre_$i ) ; fi
    if [ $? != 0 ] ; then break ; fi
    if declare -f do_$i > /dev/null ; then ( do_$i ) ; fi
    if [ $? != 0 ] ; then break ; fi
    if declare -f post_$i > /dev/null ; then ( post_$i ) ; fi
    if [ $? != 0 ] ; then break ; fi
  done
}

function do_delpack {
  if [ -d `pwd`/.flxdisk ] ; then rm -rf `pwd`/.flxdisk ; fi
}

function do_clean {
  make distclean || make mrproper || make clean
  ( do_delpack )
}

function do_edit {
  echo "Editing $CFGFILE..."
  vi $CFGFILE
}

function do_cat {
  cat $CFGFILE
}

function do_patch {
	find . -name '*.rej' -o -name '*~' | xargs rm -f

	for i in $PATCH_LIST; do
		patch -Np$PATCH_LEVEL < $CFGROOT/$CFGDIR/patches/$i
	done

	if [ -z "`find . -name '*.rej'`" ]; then
		find . -name '*~' | xargs rm -f
	fi
}

function do_unpatch {
	UNPATCH_LIST=""

	find . -name '*.rej' -o -name '*~' | xargs rm -f

	for i in $PATCH_LIST; do
		UNPATCH_LIST="$i $UNPATCH_LIST"
	done

	for i in $UNPATCH_LIST; do
		patch -RNp$PATCH_LEVEL < $CFGROOT/$CFGDIR/patches/$i
	done

	if [ -z "`find . -name '*.rej'`" ]; then
		find . -name '*~' | xargs rm -f
	fi
}

function get_perl_depend {
  filename=$1
        DEP=`grep "^\(.*['{\"]\)*[ 	]*\(require\|use\) \+['\"]*[a-zA-Z][a-z:/A-Z0-9-_]*[; '\"]" $filename | \
                sed -e 's/.*\(require\|use\) \+["'\'']\?\([^'\''" };]\+\)["'\'']\?/\2/g' \
                    -e 's/\([^]\+\)[^]*/ \1/g' | \
                sed 's@::@/@g'`
        if [ "x$DEP" != "x" ] ; then
          echo -n "$filename" >> $F
          for dep in $DEP ; do
            if [ "x${dep/*.*}" != "x" ] ; then
              echo -n " $dep.pm" >> $F
            else
              echo -n " $dep" >> $F
            fi
          done
          echo >> $F
        fi
}
 
function do_pack {  
    # use the file list when available
    if [ "$FILE_LIST" ]; then
	    do_pack_files
	    return $?
    fi

  if [ ! -d $ROOTDIR ] ; then export ROOTDIR=`pwd` ; fi
  cd $ROOTDIR

##  ( find lib -type l -name "lib*.so*" | xargs rm -f ; \
##  find usr/lib -type l -name "lib*.so*" | xargs rm -f ; \
##  ldconfig -nr . ) > /dev/null 2>&1
  ldconfig -nr . lib usr/lib > /dev/null 2>&1
  find . ! -type l | xargs touch -m

  F=$PKGROOT/$packver.dep

  rm -rf $F
  if [ -e $F.diff ] ; then cat $F.diff $F ; fi

  echo -n "Creating $F ... "
  touch $F
  find . -type f -o -type l | while read ; do
    case $REPLY in
      *.pm|*.pl|*.ph)
        get_perl_depend $REPLY
       ;;
      */man/man*/*.[0-9n])
        if [ "${REPLY/*gz}" ] ; then
          if [ -L $REPLY ] ; then
            LINK=`readlink $REPLY`
            rm $REPLY
            ln -s $LINK.gz $REPLY.gz
          else
            gzip -f -9 $REPLY
            chmod 644 $REPLY.gz
          fi
        fi
        echo "$REPLY \$MAN" >> $F
        ;;
      */info/*.info|*/info/*.info-[0-9]*)
        if [ "${REPLY/*gz}" ] ; then
          gzip -f -9 $REPLY
          chmod 644 $REPLY.gz
        fi
        echo "$REPLY \$INFO" >> $F
        ;;
      */sbin/*|*/bin/*|*/lib/*|*/libexec/*)
        flr="`file $REPLY`"
        case "$flr" in
          *\ shell\ *)
            echo "$REPLY `head -1 $REPLY| sed -e 's/^#\! *\([^ ]\+\).*/\1/'` \$SHELL">>$F
            ;;
          *perl\ commands*)
            echo "$REPLY `head -1 $REPLY| sed -e 's/^#\! *\([^ ]\+\).*/\1/'` ">>$F
            get_perl_depend $REPLY
            ;;
          *:\ symbolic\ link*)
            echo "$REPLY `echo $flr | cut -f5 -d' '`" >> $F
            ;;
          *\ ELF\ 32-bit\ LSB*dynamically\ linked*)
            echo "$REPLY `ldd $REPLY 2>/dev/null | grep -v 'statically linked' | awk '{print $1}' | tr '\012' ' '`" >> $F
            ;;
          *\ ELF\ 32-bit\ LSB*shared\ object*)
            echo "$REPLY `ldd $REPLY 2>/dev/null | grep -v 'statically linked' | awk '{print $1}' | tr '\012' ' '`" >> $F
            ;;
        esac
        ;;
    esac
  done
  echo "done."

  echo -n "Creating $PKGROOT/$packver.lst ... "
  (find . ! -type d -o -empty | cut -c3-| xargs flx sign --ignore-dot --no-depth > $PKGROOT/$packver.lst) > /dev/null 2>&1
  echo "done."

  F=$PKGROOT/$packver.$PKGSUFF
  echo -n "Creating $F ... "
  # we want everything, and directories only if they're empty. All this without './'
  # we shouldn't get an empty line since . should contain at least what we want to tar !
  find . ! -type d -o -empty | cut -c3- | tar -T - -cf - | gzip -9 >$F 2>/dev/null
  echo "done."

  if [ -n "$CFGFILE" ]; then
     F=$CFGROOT/$CFGDIR/$pack.$CFGSUFF
     echo -n "Creating $F ... "
     if [ "$F" != "$CFGFILE" ]; then cp -f "$CFGFILE" "$F"; echo "done." ; else echo "up to date."; fi
  fi
  
}

function do_unpack {  
  mkdir -p $ROOTDIR
  cd $ROOTDIR

  F=$PKGROOT/$packver.$PKGSUFF
  echo -n "Extracting $F into $ROOTDIR ... "
  tar zUxpf $F >/dev/null 2>&1
  echo "done."
}

# same as pack, except that it uses files in the current directory as the root
# entries, and that no strip, link nor compression is performed.
# Only entries listed in the file pointed to by variable FILE_LIST find their
# way to the archive.
function do_pack_files {  
##  ( find lib -type l -name "lib*.so*" | xargs rm -f ; \
##  find usr/lib -type l -name "lib*.so*" | xargs rm -f ; \
##  ldconfig -nr . ) > /dev/null 2>&1
  find . ! -type l | xargs touch -m

  F=$PKGROOT/$packver.dep

  # absurde ? : rm puis cat !
  rm -rf $F
  if [ -e $F.diff ] ; then cat $F.diff $F ; fi

  echo -n "Creating $F ... "
  touch $F
  find . -type f -o -type l | while read ; do
    case $REPLY in
      *.pm|*.pl|*.ph)
        get_perl_depend $REPLY
       ;;
      */man/man*/*.[0-9n])
        echo "$REPLY \$MAN" >> $F
        ;;
      */info/*.info|*/info/*.info-[0-9]*)
        echo "$REPLY \$INFO" >> $F
        ;;
      */sbin/*|*/bin/*|*/lib/*|*/libexec/*)
        flr="`file $REPLY`"
        case "$flr" in
          *\ shell\ *)
            echo "$REPLY `head -1 $REPLY| sed -e 's/^#\! *\([^ ]\+\).*/\1/'` \$SHELL">>$F
            ;;
          *perl\ commands*)
            echo "$REPLY `head -1 $REPLY| sed -e 's/^#\! *\([^ ]\+\).*/\1/'` ">>$F
            get_perl_depend $REPLY
            ;;
          *:\ symbolic\ link*)
            echo "$REPLY `echo $flr | cut -f5 -d' '`" >> $F
            ;;
          *\ ELF\ 32-bit\ LSB*dynamically\ linked*)
            echo "$REPLY `ldd $REPLY 2>/dev/null | grep -v 'statically linked' | awk '{print $1}' | tr '\012' ' '`" >> $F
            ;;
          *\ ELF\ 32-bit\ LSB*shared\ object*)
            echo "$REPLY `ldd $REPLY 2>/dev/null | grep -v 'statically linked' | awk '{print $1}' | tr '\012' ' '`" >> $F
            ;;
        esac
        ;;
    esac
  done
  echo "done."

  echo -n "Creating $PKGROOT/$packver.lst ... "
  # we try the special case of the '.' entry which is needed to set the root permissions.
  # this entry must be set as "." in FILE_LIST.
  if grep -q '^.[ 	]' $FILE_LIST; then
     set -- $(grep '^.[ 	]' $FILE_LIST)
     owner=${2%%:*}
     group=${2##*:}
     echo "d $3 $owner $group          0 -------------------------------- 0 ."
  fi > $PKGROOT/$packver.lst
  (flx sign --no-depth --ignore-dot `cut -f1 -d' ' $FILE_LIST|sed -e 's,/$,,'` >> $PKGROOT/$packver.lst) > /dev/null 2>&1
  echo "done."

  F=$PKGROOT/$packver.$PKGSUFF
  echo -n "Creating $F ... "

  # we want everything, and directories only if they're empty. All this without './'
  # we shouldn't get an empty line since . should contain at least what we want to tar !
  cut -f1 -d' ' $FILE_LIST|sed -e 's,/$,,' | tar -T - --no-recursion -cf - | gzip -9 >$F 2>/dev/null
  echo "done."

  if [ -n "$CFGFILE" ]; then
     F=$CFGROOT/$CFGDIR/$pack.$CFGSUFF
     echo -n "Creating $F ... "
     if [ "$F" != "$CFGFILE" ]; then cp -f "$CFGFILE" "$F"; echo "done." ; else echo "up to date."; fi
  fi
  
}

function do_strip {
  if [ ! -d $ROOTDIR ] ; then export ROOTDIR=`pwd` ; fi
  #find $ROOTDIR/. -type f | xargs file | grep ":.*executable.*not stripped" | cut -f1 -d: | xargs strip -x --strip-unneeded -R .note -R .comment > /dev/null 2>&1 
  # allow executable and shared (.so), but not relocatable (.o), both stripped or not stripped
  find $ROOTDIR/. -type f | xargs file | grep ":.*ELF.*\(executable\|\shared\).*stripped" | cut -f1 -d: | xargs strip -x --strip-unneeded -R .note -R .comment > /dev/null 2>&1 
  return 0
} 

function pre_pack {
  ( do_strip )
}

function usage {
  echo "Usage: pkg <action>"
  echo " action is one of :"
  echo "   help    : display this help."
  echo "   info    : get information on current package."
  echo "   newpkg  : build a more recent .pkg script from an old one."
  echo "   cat     : display last .pkg file."
  echo "   edit    : edit last .pkg file."
  echo "   patch   : apply a list of patches to the directory prior to compile."
  echo "   unpatch : revert a list of patches to the directory."
  echo "   compile : do_compile=do_config_only+do_compile_only in .pkg script ($CFGROOT/$CFGDIR)"
  echo "   prepack : execute do_prepack in .pkg script ($CFGROOT/$CFGDIR)"
  echo "   strip   : strip binaries in temporary directory"
  echo "   pack    : strip binaries, then package into $PKGROOT"
  echo "   delpack : remove temporary directory"
  echo "   clean   : execute 'make clean' and remove temporary directory."
  echo "   build   : execute clean compile prepack pack."
  echo "   unpack  : extract package into temporary directory"
  echo "Variables are :"
  echo "CFGROOT : directory for .pkg and patches, <$CFGROOT>"
  echo "CFGFILE : force to use of a .pkg, <$CFGFILE>"
  echo "PKGROOT : directory for .lst, .tgz and .dep, <$PKGROOT>"
  echo "ROOTDIR : base directory for package (not source), <$ROOTDIR>"
  echo "FLXARCH : architecture for package name, <$FLXARCH>"
  echo "KERNDIR : base directory for package (not source), <$KERNDIR>"
  echo "DISTVER : build version (flx.1)"
  exit 1
}

function do_help {
	usage
}

function pre_info {
  echo "Information for package $pack: "

  echo "   Package version : $PKGVER (\$PKGVER)"
  echo "   Distrib version : $DISTVER (\$DISTVER)"
  echo -n "   Config. file : "
  if [ -e $CFGFILE ]; then
     echo "$CFGFILE"
  else
     echo "none found."
  fi
  echo "   Package file : $PKGROOT/$packver.$PKGSUFF"
  echo -n "   Package size : "
  if [ -e $PKGROOT/$packver.$PKGSUFF ]; then
     echo "`du -b $PKGROOT/$packver.$PKGSUFF|cut -f1` bytes."
  else
     echo "does not exist yet."
  fi
  if [ "$PATCH_LIST" ]; then
     echo "   Patches list : $PATCH_LIST"
  fi
}

function do_newpkg {
  echo "WARNING!!! the 'newpkg' feature is in beta stage !!!"
  if [ -n "$CFGFILE" ]; then
     F=$CFGROOT/$PKGRADIX-$PKGVER-$DISTVER-pkg/$pack.$CFGSUFF
     echo -n "Creating $F ... "
     if [ "$F" != "$CFGFILE" ]; then
        mkdir -p $CFGROOT/$PKGRADIX-$PKGVER-$DISTVER-pkg && cp -f "$CFGFILE" "$F" &&
          cp -af $CFGROOT/$CFGDIR/patches $CFGROOT/$PKGRADIX-$PKGVER-$DISTVER-pkg/ >/dev/null 2>&1
        echo "done."
     else
        echo "up to date."
     fi
  fi
}

# setting fixed vars
if [ -z "$KERNDIR" ] ; then KERNDIR="/usr/src/linux" ; fi
if [ -z "$CFGROOT" ] ; then CFGROOT="/var/flx-src" ; fi
if [ -z "$PKGROOT" ] ; then PKGROOT="/var/flx-pkg" ; fi
#if [ -z "$DISTVER" ] ; then DISTVER="flx.1" ; fi
if [ "$FLXARCH" = "" ]; then FLXARCH=`uname -m` ; fi

PKGSUFF="tgz"
CFGSUFF="pkg"
exe=`basename $0`

# check for action type
echo $exe | grep -q "^pkg" 
if [ $? = 0 -a "$exe" != "pkg" ] ; then
  type=`echo $exe | cut -c4-`
else
  type=$1
fi

# look for parameters
if [ "$type" = "$1" -a "${type##-*}" ] ; then shift ; fi
case $1 in 
  --force ) force=1; shift ;;
  --help ) usage ;;
  --source) type=source_only ;;
  -* ) shift ;;
esac

if [ "$type" = "" ] ; then
  usage ; 
fi

# execute action
if [ "$type" = "find" ] ; then
  for i in * ; do 
    pkgf=`grep "/$i\$" $CFGROOT/$CFGDIR/*.$CFGSUFF | cut -f1 -d: | tr '\012' ' '`
    echo "$i: $pkgf"
  done
elif [ "$type" != "source_only" ] ; then
 ARGV=$* 

 # look for package name from directory name
 pack=`pwd`
 pack=`basename $pack | sed -e 's/[-_][0-9].*$//'`

 # for package
  if [ -n "$pack" ] ; then 
   
    packver=`pwd` 
    packver=`basename $packver`

    if [ -z "$DISTVER" ]; then
        if echo $packver | grep -q -- "-flx\." ; then
	   DISTVER=`echo $packver|sed 's/\(.*-\)\(flx.[0-9]\+\)\(.*\)/\2/'`
	fi
    fi

    # source configuration
    if [ -z "$ROOTDIR" ] ; then ROOTDIR=`pwd`/.flxdisk ; fi
    if [ -n "$CFGFILE" ]; then
       CFGDIR=`dirname $CFGFILE`
       CFGROOT=`dirname $CFGDIR`
       CFGDIR=`basename $CFGDIR`
       . $CFGFILE
    else
       #CFGFILE=`find $CFGROOT/ -name "$pack[-_]*-${DISTVER:-*}-$FLXARCH.$CFGSUFF"|sed -e "s/\.$CFGSUFF\$//"|sort|tail -1`
       #CFGFILE=${CFGFILE:-`find $CFGROOT/ -name "$pack[-_]*-${DISTVER:-*}-*.$CFGSUFF"|sed -e "s/\.$CFGSUFF\$//"|sort|tail -1`}
       #CFGFILE=${CFGFILE:-`find $CFGROOT/ -name "$pack[-_]*.$CFGSUFF"|sed -e "s/\.$CFGSUFF\$//"|sort|tail -1`}
       #CFGFILE=${CFGFILE:-`find $CFGROOT/ -name "$pack.$CFGSUFF"|sed -e "s/\.$CFGSUFF\$//"|sort|tail -1`}
       CFGFILE=`find $CFGROOT/ -maxdepth 1 -type d -name "$pack[-_]*-${DISTVER:-*}-pkg"|sed -e "s/-pkg\$//"|sort|tail -1`
       CFGFILE=${CFGFILE:-`find $CFGROOT/ -maxdepth 1 -type d -name "$pack[-_]*-pkg"|sed -e "s/-pkg\$//"|sort|tail -1`}
       CFGFILE=${CFGFILE:-`find $CFGROOT/ -maxdepth 1 -type f -name "$pack[-_]*-${DISTVER:-*}-pkg.$PKGSUFF"|sed -e "s/-pkg\.$PKGSUFF\$//"|sort|tail -1`}
       CFGFILE=${CFGFILE:-`find $CFGROOT/ -maxdepth 1 -type f -name "$pack[-_]*-pkg.$PKGSUFF"|sed -e "s/-pkg\.$PKGSUFF\$//"|sort|tail -1`}

       # to be completed

       if [ -z "$CFGFILE" ]; then
          echo "CFGFILE not found. Cannot continue." >&2
          exit 1
       fi

       if [ -d $CFGFILE ]; then
          CFGROOT=`dirname $CFGFILE`
          CFGDIR=`basename $CFGFILE`-pkg
          CFGFILE=$CFGROOT/$CFGDIR/$pack.$CFGSUFF
       else
          CFGROOT=`dirname $CFGFILE`
          CFGDIR=`basename $CFGFILE`-pkg
          CFGFILE=$CFGROOT/$CFGDIR/$pack.$CFGSUFF
          if [ ! -e $CFGROOT/$CFGDIR ]; then
             echo "Opening package $CFGROOT/$CFGDIR.$PKGSUFF into $CFGROOT/$CFGDIR..."
             mkdir -p $CFGROOT/$CFGDIR && tar -C $CFGROOT/$CFGDIR -Uxpf $CFGROOT/$CFGDIR.$PKGSUFF
             if [ $? != 0 ]; then
                echo "There was an error during this operation. You may have to manually clean $CFGROOT/$CFGDIR. Cannot continue !"
                exit 1
             else
                echo "Done !"
             fi
          fi
       fi

       if [ -e "$CFGFILE" ]; then
          . $CFGFILE
       else
          echo "CFGFILE ($CFGFILE) not found. Cannot continue." >&2
          exit 1
       fi
    fi

    if [ -z "$DISTVER" ]; then
	if echo $CFGFILE | grep -q -- "-flx\." ; then
           DISTVER=`echo $CFGFILE|sed 's/\(.*-\)\(flx.[0-9]\+\)\(.*\)/\2/'`
        else
	   DISTVER='flx.1'
	fi
    fi

    echo $packver | grep -q -- "-flx\."
    if [ $? != 0 ] ; then
	packver=$packver-$DISTVER
    fi

    echo $packver | grep -q -- "-$FLXARCH\$" 
    if [ $? != 0 ] ; then packver=$packver-$FLXARCH ; fi

    prefix=${packver%%[._-][0-9]*} 
    suffix=${packver#$prefix[._-]} 
    PKGVER=${suffix%-flx*}
    PKGRADIX=$prefix
    #echo "packver=$packver suffix=$suffix PKGVER=$PKGVER"
    if [ -z "$DISTVER" ]; then
       DISTVER=${suffix#$PKGVER-}
       if [ "$DISTVER" = "$PKGVER" ]; then
	  DISTVER="flx.1"
       else
          DISTVER=${DISTVER%-*}
       fi
    fi

    case "$FLXARCH" in
        i686) arch=i686 cpu=i686 basearch=i386 ;;
        i486) arch=i486 cpu=i486 basearch=i386 ;;
        i386) arch=i386 cpu=i386 basearch=i386 ;;
        *)    arch=i586 cpu=i686 basearch=i386 ;;
    esac

    if [ -z "$FLXMAKE" ]; then
        FLXMAKE=make
    fi

    
    if [ -z "$PATCH_LIST" ]; then
	PATCH_LIST=${CFGFILE%%.$CFGSUFF}.diff
	if [ ! -e "$PATCH_LIST" ]; then
	    unset PATCH_LIST
	fi
    fi

    export DISTVER PKGRADIX PKGVER FLXMAKE PATCH_LIST FILE_LIST
 
    if declare -f pre_$type > /dev/null ; then ( pre_$type ) ; fi
    if [ $? != 0 ] ; then exit ; fi   
    if declare -f do_$type > /dev/null ; then ( do_$type ) ; fi
    if [ $? != 0 ] ; then exit ; fi
    if declare -f post_$type > /dev/null ; then ( post_$type ) ; fi

  fi
 # done
fi