From ec325c188bdb4397a8289fc51decce4318c89a7f Mon Sep 17 00:00:00 2001 From: "Tom G. Christensen" Date: Thu, 15 Jul 2004 12:42:31 +0000 Subject: [PATCH] Redefine the meaning of the topdir variable. From now on pkgdir will be used to designate the toplevel dir of the pkg under $BUILDPKG_BASE Irix specific changes: Source formatting fixes Finally get rid of the FIXME on imageconf Automatically handle opt.src and opt.relnotes subsystems --- buildpkg.functions | 14 ++--- buildpkg.packaging.irix | 101 ++++++++++++++++++++++++++++++------- buildpkg.packaging.solaris | 4 +- 3 files changed, 92 insertions(+), 27 deletions(-) diff --git a/buildpkg.functions b/buildpkg.functions index 4f2be71..84b865a 100644 --- a/buildpkg.functions +++ b/buildpkg.functions @@ -15,8 +15,7 @@ fi # Variables that *must* be overridden pr. package # They are used to construct paths and more so they # must have sane values -# topdir= The toplevel dir name under $buildpkgbase -# It is also used pr. default in the pkgname +# topdir= The default package dirname, it's used pr. default in pkgname # and it is also used pr. default as the toplevel name inside the sourcetar ($topsrcdir) # version= source version ie. 0.14.2b # pkgver= the package revision, an increasing number is recommended but a date could be used instead @@ -71,11 +70,12 @@ NROFF=/usr/local/bin/nroff NROFFOPTS="-c -man" # Define defaults +pkgdir=${PWD##*/} # topdir under $BUILDPKG_BASE buildpkgbase=$BUILDPKG_BASE -stagedir=$buildpkgbase/$topdir/stage -srcdir=$buildpkgbase/$topdir/src +stagedir=$buildpkgbase/$pkgdir/stage +srcdir=$buildpkgbase/$pkgdir/src patchdir=$srcdir # Allow the possibility of easily putting a load of patches in a different location -metadir=$buildpkgbase/$topdir/meta +metadir=$buildpkgbase/$pkgdir/meta distdir=$buildpkgbase/distfiles/beta topsrcdir=$topdir-$version # it may be necessary to override this @@ -302,8 +302,8 @@ clean() do META_CLEAN="$META_CLEAN prototype.$secname pkginfo.$secname" pkgname=$(get_pkgname $secname) - echo "Removing $buildpkgbase/$topdir/$pkgname" - $RM -rf $buildpkgbase/$topdir/$pkgname + echo "Removing $buildpkgbase/$pkgdir/$pkgname" + $RM -rf $buildpkgbase/$pkgdir/$pkgname done fi diff --git a/buildpkg.packaging.irix b/buildpkg.packaging.irix index c8bad32..feb5fbc 100644 --- a/buildpkg.packaging.irix +++ b/buildpkg.packaging.irix @@ -86,36 +86,36 @@ fix_ver() # param: $1=product name $2=description spec_header() { - echo "product $1" - echo "$indent4 id \"$2\"" + echo "product $1" + echo "$indent4 id \"$2\"" } spec_footer() { - echo "endproduct" + echo "endproduct" } # spec_img_header() # param: $1=image name $2=image description $3=version spec_img_header() { - local nver=$(fix_ver $3) - echo "$indent4 image $1" - echo "$indent8 id \"$2\"" - echo "$indent8 version $nver" - echo "$indent8 order 9999" + local nver=$(fix_ver $3) + echo "$indent4 image $1" + echo "$indent8 id \"$2\"" + echo "$indent8 version $nver" + echo "$indent8 order 9999" } # spec_img_footer() spec_img_footer() { - echo "$indent4 endimage" + echo "$indent4 endimage" } # spec_subsys_header() # param: $1=image $2=subsys $3=description spec_subsys_header() { - echo "$indent8 subsys $2 default" - echo "$indent12 id \"$3\"" - echo "$indent12 replaces self" - echo "$indent12 exp $pkgname.$1.$2" + echo "$indent8 subsys $2 default" + echo "$indent12 id \"$3\"" + echo "$indent12 replaces self" + echo "$indent12 exp $pkgname.$1.$2" } # spec_subsys_req_header() # param: none @@ -244,15 +244,25 @@ add_files() # fetch_imageconf(): Fetch a list of toplevel image entries with descriptions # params: none -# Discard the ones that we don't have any subsystems for FIXME! +# Discard the ones that we don't have any subsystems for fetch_imageconf() { - pctopidx=0 + local pctopidx=0 + local numloops=${#pc[@]} + local i=0 + while read image desc do - pctop[$pctopidx]=$image - pdtop[$pctopidx]=$desc - let "pctopidx = $pctopidx + 1" + for ((i=0; i < $numloops; i++)) + do + temp="${pc[$i]%%.*}" + if [ "$image" == "$temp" ]; then + pctop[$pctopidx]=$image + pdtop[$pctopidx]=$desc + let "pctopidx = $pctopidx + 1" + break # We found a match no need to loop further + fi + done done < $imageconf } @@ -372,6 +382,18 @@ create_idb() fetch_ops parse_def + # hackish - FIXME perhaps? + local pcpos=${#pc[@]} # First vacant position in the subsys list array $pc + if [ -d src ]; then # We have a srcdir which means we have patches, so add them to the idb file + add_files "src" opt.src - root sys "" + pc[$pcpos]="opt.src" + let "pcpos = pcpos + 1" + fi + if [ -d relnotes ]; then # We have releasenotes, add them to idb file + add_files "relnotes" opt.relnotes - root sys "" + pc[$pcpos]="opt.relnotes" + fi + $SORT +4u -6 < $idbfile > $metadir/idbtemp lines=$(wc -l < $metadir/idbtemp) if [ ! -z $firstop ]; then @@ -490,6 +512,8 @@ parse_def() local legalend=0 local index=0 local found=0 + local i=0 + local equalindex="" while read line do @@ -607,6 +631,45 @@ check_unpackaged() $RM -f $tmpdir/f1 $tmpdir/f2 } +# auto_src(): Automatically place any patches into the correct location for packaging +# params: none +# Grabs any patches and shoves them into $prefix/src/$topdir-$version-$pkgver +# for adding to the opt.src subsystem +auto_src() +{ + local distsrcdir="src/$topdir-$version-$pkgver" + $MKDIR -p $distsrcdir + + local numpatch=${#patch[@]} + local pnum=0 + for ((pnum=0; pnum < $numpatch; pnum++)) + do + if [ ! -z ${patch[$pnum]} ]; then # They didn't give us an empty string + if [ "${patch[$pnum]:0:1}" != "/" ]; then # We have a relative pathname + # expand to absolute + patch[$pnum]=$patchdir/${patch[$pnum]} + fi # We are now sure that $patch[$pnum] contains file with absolute path + echo "Processing patch[$pnum] - ${patch[$pnum]}" + if [ -r ${patch[$pnum]} ]; then # file is readable + $CP ${patch[$pnum]} $distsrcdir + else + error $E_BAD_FILE patch + fi + else + echo "Patch $pnum has empty filename" + fi + done +} + +# auto_rel(): Fix up and add releasenotes to stagedir +# params: none +# This will make some substitutions on a release note template +# and then copy the result to $stagedir/$prefix/relnotes/$topdir-$version-$pkgver.txt +auto_rel() +{ + echo "auto_rel() is unimplemented" +} + # generic_pack(): Build package using files from 'install' stage # params: $1 - indicating whether or not the root is complete as described below # We expect generic_install to have made $stagedir the "root" dir @@ -632,6 +695,8 @@ generic_pack() fi setdir $stagedir$topinstalldir fi + auto_src # Add any patches + auto_rel # Fix up and add releasenotes create_idb create_spec check_unpackaged diff --git a/buildpkg.packaging.solaris b/buildpkg.packaging.solaris index ea5b292..48fef47 100644 --- a/buildpkg.packaging.solaris +++ b/buildpkg.packaging.solaris @@ -71,8 +71,8 @@ make_pkg() local pname=$(get_pkgname $secname) echo "Creating package and transferring it to datastream format" - $PKGMK -r `pwd` -d $buildpkgbase/$topdir -o -f $metadir/$prototype - $PKGTRANS -o -s $buildpkgbase/$topdir $distdir/$dfile $pname + $PKGMK -r `pwd` -d $buildpkgbase/$pkgdir -o -f $metadir/$prototype + $PKGTRANS -o -s $buildpkgbase/$pkgdir $distdir/$dfile $pname echo "Done. Package was created as $dfile" }