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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
#!/usr/bin/env bash
DESTDIR="${DESTDIR:-/}"
pkglibdir="${pkglibdir:-/usr/lib/rpm}"
RPMRC="${1:-rpmrc}"
MACROS="${2:-macros}"
PLATFORM="${3:-platform}"
if grep /share/ $PLATFORM > /dev/null 2>&1 ; then
DEFAULTDOCDIR='%{_usr}/share/doc'
else
DEFAULTDOCDIR='%{_usr}/doc'
fi
TEMPRC="/tmp/rpmrc.$$"
cat << E_O_F > $TEMPRC
include: $RPMRC
macrofiles: $MACROS
E_O_F
RPM="./rpm --rcfile $TEMPRC"
canonarch_sed='s_i.86_i386_;s_pentium[34]_i386_;s_athlon_i386_;s_sparc[^-]*_sparc_;s_alpha[^-]*_alpha_;s_arm[^-]*_arm_;s_\(powerpc\|ppc\)[^-]*_ppc_'
arch="`$RPM --eval '%{_arch}'|sed -e "$canonarch_sed"`"
VENDOR="`$RPM --eval '%{_vendor}'`"
OS="`$RPM --eval '%{_os}'`"
RPMRC_GNU="`$RPM --eval '%{_gnu}'`"
target_platform="`$RPM --eval '%{?_gnu:%undefine _gnu}%{_target_platform}'|sed -e "$canonarch_sed"`"
target="`$RPM --eval '%{_target}'|sed -e "$canonarch_sed"`"
case "$arch" in
i[3456]86|pentium[34]|athlon) SUBSTS='s_i386_i386_ s_i386_i486_ s_i386_i586_ s_i386_i686_ s_i386_pentium3_ s_i386_pentium4_ s_i386_athlon_' ;;
alpha*) SUBSTS='s_alpha_alpha_ s_alpha_alphaev5_ s_alpha_alphaev56_ s_alpha_alphapca56_ s_alpha_alphaev6_ s_alpha_alphaev67_' ;;
arm*) SUBSTS='s_arm_armv3l_ s_arm_armv4l_ s_arm_armv4tl_ s_arm_armv5tel_ s_arm_armv5tejl_ s_arm_armv6l_' ;;
sparc*) SUBSTS='s_sparc\(64\|v9\)_sparc_ s_sparc64_sparcv9_;s_sparc\([^v]\|$\)_sparcv9\1_ s_sparcv9_sparc64_;s_sparc\([^6]\|$\)_sparc64\1_' ;;
powerpc*|ppc*) SUBSTS='s_ppc64_ppc_ s_ppc\([^6ip]\|$\)_ppc64\1_ s_ppc\([^6ip]\|$\)_ppciseries_ s_ppc\([^6ip]\|$\)_ppcpseries_ s_ppc\([^6ip]\|$\)_ppc64iseries_ s_ppc\([^6ip]\|$\)_ppc64pseries_' ;;
s390*) SUBSTS='s_s390x_s390_ s_s390\([^x]\|$\)_s390x\1_' ;;
x86_64|amd64|ia32e) SUBSTS='s,x86_64,x86_64, s,x86_64,ia32e, s,x86_64,amd64,' ;;
*) SUBSTS=y___ ;;
esac
for SUBST in $SUBSTS ; do
ARCH=`echo $arch | sed -e $SUBST`
TARGET_PLATFORM=`echo $target_platform | sed -e $SUBST`
TARGET=`echo $target | sed -e $SUBST`
LIB=lib
PPD="${DESTDIR}/${pkglibdir}/${ARCH}-${OS}"
[ -d $PPD ] || mkdir $PPD
RPMRC_OPTFLAGS="`sed -n 's/^optflags: '$ARCH' //p' $RPMRC`"
RPMRC_OPTFLAGS="`echo $RPMRC_OPTFLAGS | sed -e 's, ,\ ,g'`"
case $RPMRC_OPTFLAGS in
*-g*) ;;
*) RPMRC_OPTFLAGS="$RPMRC_OPTFLAGS -g" ;;
esac
ARCH_INSTALL_POST='%{nil}'
MULTILIBNO=
case "${ARCH}-${OS}" in
sparc-linux) MULTILIBNO=1 ;;
sparcv9-linux) MULTILIBNO=1 ;;
sparc64-linux) ARCH_INSTALL_POST=${pkglibdir}/brp-sparc64-linux; LIB=lib64; MULTILIBNO=2 ;;
s390-linux) MULTILIBNO=1 ;;
s390x-linux) LIB=lib64; MULTILIBNO=2 ;;
ppc-linux) MULTILIBNO=1 ;;
ppc64-linux) LIB=lib64; MULTILIBNO=2 ;;
i?86-linux|pentium?-linux|athlon-linux) MULTILIBNO=1 ;;
x86_64-linux|amd64-linux|ia32e-linux) LIB=lib64; MULTILIBNO=2 ;;
esac
if [ -n "$MULTILIBNO" ]; then
MULTILIBSED='-e /^@MULTILIB/d -e s,@MULTILIBNO@,'$MULTILIBNO,
else
MULTILIBSED='-e /^@MULTILIBSTART@/,/^@MULTILIBEND@/d'
fi
case $VENDOR in
yellowdog)
VENDORSED='-e s,^@yellowdog@,,'
;;
pld)
VENDORSED='-e s,^@pld@,,'
RPMRC_OPTFLAGS="`echo $RPMRC_OPTFLAGS | sed -e "s/ -g/ /"`"
;;
mandrake)
VENDORSED='-e s,^@mandrake@,,'
RPMRC_OPTFLAGS="`echo $RPMRC_OPTFLAGS | sed -e s/i386/i686/`"
;;
conectiva)
VENDORSED='-e s,^@conectiva@,,'
;;
redhat)
VENDORSED='-e s,^@redhat@,,'
;;
apple)
VENDORSED='-e s,^@apple@,,'
;;
esac
cat $PLATFORM \
| sed -e "s,@RPMRC_OPTFLAGS@,$RPMRC_OPTFLAGS," \
-e "s,@RPMRC_ARCH@,$ARCH," \
-e "s,@RPMRC_GNU@,$RPMRC_GNU," \
-e "s,@LIB@,$LIB," \
-e "s,@ARCH_INSTALL_POST@,$ARCH_INSTALL_POST," \
-e "s,@DEFAULTDOCDIR@,$DEFAULTDOCDIR," \
-e '/\${\w*:-/!s,\${,%{_,' \
$MULTILIBSED \
$VENDORSED \
| grep -v '^@' \
> ${PPD}/macros
done
{ cd ${DESTDIR}/${pkglibdir}
[ -L noarch-${OS} ] && rm -f noarch-${OS} 2>/dev/null
mkdir -p noarch-${OS}
sed -e "/^%_arch/s,${arch},noarch," ${arch}-${OS}/macros | grep -v '^%optflags' > noarch-${OS}/macros
# [ -d ${VENDOR} ] || mkdir ${VENDOR}
# for i in brp-* find-lang.sh find-provides find-requires perl.prov perl.req
# do
# sed -e "s,/usr/lib/rpm,/usr/lib/rpm/${VENDOR},g" < $i > ${VENDOR}/$i
# chmod +x ${VENDOR}/$i
# done
## chmod -x ${VENDOR}/perl.req
# echo "macrofiles: /usr/lib/rpm/macros:/usr/lib/rpm/${VENDOR}/macros:/etc/rpm/macros.specspo:/etc/rpm/macros.cdb" > ${VENDOR}/rpmrc
# sed -e "s,/usr/lib/rpm,/usr/lib/rpm/${VENDOR},g" < ${arch}-${OS}/macros | grep -v '^%(_arch|optflags)' > ${VENDOR}/macros
}
rm $TEMPRC
|