summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Griffin <aaron@archlinux.org>2006-10-23 08:09:10 +0200
committerAaron Griffin <aaron@archlinux.org>2006-10-23 08:09:10 +0200
commit7fc4b8d2d51ba3f5503b06ee6c368ee87ca2c81d (patch)
tree48ce51117adcd8120808f415c40053a40dd5b533
parenta719484f1ee0381b72729edf13dd03c4522f85e3 (diff)
downloadpacman-7fc4b8d2d51ba3f5503b06ee6c368ee87ca2c81d.tar.gz
pacman-7fc4b8d2d51ba3f5503b06ee6c368ee87ca2c81d.tar.xz
Added re-pacman
-rw-r--r--scripts/re-pacman59
1 files changed, 59 insertions, 0 deletions
diff --git a/scripts/re-pacman b/scripts/re-pacman
new file mode 100644
index 00000000..4c93524f
--- /dev/null
+++ b/scripts/re-pacman
@@ -0,0 +1,59 @@
+#!/bin/sh
+# This script is useful to rebuild a package from existing installed files
+# Good for users on slow connections that want to share, say, kdelibs but have
+# already cleaned their cache. Many other useful things as well
+#
+# TODO check the BACKUP section and change pkgrel if anything has changed
+
+pacinfo ()
+{
+ [ $# -ne 2 ] && return 1
+ #use echo to strip spaces
+ echo $(pacman -Qi ${1} | grep "${2}" | cut -d: -f2-)
+}
+
+make_pkginfo ()
+{
+ echo "# Generated by re-pacman 1.0.0"
+ echo "# On $(date)"
+ echo "pkgname =$(pacinfo ${1} Name)"
+ echo "pkgver =$(pacinfo ${1} Version)"
+ echo "pkgdesc =$(pacinfo ${1} Description)"
+ echo "url =$(pacinfo ${1} URL)"
+ echo "builddate =$(pacinfo ${1} 'Build Date')"
+ echo "packager =$(pacinfo ${1} Packager)"
+ echo "size =$(pacinfo ${1} Size)"
+ echo "arch =$(pacinfo ${1} Architecture)"
+ deps=$(pacinfo ${1} 'Depends On')
+ for d in ${deps}; do
+ echo "depend = ${d}"
+ done
+}
+
+if [ $# -ne 1 ]; then
+ echo "usage: re-pacman <installed package name>"
+ exit 1
+fi
+
+ver=$(pacinfo ${1} Version)
+if [ "x${ver}" = "x" ]; then
+ echo "Package '${1}' not found, aborting."
+ exit 1
+fi
+
+echo ":: Cleaning up old files"
+rm -f .PKGINFO .FILELIST "${1}-${ver}.pkg.tar.gz"
+
+echo ":: Building PKGINFO"
+make_pkginfo ${1} > .PKGINFO
+echo ":: Building FILELIST"
+pacman -Ql ${1} | cut -d' ' -f2- > .FILELIST
+
+flist=".PKGINFO .FILELIST"
+flist="${flist} $(pacman -Ql ${1} | sed 's|\w* \(.*\)|/\1|g' | grep -v '/$')"
+
+echo ":: Building final package tarball"
+echo ${flist} | tr ' ' '\n' | tar czf "${1}-${ver}.pkg.tar.gz" -T - 2>/dev/null
+
+rm -f .PKGINFO .FILELIST
+echo ":: Package '${1}-${ver}.pkg.tar.gz' is now ready for installation"