summaryrefslogtreecommitdiffstats
path: root/home/bin/setupDeveloper.sh
blob: 51df9edb9e1dd7307d907293fb093850ad14bb2f (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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/bin/sh
####
# 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.
####

RPM_SERVER=mt-fedora.nrcc.noklab.com
RPM_CROSS_REPO=repos/f14-cross/
VERSIONLOCK_FILE=/etc/yum/pluginconf.d/versionlock.list
FRELEASEVER=" --releasever 14"

# some of these are for documentation, some are because configure is hardcoded to /usr/include.
# sigh.
# needed for docs:
#   xmlto 
#   docbook2ps 
# needed to build wayland:
#   libffi-devel 
#   expat-devel

#   
# the rest are needed for cross env/rpmbuild

# note, tcl is *only* needed if you want to build tcl for arm
YUMLIST_NRCC="zypper \
cross-rpm-config \
redhat-rpm-config \
armv5tel-redhat-linux-gnueabi-binutils \
armv5tel-redhat-linux-gnueabi-cpp \
armv5tel-redhat-linux-gnueabi-gcc \
armv5tel-redhat-linux-gnueabi-gcc-c++ \
armv5tel-redhat-linux-gnueabi-libgcc \
armv5tel-redhat-linux-gnueabi-libgomp \
armv5tel-redhat-linux-gnueabi-libmudflap \
armv5tel-redhat-linux-gnueabi-libmudflap-devel \
armv5tel-redhat-linux-gnueabi-libstdc++ \
armv5tel-redhat-linux-gnueabi-libstdc++-devel \
armv7hl-redhat-linux-gnueabi-binutils \
armv7hl-redhat-linux-gnueabi-gcc \
xmlto \
docbook2ps \
rpmdevtools \
libffi-devel \
docbook-utils-pdf \
chrpath \
glib2-devel \
gtk-doc \
compat-flex \
linuxdoc-tools \
w3m \
docbook-style-xsl \
docbook-dtds \
tcl \
asciidoc \
sharutils \
fdupes \
expat-devel"


RPMLIST_NRCC="redhat-rpm-config-9.1.0-5.fc14.nrcc.2 \
rpm-build-4.8.1-5.fc14.nrcc.9 \
rpm-4.8.1-5.fc14.nrcc.9 \
rpm-apidocs-4.8.1-5.fc14.nrcc.9 \
rpm-python-4.8.1-5.fc14.nrcc.9 \
rpm-cron-4.8.1-5.fc14.nrcc.9 \
rpm-libs-4.8.1-5.fc14.nrcc.9 "


if [ ! -d "$1"/sysroot ]; then
    echo "need dir of mt-cross-tools"
    exit 1
fi

## add in the private repo certificate so zypper will play nice with it.
## this goes in the host machine certs, not the sysroots
curl http://${RPM_SERVER}/mt-fedora.nrcc.noklab.com.ssl.crt | sudo tee -a /etc/pki/tls/certs/ca-bundle.crt


SPHONE_DIR=$1

mkdir -p ~/bin
rsync -av $SPHONE_DIR/home/.rpm* ~/

cd ~/bin
for i in $SPHONE_DIR/home/bin/* ; do
    echo "linking $i to $(basename $i) in `pwd`"
    ln -sf $i $(basename $i)
done



#force in basic needed packages
echo "Installing Development Tools"
sudo yum ${FRELEASEVER} -y groupinstall "Development Tools"
rpm -q wget || (echo "Installing wget"; sudo yum -y install wget)

# yum-plugin-versionlock allows pinning for yum 
sudo yum -y install yum-plugin-versionlock

# the doofy plugin doesnt make an empty one nor does it work w/o one
sudo touch $VERSIONLOCK_FILE
sudo chmod 644 $VERSIONLOCK_FILE

echo "Installing /etc/yum.repos.d/f14-cross.repo"
# grab the nrcc repo 
if [ ! -e /etc/yum.repos.d/f14-cross.repo ]; then
    cd /tmp
    rm -f f14-cross.repo
    wget http://$RPM_SERVER/f14-cross.repo
    if [  -e /tmp/f14-cross.repo ]; then
	sudo mv f14-cross.repo /etc/yum.repos.d/f14-cross.repo
    else
	echo "Couldnt retrieve the nrcc repo file"
	echo "baggin out"
	exit 1
    fi
fi

for i in $YUMLIST_NRCC; do
    rpm -q $i || (echo YUMMING $i; sudo yum -y install $i)
done




echo "Installing and Pinning NRCC Versions"
# we are making a manifest file so dependencies are all resolved at once
RPM_MANIFEST=/tmp/`mktemp RPM_MANIFEST_XXXXX` 
for i in $RPMLIST_NRCC; do
    cd /tmp
    #check for our file in versionlock
    BASE_NAME=`echo $i | sed -e 's/-[0-9]/ /' | cut -f1 -d ' '`
    BASE_NAME_VERSIONED=`echo $i | sed -e 's/-[0-9]/& /' | cut -f1 -d ' '`
    if sudo yum versionlock list | egrep $BASE_NAME_VERSIONED ; then
	# remove it from the version lock. so we can grab the one we want.
	VENTRY=`sudo yum versionlock list | egrep $BASE_NAME_VERSIONED`
	sudo yum versionlock delete $VENTRY
    fi
    #   the doofy plugin *sometimes* reverts the permissions to 600 instead of 644
    sudo chmod 644 $VERSIONLOCK_FILE
    # using yumdownloader meand we get i686 or x86_64 whichever is correct
    yumdownloader --disablerepo=* --enablerepo=f14-cross $BASE_NAME
    echo "$i*rpm" >> $RPM_MANIFEST
    sudo yum versionlock  $i
done

# the doofy plugin *sometimes* reverts the permissions to 600 instead of 644
sudo chmod 644 $VERSIONLOCK_FILE
sudo rpm -Uv --force $RPM_MANIFEST  
rm -f $RPM_MANIFEST
rm -rf /tmp/*rpm

echo "Making ARM links"
cd ~/bin
for base_name in armv5tel-redhat armv7hl-redhat; do
    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
done
NUM_CPUS=`grep processor  /proc/cpuinfo  | tail -1  | cut -f2 -d ':'`

if [ "$NUM_CPUS" -eq "0" ]; then
echo "%_smp_mflags -j 1" >> ~/.rpmmacros
else
echo "%_smp_mflags -j ${NUM_CPUS}" >> ~/.rpmmacros
fi