summaryrefslogtreecommitdiff
path: root/contrib/bacman.in
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bacman.in')
-rwxr-xr-xcontrib/bacman.in278
1 files changed, 138 insertions, 140 deletions
diff --git a/contrib/bacman.in b/contrib/bacman.in
index fe13e5b9..cb1aa10b 100755
--- a/contrib/bacman.in
+++ b/contrib/bacman.in
@@ -27,62 +27,62 @@ readonly progver="0.2.1"
# User Friendliness
#
function usage(){
- echo "This program recreates a package using pacman's db and system files"
- echo "Usage: $progname <installed package name>"
- echo "Example: $progname kernel26"
+ echo "This program recreates a package using pacman's db and system files"
+ echo "Usage: $progname <installed package name>"
+ echo "Example: $progname kernel26"
}
if [ $# -ne 1 ] ; then
- usage
- exit 1
+ usage
+ exit 1
fi
if [ "$1" = "--help" -o "$1" = "-h" ] ; then
- usage
- exit 0
+ usage
+ exit 0
fi
if [ "$1" = "--version" -o "$1" = "-v" ]; then
- echo "$progname version $progver"
- echo "Copyright (C) 2008 locci"
- exit 0
+ echo "$progname version $progver"
+ echo "Copyright (C) 2008 locci"
+ exit 0
fi
#
# Fakeroot support
#
if [ $EUID -gt 0 ]; then
- if [ -f /usr/bin/fakeroot ]; then
- echo "Entering fakeroot environment"
- export INFAKEROOT="1"
- /usr/bin/fakeroot -u -- $0 $1
- exit $?
- else
- echo "WARNING: installing fakeroot or running ${progname} as root is required to"
- echo " preserve the ownership permissions of files in some packages"
- echo ""
- fi
+ if [ -f /usr/bin/fakeroot ]; then
+ echo "Entering fakeroot environment"
+ export INFAKEROOT="1"
+ /usr/bin/fakeroot -u -- $0 $1
+ exit $?
+ else
+ echo "WARNING: installing fakeroot or running ${progname} as root is required to"
+ echo " preserve the ownership permissions of files in some packages"
+ echo ""
+ fi
fi
#
# Setting environmental variables
#
if [ ! -r @sysconfdir@/pacman.conf ]; then
- echo "ERROR: unable to read @sysconfdir@/pacman.conf"
- exit 1
+ echo "ERROR: unable to read @sysconfdir@/pacman.conf"
+ exit 1
fi
eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf)
pac_db="${DBPath:-@localstatedir@/lib/pacman/}/local"
if [ ! -r @sysconfdir@/makepkg.conf ]; then
- echo "ERROR: unable to read @sysconfdir@/makepkg.conf"
- exit 1
+ echo "ERROR: unable to read @sysconfdir@/makepkg.conf"
+ exit 1
fi
source "@sysconfdir@/makepkg.conf"
if [ -r ~/.makepkg.conf ]; then
- source ~/.makepkg.conf
+ source ~/.makepkg.conf
fi
pkg_arch=${CARCH:-'unknown'}
@@ -97,13 +97,13 @@ pkg_namver="${pkg_dir##*/}"
# Checks everything is in place
#
if [ ! -d "$pac_db" ] ; then
- echo "ERROR: pacman database directory ${pac_db} not found"
- exit 1
+ echo "ERROR: pacman database directory ${pac_db} not found"
+ exit 1
fi
if [ ! -d "$pkg_dir" ] ; then
- echo "ERROR: package ${pkg_name} not found in pacman database"
- exit 1
+ echo "ERROR: package ${pkg_name} not found in pacman database"
+ exit 1
fi
#
@@ -120,45 +120,43 @@ echo "Copying package files..."
cat "$pkg_dir"/files |
while read i; do
- if [ -z "$i" ] ; then
- continue
- fi
-
- if [[ "$i" =~ %[A-Z]*% ]] ; then
- current=$i
- continue
- fi
-
- case $current in
- %FILES%)
- ret=0
- if [ -e "/$i" ]; then
- bsdtar -cnf - "/$i" 2> /dev/null | bsdtar -xpf -
-
- # Workaround to bsdtar not reporting a missing file as an error
- if [ ! -e "$work_dir/$i" -a ! -L "$work_dir/$i" ]; then
- echo ""
- echo "ERROR: unable to add /$i to the package"
- echo " If your user does not have permssion to read this file then"
- echo " you will need to run $progname as root"
- rm -rf "$work_dir"
- exit 1
- fi
- else
- echo ""
- echo "WARNING: package file /$i is missing"
- echo ""
- fi
-
-
- ;;
- esac
+ if [ -z "$i" ] ; then
+ continue
+ fi
+
+ if [[ "$i" =~ %[A-Z]*% ]] ; then
+ current=$i
+ continue
+ fi
+
+ case $current in
+ %FILES%)
+ ret=0
+ if [ -e "/$i" ]; then
+ bsdtar -cnf - "/$i" 2> /dev/null | bsdtar -xpf -
+
+ # Workaround to bsdtar not reporting a missing file as an error
+ if [ ! -e "$work_dir/$i" -a ! -L "$work_dir/$i" ]; then
+ echo ""
+ echo "ERROR: unable to add /$i to the package"
+ echo " If your user does not have permssion to read this file then"
+ echo " you will need to run $progname as root"
+ rm -rf "$work_dir"
+ exit 1
+ fi
+ else
+ echo ""
+ echo "WARNING: package file /$i is missing"
+ echo ""
+ fi
+ ;;
+ esac
done
ret=$?
if [ $ret -ne 0 ]; then
- rm -rf "$work_dir"
- exit 1
+ rm -rf "$work_dir"
+ exit 1
fi
pkg_size=$(du -sk | awk '{print $1 * 1024}')
@@ -169,87 +167,87 @@ pkg_size=$(du -sk | awk '{print $1 * 1024}')
echo Generating .PKGINFO metadata...
echo "# Generated by $progname $progver" > .PKGINFO
if [ "$INFAKEROOT" = "1" ]; then
- echo "# Using $(fakeroot -v)" >> .PKGINFO
+ echo "# Using $(fakeroot -v)" >> .PKGINFO
fi
echo "# $(LC_ALL=C date)" >> .PKGINFO
echo "#" >> .PKGINFO
cat "$pkg_dir"/{desc,files} |
while read i; do
- if [[ -z "$i" ]]; then
- continue;
- fi
-
- if [[ "$i" =~ %[A-Z]*% ]] ; then
- current=$i
- continue
- fi
-
- case "$current" in
- # desc
- %NAME%)
- echo "pkgname = $i" >> .PKGINFO
- ;;
- %VERSION%)
- echo "pkgver = $i" >> .PKGINFO
- ;;
- %DESC%)
- echo "pkgdesc = $i" >> .PKGINFO
- ;;
- %URL%)
- echo "url = $i" >> .PKGINFO
- ;;
- %LICENSE%)
- echo "license = $i" >> .PKGINFO
- ;;
- %ARCH%)
- echo "arch = $i" >> .PKGINFO
- ;;
- %BUILDDATE%)
- echo "builddate = $(date -u "+%s")" >> .PKGINFO
- ;;
- %PACKAGER%)
- echo "packager = $pkg_pkger" >> .PKGINFO
- ;;
- %SIZE%)
- echo "size = $pkg_size" >> .PKGINFO
- ;;
- %GROUPS%)
- echo "group = $i" >> .PKGINFO
- ;;
- %REPLACES%)
- echo "replaces = $i" >> .PKGINFO
- ;;
- %DEPENDS%)
- echo "depend = $i" >> .PKGINFO
- ;;
- %OPTDEPENDS%)
- echo "optdepend = $i" >> .PKGINFO
- ;;
- %CONFLICTS%)
- echo "conflict = $i" >> .PKGINFO
- ;;
- %PROVIDES%)
- echo "provides = $i" >> .PKGINFO
- ;;
-
- # files
- %BACKUP%)
- # strip the md5sum after the tab
- echo "backup = ${i%%$'\t'*}" >> .PKGINFO
- ;;
- esac
+ if [[ -z "$i" ]]; then
+ continue;
+ fi
+
+ if [[ "$i" =~ %[A-Z]*% ]] ; then
+ current=$i
+ continue
+ fi
+
+ case "$current" in
+ # desc
+ %NAME%)
+ echo "pkgname = $i" >> .PKGINFO
+ ;;
+ %VERSION%)
+ echo "pkgver = $i" >> .PKGINFO
+ ;;
+ %DESC%)
+ echo "pkgdesc = $i" >> .PKGINFO
+ ;;
+ %URL%)
+ echo "url = $i" >> .PKGINFO
+ ;;
+ %LICENSE%)
+ echo "license = $i" >> .PKGINFO
+ ;;
+ %ARCH%)
+ echo "arch = $i" >> .PKGINFO
+ ;;
+ %BUILDDATE%)
+ echo "builddate = $(date -u "+%s")" >> .PKGINFO
+ ;;
+ %PACKAGER%)
+ echo "packager = $pkg_pkger" >> .PKGINFO
+ ;;
+ %SIZE%)
+ echo "size = $pkg_size" >> .PKGINFO
+ ;;
+ %GROUPS%)
+ echo "group = $i" >> .PKGINFO
+ ;;
+ %REPLACES%)
+ echo "replaces = $i" >> .PKGINFO
+ ;;
+ %DEPENDS%)
+ echo "depend = $i" >> .PKGINFO
+ ;;
+ %OPTDEPENDS%)
+ echo "optdepend = $i" >> .PKGINFO
+ ;;
+ %CONFLICTS%)
+ echo "conflict = $i" >> .PKGINFO
+ ;;
+ %PROVIDES%)
+ echo "provides = $i" >> .PKGINFO
+ ;;
+
+ # files
+ %BACKUP%)
+ # strip the md5sum after the tab
+ echo "backup = ${i%%$'\t'*}" >> .PKGINFO
+ ;;
+ esac
done
comp_files=".PKGINFO"
if [ -f "$pkg_dir/install" ] ; then
- cp "$pkg_dir/install" "$work_dir/.INSTALL"
- comp_files+=" .INSTALL"
+ cp "$pkg_dir/install" "$work_dir/.INSTALL"
+ comp_files+=" .INSTALL"
fi
if [ -f $pkg_dir/changelog ] ; then
- cp "$pkg_dir/changelog" "$work_dir/.CHANGELOG"
- comp_files+=" .CHANGELOG"
+ cp "$pkg_dir/changelog" "$work_dir/.CHANGELOG"
+ comp_files+=" .CHANGELOG"
fi
#
@@ -282,17 +280,17 @@ shopt -s nullglob
shopt -s -o pipefail
bsdtar -cf - $comp_files * |
case "$PKGEXT" in
- *tar.gz) gzip -c -f -n ;;
- *tar.bz2) bzip2 -c -f ;;
- *tar.xz) xz -c -z - ;;
- *tar) cat ;;
+ *tar.gz) gzip -c -f -n ;;
+ *tar.bz2) bzip2 -c -f ;;
+ *tar.xz) xz -c -z - ;;
+ *tar) cat ;;
esac > ${pkg_file} || ret=$?
if [ $ret -ne 0 ]; then
- echo "ERROR: unable to write package to $pkg_dest"
- echo " Maybe the disk is full or you do not have write access"
- rm -rf "$work_dir"
- exit 1
+ echo "ERROR: unable to write package to $pkg_dest"
+ echo " Maybe the disk is full or you do not have write access"
+ rm -rf "$work_dir"
+ exit 1
fi
rm -rf "$work_dir"