summaryrefslogtreecommitdiff
blob: db5495d41eb2c118406f594b95f540648c82bdd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash

DISTDIR=/usr/portage/distfiles
PN=debugedit

. /etc/init.d/functions.sh

set -e

einfo "Getting updated index"
rm -f index.html
wget -q http://rpm5.org/

PV=$(sed -n '/Production:/{n;s:.*RPM ::;s:<.*::;p;q}' index.html)
einfo "Latest upstream version: ${PV}"
rm -f index.html

P="${PN}-${PV}"
A=${P}.tar.bz2

e=${P}.ebuild
if [[ -e ../${e} ]] ; then
	einfo "All up to date"
	exit 0
fi

#tf=${DISTDIR}/${A}
#if [[ ! -e ${tf} ]] ; then
#	einfo "Cannot find ${tf}"
#	exit 0
#fi

einfo "Fetching latest rpm tarball"
r=rpm-${PV}
wget -nv http://rpm5.org/files/rpm/rpm-${PV%.*}/${r}.tar.gz -P ${DISTDIR} -c

einfo "Unpacking ${r}"
rm -rf ${r}
tar xf ${DISTDIR}/${r}.tar.gz

einfo "Creating ${P}"
rm -rf ${P}
mkdir ${P}
cp Makefile ${r}/tools/{hashtab.?,debugedit.c} ${P}/
pushd ${P} >/dev/null
more=true
while ${more} ; do
	more=false
	for h in $(grep '#include' *.[ch] | awk '{print $NF}' | sed 's:[<>"]::g') ; do
		[[ ${h} == */* ]] && continue
		rh=$(find ../${r} -name ${h##*/})
		if [[ -n ${rh} ]] && [[ ! -e ${rh##*/} ]] ; then
			# don't copy glibc includes
			if ! grep -qs 'This file is part of the GNU C Library' ${rh} ; then
				cp ${rh} ./
				more=true
			fi
		fi
	done
done
popd >/dev/null
tar jcf ${A} ${P}

einfo "Testing build"
pushd ${P} >/dev/null
make -s
popd >/dev/null

einfo "Cleaning up"
rm -rf ${P} ${r}
du -b ${A}