summaryrefslogtreecommitdiffstats
path: root/home/bin/rpmbuild-noarch
blob: a5f7c81909b605c9ced1720283ee4a120c9e6d78 (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
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
#!/bin/bash
####
# Copyright (c) 2011 Nokia Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without
# limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
####
#
# Usage:
#
#    rpmbuild-noarch ARCH ARGS...
# OR 
#    rpmbuild-armv5tel ARGS...
#
# The architecture is derived from the name of the shell script, or by
# running the generic script and passing the architecture as the first argument.
# This allows us to create a softlink to the shell script for each possible architecture.
#
# E.g.:    ln -s rpmbuild-noarch rpmbuild-armv5tel
#
#export ARCH=armv5tel

BASENAME=$(basename $0)
ARCH=${BASENAME#*-}
if [ "$ARCH" = "noarch" ] ; then
    ARCH=$1
    shift
fi

if [ $# -lt 2 ] ; then
    echo "Need to specify a build option and a spec file"
    exit 1
fi

export ARCH
export PP_ARCH=-${ARCH}
export SYSROOT=/usr/${ARCH}-redhat-linux-gnueabi/sys-root
export CROSS_COMPILE=arm-none-linux-gnueabi-
export PKG_CONFIG_PATH=${SYSROOT}/usr/lib/pkgconfig
export TARGET=${ARCH}-linux-gnueabi
export ZYPP_CONF=$SYSROOT/etc/zypp/zypp.conf
export BUILDROOT=$HOME/rpmbuild-${ARCH}/INSTALLROOT

terminate() {
    echo "${BASENAME} does not support $1"
    exit 1
}
# we used to set up the generic arm links in ~/bin with the setupDeveloper script.  
# Now that we are actively supporting 2 DIFFERENT architectures, 
# we need to set them up on the fly.  If you run 
# rpmbuild-armv5tel and rpmbuild-armv7hl on 2 diff
# xterms at the same time u r :(
echo "Making ARM links"
pushd ~/bin
base_name=$ARCH-redhat
for newprefix in arm arm-none ; do
    for i in /usr/bin/${base_name}*; do
	oldname=$(basename $i)
	linkname=${newprefix}${oldname#${base_name}}
	echo Redirecting to $i from ${linkname}
	ln -sf $i ${linkname}
    done
done
popd


# We assume that the list argument is the target file
# rpmbuild seems to work better if we insert our extra
# arguments BEFORE the target file, but AFTER all of the
# other arguments that were passed on the command line.

TARGETFILE=${!#}
length=$(($#-1))

for arg in "$@" ; do
   case $arg in 
#       -tp|-tc|-ti|-ta|-tb|-ts) terminate $arg;;
#       --rebuild|--recompile|--short-circuit)  terminate $arg;;
       -v|--verbose) VERBOSE="yes";;
   esac
done

EXTRA_ARGS="--rebuild --buildroot=${BUILDROOT} --root=${SYSROOT} --dbpath ${SYSROOT}/var/lib/rpm --target=${TARGET}"

if [ $VERBOSE ] ; then
    echo "#### Calling RPMBUILD with ${@:1:$length} $EXTRA_ARGS $TARGETFILE"
fi

rpmbuild ${@:1:$length} $EXTRA_ARGS $TARGETFILE