Add helper functions to extract PKG and PSTAMP from pkginfo files
Fix list_pkgs so it actually works the way it was intended Fix make_pkg to use the fixed list_pkgs Remove old prototype function and PKGPROTO helper var Add 'depend' support to add_scripts Bash 2.03 needs (()) expansion in quotes in parse_def to avoid a syntax error Use $AWK instead of awk
This commit is contained in:
parent
552b58c24a
commit
d15a078371
@ -7,12 +7,11 @@
|
||||
# generic tools go in buildpkg.functions
|
||||
PKGMK=/usr/bin/pkgmk
|
||||
PKGTRANS=/usr/bin/pkgtrans
|
||||
PKGPROTO=/usr/bin/pkgproto
|
||||
|
||||
# Override generic location
|
||||
STRIP=/usr/ccs/bin/strip
|
||||
|
||||
META_CLEAN="prototype prototype.in pkginfo"
|
||||
META_CLEAN="prototype prototype.in pkginfo files.tmp"
|
||||
|
||||
# Define defaults
|
||||
# pkginfo information.
|
||||
@ -48,21 +47,19 @@ distfile='$secname-$version-$secver.sb-$os-$cpu-$pkgdirdesig'
|
||||
#####################################################
|
||||
|
||||
# make_pkg(): Create the final package
|
||||
# params: $1 = prototype filename
|
||||
# params: $1 = meta file suffix
|
||||
#
|
||||
make_pkg()
|
||||
{
|
||||
if [ $# -lt 1 ]; then
|
||||
error $E_MISSING_ARGS make_pkg
|
||||
fi
|
||||
local prototype=$($BASENAME $1)
|
||||
local secname=$1
|
||||
local prototype=prototype.$secname
|
||||
|
||||
local secname=${prototype##prototype.}
|
||||
local pstamp=$($GREP PSTAMP $metadir/pkginfo.$secname)
|
||||
local secver=$(_upls ${pstamp##PSTAMP=})
|
||||
local secver=$(get_pkgrev $secname)
|
||||
local dfile=$(_upls $distfile)
|
||||
local pn=$($GREP PKG $metadir/pkginfo.$secname)
|
||||
local pname=$(_upls ${pn##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
|
||||
@ -98,44 +95,16 @@ pack_info()
|
||||
# params: none
|
||||
list_pkgs()
|
||||
{
|
||||
for i in $metadir/prototype.*
|
||||
local i
|
||||
local it
|
||||
# We can't rely on shell expansion here since we would be burned if * is empty!
|
||||
for i in $($LS -1 $metadir/prototype.* 2>/dev/null)
|
||||
do
|
||||
echo ${i##prototype.}
|
||||
it=$($BASENAME $i)
|
||||
echo ${it##prototype.}
|
||||
done
|
||||
}
|
||||
|
||||
# prototype(): Create a prototype file for pkgmk
|
||||
# params: $1 = owner $2 = group $3 = [script|noscript]
|
||||
# $1 & $2 will list the owner and group that is to be applied to all files
|
||||
# pkginfo and depend (if it exists) will automatically be added to prototype file
|
||||
# $3 will define whether or not to automatically include any post/pre scripts found
|
||||
# in $topdir/meta. Pr. default postinstall,preinstall,postremove,preremove are the filenames
|
||||
# it will look for.
|
||||
# $3 can be omitted and in that case prototype will behave as if $3=noscript
|
||||
prototype()
|
||||
{
|
||||
local owner=$1
|
||||
local group=$2
|
||||
|
||||
$FIND . -print|$PKGPROTO > $metadir/prototype.in
|
||||
$CAT $metadir/prototype.in | $AWK -v owner="$owner" -v group="$group" \
|
||||
'{ $5=owner; $6=group; print; }' > $metadir/prototype
|
||||
|
||||
add_meta_file pkginfo "$metadir/pkginfo"
|
||||
|
||||
# If a dependency file is available then use it
|
||||
[ -r $metadir/depend -a $usedepend -eq 1 ] && add_meta_file depend "$metadir/depend"
|
||||
|
||||
case $3 in
|
||||
'script') [ -r $metadir/preinstall ] && add_meta_file preinstall "$metadir/preinstall"
|
||||
[ -r $metadir/postinstall ] && add_meta_file postinstall "$metadir/postinstall"
|
||||
[ -r $metadir/preremove ] && add_meta_file preremove "$metadir/preremove"
|
||||
[ -r $metadir/postremove ] && add_meta_file postremove "$metadir/postremove"
|
||||
;;
|
||||
'noscript') ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# add_meta_file(): add a metafile entry to the prototype file
|
||||
# params: $1 = keyword $2 = filename $3 = metafile suffix
|
||||
# Additions will be done to the file $metadir/prototype
|
||||
@ -160,6 +129,10 @@ add_scripts()
|
||||
error $E_MISSING_ARGS add_scripts
|
||||
fi
|
||||
local secname=$1
|
||||
|
||||
# If a dependency file is available then use it
|
||||
[ -r $metadir/depend.$secname -a $usedepend -eq 1 ] && add_meta_file depend "$metadir/depend.$secname" $secname
|
||||
|
||||
if [ $usescripts -eq 1 ]; then
|
||||
[ -r $metadir/preinstall.$secname ] && add_meta_file preinstall "$metadir/preinstall.$secname" $secname
|
||||
[ -r $metadir/postinstall.$secname ] && add_meta_file postinstall "$metadir/postinstall.$secname" $secname
|
||||
@ -291,10 +264,10 @@ parse_def()
|
||||
local section=0
|
||||
local foundfiles=0
|
||||
local secname=""
|
||||
local secpos=0
|
||||
|
||||
while read line
|
||||
do
|
||||
echo $line
|
||||
case ${line:0:1} in
|
||||
'#') ;;
|
||||
'[')
|
||||
@ -302,7 +275,7 @@ parse_def()
|
||||
error $E_BAD_SECTION_BEGIN parse_def
|
||||
else
|
||||
section=1
|
||||
secname=${line:1:((${#line}-2))}
|
||||
secname="${line:1:((${#line}-2))}"
|
||||
fi
|
||||
;;
|
||||
'')
|
||||
@ -341,9 +314,9 @@ parse_def()
|
||||
else # Perhaps we hit 'files'?
|
||||
if [ "${line:0:5}" == "files" ]; then
|
||||
triplet="${line:6:((${#line}-5-2))}"
|
||||
defaultperms=$(echo $triplet | awk -F, '{ print $1 }')
|
||||
defaultuid=$(echo $triplet | awk -F, '{ print $2 }')
|
||||
defaultgid=$(echo $triplet | awk -F, '{ print $3 }')
|
||||
defaultperms=$(echo $triplet | $AWK -F, '{ print $1 }')
|
||||
defaultuid=$(echo $triplet | $AWK -F, '{ print $2 }')
|
||||
defaultgid=$(echo $triplet | $AWK -F, '{ print $3 }')
|
||||
foundfiles=1
|
||||
pack_info $secname # Create pkginfo
|
||||
# Start the prototype file by adding the pkginfo file
|
||||
@ -374,11 +347,33 @@ check_unpackaged()
|
||||
$SORT $tmpdir/files.tmp > $tmpdir/f2
|
||||
if [ ! "$($CMP $tmpdir/f1 $tmpdir/f2)" == "" ]; then
|
||||
$RM -f $tmpdir/f1 $tmpdir/f2
|
||||
echo error $E_UNPACKAGED_FILES check_unpackaged
|
||||
error $E_UNPACKAGED_FILES check_unpackaged
|
||||
fi
|
||||
$RM -f $tmpdir/f1 $tmpdir/f2
|
||||
}
|
||||
|
||||
# get_pkgname(): Extract pkgname (PKG) from a pkginfo file
|
||||
# params: $1 = metafile suffix
|
||||
get_pkgname()
|
||||
{
|
||||
local secname=$1
|
||||
|
||||
local pn=$($GREP PKG $metadir/pkginfo.$secname)
|
||||
local pname=$(_upls ${pn##PKG=})
|
||||
echo $pname
|
||||
}
|
||||
|
||||
# get_pkgrev(): Extract pkgrev (PSTAMP) from pkginfo file
|
||||
# params: $1 = metafile suffix
|
||||
get_pkgrev()
|
||||
{
|
||||
local secname=$1
|
||||
|
||||
local pstamp=$($GREP PSTAMP $metadir/pkginfo.$secname)
|
||||
local secver=$(_upls ${pstamp##PSTAMP=})
|
||||
echo $secver
|
||||
}
|
||||
|
||||
#####################################################
|
||||
# Define generic functions for different build stages
|
||||
#####################################################
|
||||
@ -402,8 +397,6 @@ generic_pack()
|
||||
if [ "$ignore_unpackaged_files" -eq 0 ]; then
|
||||
check_unpackaged
|
||||
fi
|
||||
#pack_info
|
||||
#prototype root bin script
|
||||
# Create a list of all the packages that we are going to build
|
||||
for i in $(list_pkgs)
|
||||
do
|
||||
|
Loading…
x
Reference in New Issue
Block a user