2006-10-23 02:09:10 -04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2006-11-13 12:48:13 -05:00
|
|
|
# re-pacman: regenerate a pacman package based on installed files and the
|
|
|
|
# pacman database entries. Useful for reuse, or possible config file
|
|
|
|
# extension
|
|
|
|
#
|
|
|
|
# Copyright (c) 2006 Aaron Griffin <aaron@archlinux.org>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-12-10 23:55:22 -05:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-11-13 12:48:13 -05:00
|
|
|
#
|
|
|
|
|
|
|
|
#TODO
|
|
|
|
# * Check for md5 changes in backup lines and change pkgrel
|
2006-10-23 02:09:10 -04:00
|
|
|
|
2006-12-20 20:53:40 -05:00
|
|
|
pacinfo () {
|
|
|
|
[ $# -ne 2 ] && return 1
|
|
|
|
#use echo to strip spaces
|
|
|
|
echo $(pacman -Qi ${1} | grep "${2}" | cut -d: -f2-)
|
2006-10-23 02:09:10 -04:00
|
|
|
}
|
|
|
|
|
2006-12-20 20:53:40 -05:00
|
|
|
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
|
2006-10-23 02:09:10 -04:00
|
|
|
}
|
|
|
|
|
2007-07-26 20:21:38 -04:00
|
|
|
LANG="POSIX"
|
|
|
|
|
2006-10-23 02:09:10 -04:00
|
|
|
if [ $# -ne 1 ]; then
|
2006-12-20 20:53:40 -05:00
|
|
|
echo "usage: re-pacman <installed package name>"
|
|
|
|
exit 1
|
2006-10-23 02:09:10 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
ver=$(pacinfo ${1} Version)
|
|
|
|
if [ "x${ver}" = "x" ]; then
|
2006-12-20 20:53:40 -05:00
|
|
|
echo "Package '${1}' not found, aborting."
|
|
|
|
exit 1
|
2006-10-23 02:09:10 -04:00
|
|
|
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"
|
2006-12-20 20:53:40 -05:00
|
|
|
|
|
|
|
# vim: set ts=2 sw=2 noet:
|