Cleaned up and simplified create_package().

Signed-off-by: Andrew Fyfe <andrew@neptune-one.net>
This commit is contained in:
Andrew Fyfe 2007-04-11 20:05:47 +01:00 committed by Dan McGee
parent 5b4a4af94d
commit 7fb1dc3f20
1 changed files with 26 additions and 25 deletions

View File

@ -394,26 +394,25 @@ removedeps() {
} }
create_package() { create_package() {
# get some package meta info cd "$startdir"/pkg
builddate=$(LC_ALL= ; LANG= ; date -u "+%a %b %e %H:%M:%S %Y") msg "$(gettext "Creating package...")" # get some package meta info
local builddate=$(LC_ALL= LANG= date -u "+%a %b %e %H:%M:%S %Y")
if [ "$PACKAGER" != "" ]; then if [ "$PACKAGER" != "" ]; then
packager="$PACKAGER" local packager="$PACKAGER"
else else
packager="Arch Linux (http://www.archlinux.org)" local packager="Arch Linux (http://www.archlinux.org)"
fi fi
size=$(du -cb "$startdir/pkg" | tail -n 1 | awk '{print $1}') local size=$(du -sb | awk '{print $1}')
# build a filelist - do this first to keep meta files out of the list # build a filelist - do this first to keep meta files out of the list
msg "$(gettext "Generating .FILELIST file...")" msg2 "$(gettext "Generating .FILELIST file...")"
cd "$startdir/pkg" tar -cvf /dev/null * | sort >.FILELIST
tar cvf /dev/null * | sort >.FILELIST
# write the .PKGINFO file # write the .PKGINFO file
msg "$(gettext "Generating .PKGINFO file...")" msg2 "$(gettext "Generating .PKGINFO file...")"
cd "$startdir/pkg"
echo "# Generated by makepkg $myver" >.PKGINFO echo "# Generated by makepkg $myver" >.PKGINFO
echo -n "# " >>.PKGINFO echo "# $(LC_ALL= LANG= date -u)" >>.PKGINFO
date >>.PKGINFO
echo "pkgname = $pkgname" >>.PKGINFO echo "pkgname = $pkgname" >>.PKGINFO
echo "pkgver = $pkgver-$pkgrel" >>.PKGINFO echo "pkgver = $pkgver-$pkgrel" >>.PKGINFO
echo "pkgdesc = $pkgdesc" >>.PKGINFO echo "pkgdesc = $pkgdesc" >>.PKGINFO
@ -425,6 +424,7 @@ create_package() {
echo "arch = $CARCH" >>.PKGINFO echo "arch = $CARCH" >>.PKGINFO
fi fi
local it
for it in "${license[@]}"; do for it in "${license[@]}"; do
echo "license = $it" >>.PKGINFO echo "license = $it" >>.PKGINFO
done done
@ -454,31 +454,32 @@ create_package() {
plain "$(gettext "example for GPL\'ed software: license=(\'GPL\').")" plain "$(gettext "example for GPL\'ed software: license=(\'GPL\').")"
fi fi
local comp_files
# check for an install script # check for an install script
# TODO: should we include ${pkgname}.install if it exists and $install is unset?
if [ "$install" != "" ]; then if [ "$install" != "" ]; then
msg "$(gettext "Copying install script...")" msg2 "$(gettext "Copying install script...")"
cp "$startdir/$install" "$startdir/pkg/.INSTALL" cp "$startdir/$install" .INSTALL
comp_files="$comp_files .INSTALL"
fi fi
# do we have a changelog? # do we have a changelog?
have_changelog=0
if [ -f "$startdir/ChangeLog" ]; then if [ -f "$startdir/ChangeLog" ]; then
msg "$(gettext "Copying package changelog")" msg2 "$(gettext "Copying package changelog")"
cp "$startdir/ChangeLog" "$startdir/pkg/.CHANGELOG" cp "$startdir/ChangeLog" .CHANGELOG
have_changelog=1 comp_files="$comp_files .CHANGELOG"
fi fi
# tar it up # tar it up
msg "$(gettext "Compressing package...")" msg2 "$(gettext "Compressing package...")"
cd "$startdir/pkg"
pkg_file="$PKGDEST/$pkgname-$pkgver-$pkgrel-${CARCH}.${PKGEXT}" local pkg_file="$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT}"
comp_files=".PKGINFO .FILELIST ${install:+.INSTALL}" comp_files="$comp_files .PKGINFO .FILELIST"
[ $have_changelog -eq 1 ] && comp_files=".CHANGELOG $comp_files"
if ! tar czf $pkg_file $comp_files *; then if ! tar -czf "$pkg_file" $comp_files *; then
error "$(gettext "Failed to create package file.")" error "$(gettext "Failed to create package file.")"
exit 1 exit 1 # TODO: error code
fi fi
} }