ffd8cd8164eeec404f039456646a4e9488c25144
[tools/librpm-tizen.git] / installplatform
1 #!/bin/sh
2
3 DESTDIR="${DESTDIR:-/}"
4 pkglibdir="${pkglibdir:-/usr/lib/rpm}"
5
6 RPMRC="${1:-rpmrc}"
7 MACROS="${2:-macros}"
8 PLATFORM="${3:-platform}"
9
10 TEMPRC="/tmp/rpmrc.$$"
11 cat << E_O_F > $TEMPRC
12 include:        $RPMRC
13 macrofiles:     $MACROS
14 E_O_F
15
16 RPM="./rpm --rcfile $TEMPRC"
17
18 ARCH="`$RPM --eval '%{_arch}'`"
19 VENDOR="`$RPM --eval '%{_vendor}'`"
20 OS="`$RPM --eval '%{_os}'`"
21 TARGET_PLATFORM="`$RPM --eval '%{_target_platform}'`"
22 TARGET="`$RPM --eval '%{_target}'`"
23
24 PPD="${DESTDIR}/${pkglibdir}/${ARCH}-${VENDOR}-${OS}"
25
26 [ -d $PPD ] || mkdir $PPD
27
28 RPMRC_OPTFLAGS="`$RPM --eval '%{optflags}'`"
29 RPMRC_OPTFLAGS="`echo $RPMRC_OPTFLAGS | sed -e 's, ,\ ,g'`"
30
31
32 cat $PLATFORM | \
33   sed -e s,@RPMRC_OPTFLAGS@,$RPMRC_OPTFLAGS, -e 's,\${,%{_,' \
34 > ${PPD}/macros
35
36 #
37 # Better try to create these too until the smoke clears. Yuck.
38 [ "${ARCH}-${VENDOR}-${OS}" = "${TARGET}" ] || ln -sf ${ARCH}-${VENDOR}-${OS} ${DESTDIR}/${pkglibdir}/${TARGET}
39 [ "${ARCH}-${VENDOR}-${OS}" = "${TARGET_PLATFORM}" ] || ln -sf ${ARCH}-${VENDOR}-${OS} ${DESTDIR}/${pkglibdir}/${TARGET_PLATFORM}
40
41 rm $TEMPRC