[pacman-dev] [PATCH 2/9] Cleaned up and simplified create_package().
Andrew Fyfe
andrew at neptune-one.net
Sun Apr 1 18:49:54 EDT 2007
Signed-off-by: Andrew Fyfe <andrew at neptune-one.net>
diff --git a/scripts/makepkg.in b/scripts/makepkg.in
index 59f6d99..5ec5e03 100755
--- a/scripts/makepkg.in
+++ b/scripts/makepkg.in
@@ -357,26 +357,26 @@ removedeps() {
}
create_package () {
+ cd "$startdir"/pkg
+ msg "$(gettext "Creating package...")"
+
# get some package meta info
- builddate=$(LC_ALL= ; LANG= ; date -u "+%a %b %e %H:%M:%S %Y")
+ local builddate=$(LC_ALL= LANG= date -u "+%a %b %e %H:%M:%S %Y")
if [ "$PACKAGER" != "" ]; then
- packager="$PACKAGER"
+ local packager="$PACKAGER"
else
- packager="Arch Linux (http://www.archlinux.org)"
+ local packager="Arch Linux (http://www.archlinux.org)"
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
- msg "$(gettext "Generating .FILELIST file...")"
- cd "$startdir/pkg"
- tar cvf /dev/null * | sort >.FILELIST
+ msg2 "$(gettext "Generating .FILELIST file...")"
+ tar -cvf /dev/null * | sort >.FILELIST
# write the .PKGINFO file
- msg "$(gettext "Generating .PKGINFO file...")"
- cd "$startdir/pkg"
+ msg2 "$(gettext "Generating .PKGINFO file...")"
echo "# Generated by makepkg $myver" >.PKGINFO
- echo -n "# " >>.PKGINFO
- date >>.PKGINFO
+ echo "# $(LC_ALL= LANG= date -u)" >>.PKGINFO
echo "pkgname = $pkgname" >>.PKGINFO
echo "pkgver = $pkgver-$pkgrel" >>.PKGINFO
echo "pkgdesc = $pkgdesc" >>.PKGINFO
@@ -388,6 +388,7 @@ create_package () {
echo "arch = $CARCH" >>.PKGINFO
fi
+ local it
for it in "${license[@]}"; do
echo "license = $it" >>.PKGINFO
done
@@ -417,31 +418,32 @@ create_package () {
plain "$(gettext "example for GPL\'ed software: license=(\'GPL\').")"
fi
+ local comp_files
+
# check for an install script
+ # TODO: should we include ${pkgname}.install if it exists and $install is unset?
if [ "$install" != "" ]; then
- msg "$(gettext "Copying install script...")"
- cp "$startdir/$install" "$startdir/pkg/.INSTALL"
+ msg2 "$(gettext "Copying install script...")"
+ cp "$startdir/$install" .INSTALL
+ comp_files="$comp_files .INSTALL"
fi
# do we have a changelog?
- have_changelog=0
if [ -f "$startdir/ChangeLog" ]; then
- msg "$(gettext "Copying package changelog")"
- cp "$startdir/ChangeLog" "$startdir/pkg/.CHANGELOG"
- have_changelog=1
+ msg2 "$(gettext "Copying package changelog")"
+ cp "$startdir/ChangeLog" .CHANGELOG
+ comp_files="$comp_files .CHANGELOG"
fi
# tar it up
- msg "$(gettext "Compressing package...")"
- cd "$startdir/pkg"
+ msg2 "$(gettext "Compressing package...")"
- pkg_file="$PKGDEST/$pkgname-$pkgver-$pkgrel-${CARCH}.${PKGEXT}"
- comp_files=".PKGINFO .FILELIST ${install:+.INSTALL}"
- [ $have_changelog -eq 1 ] && comp_files=".CHANGELOG $comp_files"
+ local pkg_file="$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKGEXT}"
+ comp_files="$comp_files .PKGINFO .FILELIST"
- if ! tar czf $pkg_file $comp_files *; then
+ if ! tar -czf "$pkg_file" $comp_files *; then
error "$(gettext "Failed to create package file.")"
- exit 1
+ exit 1 # TODO: error code
fi
}
--
1.5.0.6
More information about the pacman-dev
mailing list