From 7fc4b8d2d51ba3f5503b06ee6c368ee87ca2c81d Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Mon, 23 Oct 2006 06:09:10 +0000 Subject: Added re-pacman --- scripts/re-pacman | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 scripts/re-pacman (limited to 'scripts/re-pacman') 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 " + 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" -- cgit v1.2.3-24-g4f1b