Add check for swprintf() and a workaround when it is missing
[pacman-ng.git] / contrib / re-pacman
blobfff1c873bcd8a105816ff0ca6026e72369445ba8
1 #!/bin/sh
3 # re-pacman: regenerate a pacman package based on installed files and the
4 # pacman database entries. Useful for reuse, or possible config file
5 # extension
6 #
7 # Copyright (c) 2006 Aaron Griffin <aaron@archlinux.org>
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #TODO
24 # * Check for md5 changes in backup lines and change pkgrel
26 pacinfo () {
27 [ $# -ne 2 ] && return 1
28 #use echo to strip spaces
29 echo $(pacman -Qi ${1} | grep "${2}" | cut -d: -f2-)
32 make_pkginfo () {
33 echo "# Generated by re-pacman 1.0.0"
34 echo "# On $(date)"
35 echo "pkgname =$(pacinfo ${1} Name)"
36 echo "pkgver =$(pacinfo ${1} Version)"
37 echo "pkgdesc =$(pacinfo ${1} Description)"
38 echo "url =$(pacinfo ${1} URL)"
39 echo "builddate =$(pacinfo ${1} 'Build Date')"
40 echo "packager =$(pacinfo ${1} Packager)"
41 echo "size =$(pacinfo ${1} Size)"
42 echo "arch =$(pacinfo ${1} Architecture)"
43 deps=$(pacinfo ${1} 'Depends On')
44 for d in ${deps}; do
45 echo "depend = ${d}"
46 done
49 LANG="POSIX"
51 if [ $# -ne 1 ]; then
52 echo "usage: re-pacman <installed package name>"
53 exit 1
56 ver=$(pacinfo ${1} Version)
57 if [ "x${ver}" = "x" ]; then
58 echo "Package '${1}' not found, aborting."
59 exit 1
62 echo ":: Cleaning up old files"
63 rm -f .PKGINFO "${1}-${ver}.pkg.tar.gz"
65 echo ":: Building PKGINFO"
66 make_pkginfo ${1} > .PKGINFO
68 flist=".PKGINFO"
69 flist="${flist} $(pacman -Ql ${1} | sed 's|\w* \(.*\)|/\1|g' | grep -v '/$')"
71 echo ":: Building final package tarball"
72 echo ${flist} | tr ' ' '\n' | tar czf "${1}-${ver}.pkg.tar.gz" -T - 2>/dev/null
74 rm -f .PKGINFO
75 echo ":: Package '${1}-${ver}.pkg.tar.gz' is now ready for installation"
77 # vim: set ts=2 sw=2 noet: