| 1 | #!/bin/bash -x |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | source conf_vars.sh |
|---|
| 11 | |
|---|
| 12 | PKG=$1 |
|---|
| 13 | ARCH=$2 |
|---|
| 14 | |
|---|
| 15 | if [ ${ARCH} == "armel" ]; then |
|---|
| 16 | MIRROR=${MIRROR:="http://ftp.gnuab.org/debian/"} |
|---|
| 17 | |
|---|
| 18 | fi |
|---|
| 19 | |
|---|
| 20 | if [ ! -d $LOGPATH ]; then |
|---|
| 21 | mkdir -p $LOGPATH |
|---|
| 22 | fi |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | echo 1 > $LOGPATH/$HOST-$ARCH-$PKG.log |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | checkinstalled () { |
|---|
| 34 | while [ -n "$1" ]; do |
|---|
| 35 | dpkg -l "$1" |grep -q "^ii" || { |
|---|
| 36 | echo "$1 is not installed." |
|---|
| 37 | apt-get -y --force-yes install $1 |
|---|
| 38 | } |
|---|
| 39 | shift |
|---|
| 40 | done |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | sanitycheck () { |
|---|
| 44 | |
|---|
| 45 | echo "Sanity check..." |
|---|
| 46 | checkinstalled dpkg-cross |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | checkinstalled grep-dctrl |
|---|
| 50 | checkinstalled sudo |
|---|
| 51 | checkinstalled fakeroot |
|---|
| 52 | checkinstalled dpatch |
|---|
| 53 | checkinstalled patchutils |
|---|
| 54 | checkinstalled tar |
|---|
| 55 | checkinstalled bzip2 |
|---|
| 56 | checkinstalled lsb-release |
|---|
| 57 | checkinstalled autoconf |
|---|
| 58 | checkinstalled autoconf2.13 |
|---|
| 59 | checkinstalled automake1.9 |
|---|
| 60 | checkinstalled libtool |
|---|
| 61 | checkinstalled autogen |
|---|
| 62 | checkinstalled gawk |
|---|
| 63 | checkinstalled bison |
|---|
| 64 | checkinstalled flex |
|---|
| 65 | checkinstalled realpath |
|---|
| 66 | checkinstalled texinfo |
|---|
| 67 | checkinstalled devscripts |
|---|
| 68 | checkinstalled reprepro |
|---|
| 69 | checkinstalled less |
|---|
| 70 | checkinstalled coreutils |
|---|
| 71 | checkinstalled automake1.4 |
|---|
| 72 | checkinstalled automake1.7 |
|---|
| 73 | checkinstalled dh-make |
|---|
| 74 | checkinstalled debhelper |
|---|
| 75 | checkinstalled apt-cross |
|---|
| 76 | checkinstalled emdebian-tools |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | checkinstalled tetex-bin |
|---|
| 80 | checkinstalled libncurses5-dev |
|---|
| 81 | checkinstalled libreadline5-dev |
|---|
| 82 | |
|---|
| 83 | checkinstalled gobjc |
|---|
| 84 | checkinstalled cdbs |
|---|
| 85 | checkinstalled quilt |
|---|
| 86 | checkinstalled type-handling |
|---|
| 87 | echo "Sanity check passed." |
|---|
| 88 | } |
|---|
| 89 | |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | version () { |
|---|
| 94 | rmadison -a ${ARCH} ${1} | grep ${SUITE} | cut -d'|' -f2 | tr -d ' ' | cut -d'+' -f1 |sed 's/1://'|tail -n 1 |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | srcver () { |
|---|
| 98 | local x=$(apt-cache showsrc $1 |grep ^Version: |sed 's/^Version: //' |sort -bru |head -1) |
|---|
| 99 | echo $(echo $x |sed 's/\(.*\)\(-[0-9]*$\)/\1/' |sed 's/1://') |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | upstreamversion () { |
|---|
| 104 | echo $(version $1 |sed 's/\(.*\)\(-[0-9]*$\)/\1/') |
|---|
| 105 | } |
|---|
| 106 | |
|---|
| 107 | |
|---|
| 108 | debianrevision () { |
|---|
| 109 | echo $(version $1 |sed 's/\(.*-\)\([0-9]*$\)/\2/') |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | sourcepackage () { |
|---|
| 114 | local x=$(grep-status -PX $1 -s Source: -n) |
|---|
| 115 | local y=$1 |
|---|
| 116 | echo ${x:=$y} |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | sourcedir () { |
|---|
| 121 | echo $1-$(srcver $1) |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | |
|---|
| 125 | |
|---|
| 126 | make-cross-package () { |
|---|
| 127 | local _version=$(version $1) |
|---|
| 128 | |
|---|
| 129 | apt-cross -v -v -a ${ARCH} -S ${SUITE} -m ${MIRROR} -i $1 |
|---|
| 130 | apt-cross -v -v -a ${ARCH} -S ${SUITE} -m ${MIRROR} -f -b $1 |
|---|
| 131 | apt-cross -v -v -a ${ARCH} -S ${SUITE} -m ${MIRROR} -f -b $1 |
|---|
| 132 | |
|---|
| 133 | |
|---|
| 134 | |
|---|
| 135 | |
|---|
| 136 | } |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | |
|---|
| 140 | build-libs () { |
|---|
| 141 | |
|---|
| 142 | |
|---|
| 143 | make-cross-package linux-libc-dev |
|---|
| 144 | |
|---|
| 145 | |
|---|
| 146 | if [ ${ARCH} = "alpha" ] || [ ${ARCH} = "ia64" ] ; then |
|---|
| 147 | make-cross-package libc6.1 |
|---|
| 148 | make-cross-package libc6.1-dev |
|---|
| 149 | else |
|---|
| 150 | make-cross-package libc6 |
|---|
| 151 | make-cross-package libc6-dev |
|---|
| 152 | fi |
|---|
| 153 | |
|---|
| 154 | |
|---|
| 155 | if [ ${ARCH} = "ia64" ] ; then |
|---|
| 156 | make-cross-package libatomic-ops-dev |
|---|
| 157 | make-cross-package libunwind7 |
|---|
| 158 | make-cross-package libunwind7-dev |
|---|
| 159 | fi |
|---|
| 160 | |
|---|
| 161 | if [ ${ARCH} = "powerpc" ]; then |
|---|
| 162 | make-cross-package libc6-ppc64 |
|---|
| 163 | make-cross-package libc6-dev-ppc64 |
|---|
| 164 | fi |
|---|
| 165 | |
|---|
| 166 | if [ ${ARCH} = "i386" ]; then |
|---|
| 167 | make-cross-package libc6-amd64 |
|---|
| 168 | make-cross-package lib64gcc1 |
|---|
| 169 | make-cross-package libc6-dev-amd64 |
|---|
| 170 | fi |
|---|
| 171 | |
|---|
| 172 | if [ ${ARCH} = "sparc" ]; then |
|---|
| 173 | make-cross-package libc6-sparc64 |
|---|
| 174 | make-cross-package libc6-dev-sparc64 |
|---|
| 175 | fi |
|---|
| 176 | |
|---|
| 177 | if [ ${ARCH} = "s390" ]; then |
|---|
| 178 | make-cross-package libc6-s390x |
|---|
| 179 | make-cross-package libc6-dev-s390x |
|---|
| 180 | fi |
|---|
| 181 | |
|---|
| 182 | if [ ${ARCH} = "hppa" ]; then |
|---|
| 183 | make-cross-package libgcc4 |
|---|
| 184 | fi |
|---|
| 185 | |
|---|
| 186 | if [ ${ARCH} = "m68k" ] ; then |
|---|
| 187 | make-cross-package libgcc2 |
|---|
| 188 | else |
|---|
| 189 | make-cross-package libgcc1 |
|---|
| 190 | fi |
|---|
| 191 | |
|---|
| 192 | |
|---|
| 193 | if [ ${ARCH} = "amd64" ] ; then |
|---|
| 194 | make-cross-package lib32gcc1 |
|---|
| 195 | fi |
|---|
| 196 | |
|---|
| 197 | if [ ${ARCH} = "ia64" ] ; then |
|---|
| 198 | make-cross-package lib32gcc1 |
|---|
| 199 | fi |
|---|
| 200 | |
|---|
| 201 | |
|---|
| 202 | |
|---|
| 203 | |
|---|
| 204 | |
|---|
| 205 | make-cross-package gcc-4.3-base |
|---|
| 206 | |
|---|
| 207 | |
|---|
| 208 | |
|---|
| 209 | |
|---|
| 210 | rm -rf *${ARCH}.deb |
|---|
| 211 | |
|---|
| 212 | } |
|---|
| 213 | |
|---|
| 214 | |
|---|
| 215 | apply_patch () { |
|---|
| 216 | patch -p1 < ../../patches/$1 |
|---|
| 217 | } |
|---|
| 218 | |
|---|
| 219 | |
|---|
| 220 | |
|---|
| 221 | build-gdb () { |
|---|
| 222 | local _upver=$(upstreamversion gdb) |
|---|
| 223 | local _version=$(version gdb) |
|---|
| 224 | local _dir=$(sourcedir gdb) |
|---|
| 225 | local _debarch=${ARCH} |
|---|
| 226 | |
|---|
| 227 | if [ ! -d gdb-${_version} ]; then |
|---|
| 228 | rm -rf $_dir |
|---|
| 229 | apt-get source gdb |
|---|
| 230 | |
|---|
| 231 | |
|---|
| 232 | |
|---|
| 233 | |
|---|
| 234 | |
|---|
| 235 | mv $_dir gdb-${_version} |
|---|
| 236 | fi |
|---|
| 237 | pushd gdb-${_version} |
|---|
| 238 | |
|---|
| 239 | TARGET=${ARCH} dpkg-buildpackage -rfakeroot -uc -us |
|---|
| 240 | popd |
|---|
| 241 | |
|---|
| 242 | |
|---|
| 243 | |
|---|
| 244 | |
|---|
| 245 | rm -rf *.gz *.bz2 *.dsc *.changes *.tgz *.tar gdb-${_version}/ |
|---|
| 246 | |
|---|
| 247 | } |
|---|
| 248 | |
|---|
| 249 | |
|---|
| 250 | build-binutils () { |
|---|
| 251 | local _upver=$(upstreamversion binutils) |
|---|
| 252 | local _version=$(version binutils) |
|---|
| 253 | local _dir=$(sourcedir binutils) |
|---|
| 254 | local _debarch=${ARCH} |
|---|
| 255 | |
|---|
| 256 | if [ ! -d binutils-${_version} ]; then |
|---|
| 257 | rm -rf $_dir |
|---|
| 258 | apt-get source binutils |
|---|
| 259 | pushd $_dir |
|---|
| 260 | echo "${ARCH}" > debian/target |
|---|
| 261 | |
|---|
| 262 | |
|---|
| 263 | apply_patch binutils-cross-2.18.patch |
|---|
| 264 | |
|---|
| 265 | popd |
|---|
| 266 | mv $_dir binutils-${_version} |
|---|
| 267 | fi |
|---|
| 268 | pushd binutils-${_version} |
|---|
| 269 | |
|---|
| 270 | TARGET=${ARCH} fakeroot debian/rules binary-cross |
|---|
| 271 | popd |
|---|
| 272 | |
|---|
| 273 | $ROOTCMD dpkg -i binutils-*-linux-gnu*.deb >> dpkg.log |
|---|
| 274 | |
|---|
| 275 | |
|---|
| 276 | rm -rf *.gz *.bz2 *.tgz *.dsc *.changes *.tar binutils-${_version}/ |
|---|
| 277 | |
|---|
| 278 | } |
|---|
| 279 | |
|---|
| 280 | |
|---|
| 281 | |
|---|
| 282 | build-gcc () { |
|---|
| 283 | local _upver=$(upstreamversion gcc-$1) |
|---|
| 284 | local _version=$(version gcc-$1) |
|---|
| 285 | local _dir=$(sourcedir gcc-$1) |
|---|
| 286 | |
|---|
| 287 | if [ ! -d gcc-$1-${_version} ]; then |
|---|
| 288 | rm -rf $_dir |
|---|
| 289 | apt-get source gcc-$1 |
|---|
| 290 | pushd $_dir |
|---|
| 291 | echo "${ARCH}" > debian/target |
|---|
| 292 | |
|---|
| 293 | |
|---|
| 294 | if [ ${1} = "4.2" ]; then |
|---|
| 295 | |
|---|
| 296 | |
|---|
| 297 | apply_patch gcc-4.2-4.2.2-cross.patch |
|---|
| 298 | fi |
|---|
| 299 | |
|---|
| 300 | if [ ${GCCVER} = "3.3" ]; then |
|---|
| 301 | |
|---|
| 302 | |
|---|
| 303 | |
|---|
| 304 | |
|---|
| 305 | apply_patch gcc-3.3.6.patch |
|---|
| 306 | fi |
|---|
| 307 | |
|---|
| 308 | DEB_CROSS=yes fakeroot debian/rules control |
|---|
| 309 | popd |
|---|
| 310 | mv $_dir gcc-$1-${_version} |
|---|
| 311 | fi |
|---|
| 312 | pushd gcc-$1-${_version} |
|---|
| 313 | if [ ${ARCH} = "armel" ]; then |
|---|
| 314 | LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/arm-linux-gnueabi/lib/:/arm-linux-gnueabi/lib:/usr/arm-linux-gnueabi/lib32/:/usr/arm-linux-gnueabi/lib64/:/arm-linux-gnueabi/lib32/:/arm-linux-gnueabi/lib64/:/emul/ia32-linux/lib/:/emul/ia32-linux/usr/lib/ DEB_CROSS=yes dpkg-buildpackage -us -uc -B -rfakeroot |
|---|
| 315 | else |
|---|
| 316 | LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/${ARCH}-linux-gnu/lib/:/${ARCH}-linux-gnu/lib:/usr/${ARCH}-linux-gnu/lib32/:/usr/${ARCH}-linux-gnu/lib64/:/${ARCH}-linux-gnu/lib32/:/${ARCH}-linux-gnu/lib64/:/emul/ia32-linux/lib/:/emul/ia32-linux/usr/lib/ DEB_CROSS=yes dpkg-buildpackage -us -uc -B -rfakeroot |
|---|
| 317 | fi |
|---|
| 318 | popd |
|---|
| 319 | } |
|---|
| 320 | |
|---|
| 321 | |
|---|
| 322 | install-gcc () { |
|---|
| 323 | local _version=$(version gcc-$1) |
|---|
| 324 | local _versionrepo=$(echo gcc-$1 | sed -e 's/-//' | sed -e 's/\.//') |
|---|
| 325 | |
|---|
| 326 | |
|---|
| 327 | rm -rf *.gz *.bz2 *.tgz *.tar gcc-$1-${_version}/ *.changes *.dsc |
|---|
| 328 | |
|---|
| 329 | } |
|---|
| 330 | |
|---|
| 331 | |
|---|
| 332 | |
|---|
| 333 | build-gcc-3.3 () { |
|---|
| 334 | checkinstalled gcc-3.3 |
|---|
| 335 | GCCVER=${GCCVER:="3.3"} |
|---|
| 336 | build-gcc 3.3 |
|---|
| 337 | install-gcc 3.3 |
|---|
| 338 | } |
|---|
| 339 | |
|---|
| 340 | |
|---|
| 341 | build-gcc-3.4 () { |
|---|
| 342 | checkinstalled gcc-3.4 |
|---|
| 343 | GCCVER=${GCCVER:="3.4"} |
|---|
| 344 | build-gcc 3.4 |
|---|
| 345 | install-gcc 3.4 |
|---|
| 346 | } |
|---|
| 347 | |
|---|
| 348 | |
|---|
| 349 | build-gcc-4.0 () { |
|---|
| 350 | checkinstalled gcc-4.0 |
|---|
| 351 | GCCVER=${GCCVER:="4.0"} |
|---|
| 352 | build-gcc 4.0 |
|---|
| 353 | install-gcc 4.0 |
|---|
| 354 | } |
|---|
| 355 | |
|---|
| 356 | |
|---|
| 357 | build-gcc-4.1 () { |
|---|
| 358 | checkinstalled gcc-4.1 |
|---|
| 359 | GCCVER=${GCCVER:="4.1"} |
|---|
| 360 | |
|---|
| 361 | |
|---|
| 362 | |
|---|
| 363 | build-gcc 4.1 |
|---|
| 364 | install-gcc 4.1 |
|---|
| 365 | } |
|---|
| 366 | |
|---|
| 367 | |
|---|
| 368 | build-gcc-4.2 () { |
|---|
| 369 | checkinstalled gcc-4.2 |
|---|
| 370 | GCCVER=${GCCVER:="4.2"} |
|---|
| 371 | build-gcc 4.2 |
|---|
| 372 | install-gcc 4.2 |
|---|
| 373 | } |
|---|
| 374 | |
|---|
| 375 | build-gcc-4.3 () { |
|---|
| 376 | checkinstalled gcc-4.3 |
|---|
| 377 | GCCVER=${GCCVER:="4.3"} |
|---|
| 378 | build-gcc 4.3 |
|---|
| 379 | install-gcc 4.3 |
|---|
| 380 | } |
|---|
| 381 | |
|---|
| 382 | |
|---|
| 383 | build-gcc-snapshot () { |
|---|
| 384 | |
|---|
| 385 | pushd /usr/lib |
|---|
| 386 | $ROOTCMD ln -sf /usr gcc-snapshot |
|---|
| 387 | popd |
|---|
| 388 | |
|---|
| 389 | build-gcc snapshot |
|---|
| 390 | |
|---|
| 391 | } |
|---|
| 392 | |
|---|
| 393 | |
|---|
| 394 | |
|---|
| 395 | |
|---|
| 396 | sanitycheck |
|---|
| 397 | |
|---|
| 398 | |
|---|
| 399 | if [[ "1.39" > $(dpkg-cross --help 2>&1 |awk '{print $3; exit;}') ]]; then |
|---|
| 400 | echo "dpkg-cross is too old." |
|---|
| 401 | exit 1 |
|---|
| 402 | fi |
|---|
| 403 | |
|---|
| 404 | |
|---|
| 405 | |
|---|
| 406 | |
|---|
| 407 | |
|---|
| 408 | |
|---|
| 409 | |
|---|
| 410 | [ -d ${ARCH} ] || mkdir ${ARCH} |
|---|
| 411 | pushd ${ARCH} |
|---|
| 412 | echo "Updating apt-cross cache" |
|---|
| 413 | apt-cross -a ${ARCH} -S ${SUITE} -m ${MIRROR} -u |
|---|
| 414 | echo "Building for ARCH::${ARCH}" |
|---|
| 415 | |
|---|
| 416 | if [ ${1} = "libs" ]; then |
|---|
| 417 | build-libs &> ../$LOGPATH/$HOST-$ARCH-$PKG.log |
|---|
| 418 | |
|---|
| 419 | elif [ ${1} = "binutils" ]; then |
|---|
| 420 | build-binutils &> ../$LOGPATH/$HOST-$ARCH-$PKG.log |
|---|
| 421 | |
|---|
| 422 | elif [ ${1} = "gdb" ]; then |
|---|
| 423 | build-gdb &> ../$LOGPATH/$HOST-$ARCH-$PKG.log |
|---|
| 424 | |
|---|
| 425 | |
|---|
| 426 | |
|---|
| 427 | elif [ ${1} = "3.3" ]; then |
|---|
| 428 | GCCVER=${1} |
|---|
| 429 | echo $GCCVER |
|---|
| 430 | echo Runs |
|---|
| 431 | echo gcc-3.3 |
|---|
| 432 | |
|---|
| 433 | elif [ ${1} = "3.4" ]; then |
|---|
| 434 | GCCVER=${1} |
|---|
| 435 | build-gcc-${GCCVER} &> ../$LOGPATH/$HOST-$ARCH-$PKG.log |
|---|
| 436 | elif [ ${1} = "4.1" ]; then |
|---|
| 437 | GCCVER=${1} |
|---|
| 438 | build-gcc-${GCCVER} &> ../$LOGPATH/$HOST-$ARCH-$PKG.log |
|---|
| 439 | elif [ ${1} = "4.2" ]; then |
|---|
| 440 | GCCVER=${1} |
|---|
| 441 | build-gcc-${GCCVER} &> ../$LOGPATH/$HOST-$ARCH-$PKG.log |
|---|
| 442 | elif [ ${1} = "4.3" ]; then |
|---|
| 443 | GCCVER=${1} |
|---|
| 444 | build-gcc-${GCCVER} &> ../$LOGPATH/$HOST-$ARCH-$PKG.log |
|---|
| 445 | else |
|---|
| 446 | echo " Unknown option" |
|---|
| 447 | exit 1 |
|---|
| 448 | fi |
|---|
| 449 | popd |
|---|
| 450 | |
|---|
| 451 | |
|---|
| 452 | |
|---|
| 453 | TEST=`cat $LOGPATH/$HOST-$ARCH-$PKG.log | grep $HOST.deb` |
|---|
| 454 | if [ -n ${TEST} ]; then |
|---|
| 455 | echo 1 >> $LOGPATH/$HOST-$ARCH-$PKG.log |
|---|
| 456 | else |
|---|
| 457 | echo 0 >> $LOGPATH/$HOST-$ARCH-$PKG.log |
|---|
| 458 | fi |
|---|
| 459 | |
|---|
| 460 | |
|---|