From b14f4dfac2d5101cedb23ef6d92e93ff1df9feb9 Mon Sep 17 00:00:00 2001 From: "Tom G. Christensen" Date: Sat, 12 Apr 2008 13:43:47 +0000 Subject: [PATCH] Add relnotes facility The auto_rel function fills out a template and installs it in the stagedir Add access function to support extraction of VENDOR field value from a pkginfo file Small hack in check_unpackaged to sort out relnotes since we've not added that information in any metadata yet. --- buildpkg.packaging.solaris | 126 ++++++++++++++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 3 deletions(-) diff --git a/buildpkg.packaging.solaris b/buildpkg.packaging.solaris index 9eec1cf..d1512b1 100644 --- a/buildpkg.packaging.solaris +++ b/buildpkg.packaging.solaris @@ -20,7 +20,7 @@ strip_elf_args="" # GNU default is -g strip_shared_args="" # GNU default is --strip-unneeded strip_static_args="" # GNU default is -g -META_CLEAN="prototype prototype.in pkginfo files.tmp depend.*.auto depend.*.all" +META_CLEAN="prototype prototype.in pkginfo files.tmp depend.*.auto depend.*.all sums" # Define defaults # pkginfo information. @@ -67,6 +67,9 @@ ignore_deps="" # Solaris doesn't know how to handle any kind of compressed manpages gzman=0 +# If not using gcc then please set this to 1 +suncc=0 + # Default configure args configure_args='--prefix=$prefix --mandir=${prefix}/${_mandir} --infodir=${prefix}/${_infodir}' @@ -316,6 +319,103 @@ add_dir() echo "$dir" >> $metadir/files.tmp } +# 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/${metainstalldir}relnotes/$topdir-$version-$pkgver.txt +auto_rel() +{ + local i + local rn + + for i in relnotes relnotes.${_os} + do + [ -r ${metadir}/${i} ] && rn=$i + done + if [ -r ${metadir}/${rn} ]; then + local relmetadir=${stagedir}${metainstalldir}relnotes/$topdir-$version-$pkgver + ### compute configure info for relnotes + local cf="$(_upls $configure_args)" + [ -n "$ac_overrides" ] && local aco="$(for ar in $ac_overrides; do echo $ar; done | $AWK '{ printf "%s \\\\ \\n",$0 }')" + local temp_fullcf="$(echo "$__configure $cf" | $AWK '{ printf "%s\\n",$0 }')" + temp_fullcf="$(echo "${aco}${temp_fullcf}")" + # Remove trailing whitespace and \n + local fullcf="${temp_fullcf%\\*}" + ### + ### compute compiler info for relnotes + if [ $suncc -eq 0 ]; then + #local compiler_temp="$(gcc --version 2>&1 | $SED -n '1,1p')" + #local compiler="gcc ${compiler_temp##* }" + local compiler="$(gcc -v 2>&1 | $SED -n '/^gcc/ s/ version//p')" + else # not gcc + local compiler="$(cc -version 2>&1)" + if [ "$CXX" = "g++" ]; then + # SUN cc with gnu g++ + local compiler_temp="$(g++ --version 2>&1 | $SED -n '1,1p')" + local compiler="$((echo $compiler; echo g++ ${compiler_temp##* }) | $AWK '{ printf "%s\\n",$0 }')" + local compiler="${compiler%\\*}" + fi + fi + ### + local pkgnam=$(get_pkgname $relnotes_secname) + local vendor=$(get_pkgvendor $relnotes_secname) + local packager="${pkgedby} <${email}>" + ### Compute SHA1 sums for all source entries + local s + local path + local file + local source_sha1sum + local temp_source_sha1sum="" + # older bash 2.x doesn't like C-style for loops (observed on Solaris 2.x) + #for ((s=0; $s < ${#source[@]}; s++)) + local s=0 + while [ $s -lt ${#source[@]} ] + do + # A little snip from buildpkg.functions:unpack + if [ "${source[$s]:0:1}" != "/" ]; then # We have a relative pathname + # expand to absolute + [ -r "$srcdir/${source[$s]}" ] && source[$s]="$srcdir/${source[$s]}" + [ -r "$srcfiles/${source[$s]}" ] && source[$s]="$srcfiles/${source[$s]}" + fi # We are now sure that ${source[$s]} contains file with absolute path + # To avoid recording an absolute path in the sha1sum output that gets inserted + # into relnotes we cd first then run sha1sum + path="${source[$s]%/*}" # Extract path part + file="${source[$s]##*/}" # Extract filename part + (cd "$path"; $SHA1SUM "$file") >> $metadir/sums + let s=s+1 + done + [ -r "$metadir/sums" ] && temp_source_sha1sum="$(cat $metadir/sums | $AWK '{ printf "%s\\n",$0 }')" + source_sha1sum="${temp_source_sha1sum%\\*}" + ### End of SHA1 sum computing + ### Extract environtment variables + local temp_extracted_env="$($SED -e 's/export /echo ENV /g' ${buildpkgbase}/${pkgdir}/build.sh >> /tmp/env.sh; bash /tmp/env.sh|$GREP ^ENV|$SED -e 's/ENV //g'|$AWK '{ printf "%s\\n",$0 }' && $RM -f /tmp/env.sh)" + # Remove trailing \n + local extracted_env="${temp_extracted_env%\\*}" + ### + ### Add dependencies + local temp_deps="$($CAT $metadir/depend.*.all | $GREP -v 'REV=' | $SORT -u | $AWK '{ printf "%s\\n",$0 }')" + local deps="${temp_deps%\\*}" + ### + $MKDIR -p $relmetadir + $GSED -e "s;%%PKGNAME%%;${pkgnam};g" \ + -e "s;%%SOURCE_AND_VER%%;${topdir}-${version};g" \ + -e "s;%%CONFIGURE%%;${fullcf};g" \ + -e "s;%%COMPILER%%;${compiler};g" \ + -e "s;%%VENDOR%%;${vendor};g" \ + -e "s;%%PKGEDBY%%;${packager};g" \ + -e "s;%%SOURCE_SHA1SUM%%;${source_sha1sum};g" \ + -e "s;%%ENVIRONMENT%%;${extracted_env};g" \ + -e "s;%%DEPENDENCIES%%;${deps};g" \ + ${metadir}/${rn} > "$relmetadir/${topdir}.txt" + + ### Add the relnotes to the prototype file + #add_dir $defaultperms $defaultuid $defaultgid "relnotes/$topdir-$version-$pkgver" $relnotes_secname # Add dir entry + add_proto $defaultperms $defaultuid $defaultgid "relnotes" $relnotes_secname + else + echo "auto_rel: No release notes found!" + fi +} + # dep_pkg_name: Given a filename it will look it up and find the PKGNAME # Params: A list of filenames # For each file we use pkgchk -l -p to find the package containing it @@ -501,6 +601,8 @@ parse_def() legalend=0 # Set default value for maxinst for the new section maxinst=1 + # By default relnotes will end up in the first package section found + [ -z "$relnotes_secname" ] && relnotes_secname=$secname fi ;; '') @@ -591,7 +693,7 @@ check_unpackaged() $FIND . -type d -print|$SED -e 's/\.\///g'|$GREP -v '^\.' >> $tmpdir/files.tmp $SORT $metadir/files.tmp|$UNIQ > $tmpdir/f1 $SORT $tmpdir/files.tmp > $tmpdir/f2 - upf="$($CAT $tmpdir/f1 $tmpdir/f2 | $SORT | $UNIQ -u)" + upf="$($CAT $tmpdir/f1 $tmpdir/f2 | $SORT | $SED -e '/^relnotes/d' | $UNIQ -u)" if [ ! -z "$upf" ]; then echo "There are unpackaged files in the stagedir:" for i in $upf @@ -654,6 +756,18 @@ get_pkgdesc() fi } +# get_pkgvendor(): Extract upstram vendor information from a pkginfo file +# params: $1 = metafile suffix +get_pkgvendor() +{ + local secname=$1 + + if [ -r $metadir/pkginfo.$secname ]; then + local pv=$($SED -n 's/VENDOR=\(.*\) - .*/\1/p' $metadir/pkginfo.$secname | $TR -d '"') + echo $(_upls $pv) + fi +} + # do_strip_bin(): Strip binaries # params: none do_strip_bin() @@ -717,7 +831,10 @@ generic_pack() setdir ${stagedir}${topinstalldir}${dir_prefix}/${_infodir} [ "$gzinfo" -eq 1 ] && compress_info fi - #setdir "${stagedir}${prefix}" + # We need to add slash to the end of metainstalldir but *only* if + # metainstalldir is not /. We do this to avoid creating an absolute path + # which could happen with metainstalldir=/ if we unconditionally add /. + [ ! "$metainstalldir" = "/" ] && metainstalldir="${metainstalldir}/" # pkgdef should list files relative to topinstalldir setdir "${stagedir}${topinstalldir}" parse_def @@ -727,6 +844,9 @@ generic_pack() do auto_deps $i add_scripts $i + # auto_rel should only run once, when relnotes_secname comes up + # however it depends on depend.*.all generated above so must be inside the loop + [ "$i" = "$relnotes_secname" ] && auto_rel make_pkg $i done }