1 #!/bin/bash 2 3 # this script is designed to collect headers and libraries for an ARM HF ABI 4 # crossbuild of JavaFX. The result is probably bigger than it needs to be. 5 # The operation will cache download data in $DEST_VERSION.data so that 6 # rerunning the script can be done faster. When the desired result is complete, 7 # it can be removed as it should not be used in the build process. 8 9 # How to: 10 # Each debian repo will have a Contents and a Packages file (usually as a .gz) 11 # the Contents can be used to map a needed file to a package 12 # the Package is used to check dependancies 13 14 DEST_VERSION=armv6hf-02 15 16 confirm() { 17 echo -n "Is this correct? [Y/n]: " 18 read -n 1 -r 19 echo 20 if [[ $REPLY == "y" || $REPLY == "Y" || $REPLY == "" ]]; then 21 CONFIRMED=1 22 else 23 CONFIRMED=0 24 fi 25 } 26 27 checkReinstall() { 28 if [[ -d $1 ]]; then 29 echo 30 echo $1 already exists. 31 echo -n "Delete and re-install? [y/N]: " 32 read -n 1 -r 33 echo 34 if [[ $REPLY == "y" || $REPLY == "Y" ]]; then 35 /bin/rm -rf $1 36 fi 37 fi 38 } 39 40 getPackages() { 41 TOOLCHAIN=$1 42 REPO=$2 43 DISTRO=$3 44 CATEGORY=$4 45 ARCH=$5 46 PACKAGES=${@:6} 47 48 PACKAGEDIR=`echo $REPO | tr /: -`-$DISTRO-$CATEGORY-$ARCH 49 50 cd $RT/.. 51 OUT="$PWD/crosslibs/$TOOLCHAIN" 52 OUTDAT=$OUT.data 53 54 PACKAGELIST=$OUTDAT/$PACKAGEDIR/Packages 55 56 mkdir -p $OUT 57 mkdir -p $OUTDAT 58 cd $OUT 59 echo Working in $PWD 60 61 WGET="`which wget` -N --no-verbose" 62 63 echo "Checking to see if we have ${PACKAGELIST}" 64 if [ ! -f ${PACKAGELIST}/ ] 65 then 66 cd $OUTDAT 67 mkdir -p $PACKAGEDIR 68 cd $PACKAGEDIR 69 echo Getting package list 70 $WGET $REPO/dists/$DISTRO/$CATEGORY/binary-$ARCH/Packages.gz 71 if [ ! -f Packages.gz ] 72 then 73 echo "Failed to download Packages for this distro" 74 exit -1 75 fi 76 gunzip -c Packages.gz > Packages 77 cd $OUT 78 else 79 echo "Already have ${PACKAGELIST}, will reuse" 80 fi 81 82 DPKG_DEB=`which dpkg-deb` 83 if [ ! "$DPKG_DEB" ] 84 then 85 echo "did not find dpkg-deb" 86 fi 87 SED=`which sed` 88 if [ ! "$SED" ] 89 then 90 echo "did not find sed" 91 fi 92 93 echo 94 echo "Processing our packages" 95 96 for PACKAGE in ${PACKAGES}; do 97 echo Working on package $PACKAGE 98 PACKPATH=`$SED -ne "/^Package: $PACKAGE\$/,/Filename:/ s/^Filename: // p" ${PACKAGELIST}` 99 if [[ -z "$PACKPATH" ]]; then 100 echo "Could not find package $PACKAGE at $PACKPATH" 101 else 102 FILE=`/usr/bin/basename $PACKPATH` 103 if [ ! -f "${OUTDAT}/${FILE}" ] 104 then 105 echo "Fetching $PACKAGE ($FILE)" 106 cd $OUTDAT 107 $WGET $REPO/$PACKPATH 108 cd $OUT 109 else 110 echo Reusing cached $PACKAGE 111 fi 112 echo Unpacking $PACKAGE 113 $DPKG_DEB -x $OUTDAT/$FILE . 114 fi 115 done 116 117 echo 118 echo "Have all of our packages" 119 echo 120 echo "Clean up some unneeded junk" 121 # clean up good stuff we don't need that was pulled in. 122 rm -rf \ 123 bin etc sbin var selinux \ 124 usr/lib/gnu-smalltalk \ 125 usr/lib/mime/ \ 126 usr/lib/locale/ \ 127 usr/lib/girepository-1.0 \ 128 usr/share/man \ 129 usr/share/locale \ 130 usr/share/doc \ 131 usr/sbin \ 132 usr/lib/compat-ld \ 133 usr/lib/gold-ld \ 134 usr/lib/arm-linux-gnueabihf/gconv \ 135 usr/share/X11/locale \ 136 usr/bin 137 138 echo 139 echo "Checking for symlinks that need to be patched" 140 141 #!/bin/bash 142 143 find usr lib -type l ! -exec test -r {} \; -print | while read link 144 do 145 fileo=`file $link` 146 src=${fileo##*broken symbolic link to } 147 src=${src##\`} 148 src=${src%\'} 149 tgt=${fileo%:*} 150 151 if [[ "$src" =~ '/' ]] 152 then 153 # Fix absolute path by adding ../ for each level in the src 154 lsrc=${src#/} 155 ltgt=${tgt} 156 j=`expr index "$ltgt" /` 157 while [[ $j > 0 ]] 158 do 159 ltgt=${ltgt:$j} 160 j=`expr index "$ltgt" /` 161 lsrc="../${lsrc}" 162 done 163 echo fixing broken link ln -sf $lsrc $tgt 164 ln -sf $lsrc $tgt 165 fi 166 done 167 168 remaining=`find usr lib -type l ! -exec test -r {} \; -print ` 169 if [ "$remaining" ] 170 then 171 echo 172 echo 173 echo "Warning broken links remaining:" 174 find usr lib -type l ! -exec test -r {} \; -print | while read link 175 do 176 fileo=`file $link` 177 src=${fileo##* \`} 178 src=${src%\'} 179 tgt=${fileo%:*} 180 181 echo "broken link $tgt -> $src" 182 done 183 fi 184 185 # misc fixups, patch absolute ld scripts 186 187 cat > usr/lib/arm-linux-gnueabihf/libpthread.so << EOF 188 /* GNU ld script 189 Use the shared library, but some functions are only in 190 the static library, so try that secondarily. */ 191 OUTPUT_FORMAT(elf32-littlearm) 192 GROUP ( ../../../lib/arm-linux-gnueabihf/libpthread.so.0 ../../../usr/lib/arm-linux-gnueabihf/libpthread_nonshared.a ) 193 EOF 194 if [[ ! $? -eq 0 ]]; then 195 echo libpthread patch failed. 196 exit 1 197 fi 198 199 cat > usr/lib/arm-linux-gnueabihf/libc.so << EOF 200 /* GNU ld script 201 Use the shared library, but some functions are only in 202 the static library, so try that secondarily. */ 203 OUTPUT_FORMAT(elf32-littlearm) 204 GROUP ( ../../../lib/arm-linux-gnueabihf/libc.so.6 ../../../usr/lib/arm-linux-gnueabihf/libc_nonshared.a AS_NEEDED ( ../../../lib/arm-linux-gnueabihf/ld-linux-armhf.so.3 ) ) 205 EOF 206 if [[ ! $? -eq 0 ]]; then 207 echo libc patch failed. 208 exit 1 209 fi 210 211 212 # Install an alternative pkg-config 213 mkdir -p bin || exit 1 214 cp $SCRIPTDIR/pkg-config bin || exit 1 215 chmod +x bin/pkg-config || exit 1 216 217 # Patch package configuration files 218 find usr -name "*.pc" | xargs sed -i -e "s:=/usr/:=\${prefix}/:" 219 if [[ ! $? -eq 0 ]]; then 220 echo pkg-config patch failed. 221 exit 1 222 fi 223 224 } 225 226 installLibs() { 227 DESTINATION=$DEST_VERSION 228 229 getPackages \ 230 $DESTINATION \ 231 http://ftp.us.debian.org/debian/ stable main armhf \ 232 libatk1.0-dev \ 233 libatk1.0-0 \ 234 libc6 \ 235 libc-bin \ 236 libgcc1 \ 237 libglib2.0-0 \ 238 libffi5 \ 239 libpcre3 \ 240 libselinux1 \ 241 zlib1g \ 242 libatk1.0-data \ 243 libgirepository-1.0-1 \ 244 pkg-config \ 245 libpopt0 \ 246 libglib2.0-dev \ 247 libglib2.0-bin \ 248 libelf1 \ 249 libglib2.0-data \ 250 libpcre3-dev \ 251 libc6-dev \ 252 libc-dev-bin \ 253 linux-libc-dev \ 254 libpcrecpp0 \ 255 libstdc++6 \ 256 zlib1g-dev \ 257 libcairo2-dev \ 258 libcairo2 \ 259 libfontconfig1 \ 260 libexpat1 \ 261 libfreetype6 \ 262 libpixman-1-0 \ 263 libpng12-0 \ 264 libx11-6 \ 265 libxcb1 \ 266 libxau6 \ 267 libxdmcp6 \ 268 libx11-data \ 269 libxcb-render0 \ 270 libxcb-shm0 \ 271 libxrender1 \ 272 libcairo-gobject2 \ 273 libcairo-script-interpreter2 \ 274 libfontconfig1-dev \ 275 libexpat1-dev \ 276 libfreetype6-dev \ 277 libx11-dev \ 278 libxau-dev \ 279 x11proto-core-dev \ 280 libxdmcp-dev \ 281 x11proto-input-dev \ 282 x11proto-kb-dev \ 283 xtrans-dev \ 284 libxcb1-dev \ 285 libpthread-stubs0-dev \ 286 libpthread-stubs0 \ 287 libxrender-dev \ 288 x11proto-render-dev \ 289 libpng12-dev \ 290 libsm-dev \ 291 libsm6 \ 292 libice6 \ 293 libuuid1 \ 294 libpam0g \ 295 libsemanage1 \ 296 libsemanage-common \ 297 libbz2-1.0 \ 298 libsepol1 \ 299 libustr-1.0-1 \ 300 libice-dev \ 301 libpixman-1-dev \ 302 libxcb-render0-dev \ 303 libxcb-shm0-dev \ 304 libgdk-pixbuf2.0-dev \ 305 libgdk-pixbuf2.0-0 \ 306 libjasper1 \ 307 libjpeg8 \ 308 libtiff4 \ 309 libjbig0 \ 310 libgdk-pixbuf2.0-common \ 311 libglib2.0-0-refdbg \ 312 libgstreamer0.10-dev \ 313 libgstreamer0.10-0 \ 314 libxml2 \ 315 liblzma5 \ 316 libxml2-dev \ 317 libgstreamer-plugins-base0.10-dev \ 318 libgstreamer-plugins-base0.10-0 \ 319 liborc-0.4-0 \ 320 libgtk2.0-dev \ 321 libgtk2.0-0 \ 322 libgtk2.0-common \ 323 libcomerr2 \ 324 libcups2 \ 325 libavahi-client3 \ 326 libavahi-common3 \ 327 libavahi-common-data \ 328 libdbus-1-3 \ 329 libgnutls26 \ 330 libgcrypt11 \ 331 libgpg-error0 \ 332 libp11-kit0 \ 333 libtasn1-3 \ 334 libgssapi-krb5-2 \ 335 libk5crypto3 \ 336 libkeyutils1 \ 337 libkrb5support0 \ 338 libkrb5-3 \ 339 libpango1.0-0 \ 340 libthai0 \ 341 libthai-data \ 342 libdatrie1 \ 343 libxft2 \ 344 libxcomposite1 \ 345 libxcursor1 \ 346 libxfixes3 \ 347 libxdamage1 \ 348 libxext6 \ 349 libxi6 \ 350 libxinerama1 \ 351 libxrandr2 \ 352 libpango1.0-dev \ 353 libxft-dev \ 354 libxext-dev \ 355 x11proto-xext-dev \ 356 libxinerama-dev \ 357 x11proto-xinerama-dev \ 358 libxi-dev \ 359 libxrandr-dev \ 360 x11proto-randr-dev \ 361 libxcursor-dev \ 362 libxfixes-dev \ 363 x11proto-fixes-dev \ 364 libxcomposite-dev \ 365 x11proto-composite-dev \ 366 libxdamage-dev \ 367 x11proto-damage-dev \ 368 libxml2-utils \ 369 libreadline6 \ 370 libtinfo5 \ 371 libgtk2-gst \ 372 libgst7 \ 373 libgmp10 \ 374 libltdl7 \ 375 libsigsegv2 \ 376 libmpfr4 \ 377 libgomp1 \ 378 libmpc2 \ 379 libxtst-dev \ 380 libxtst6 \ 381 x11proto-record-dev \ 382 libdirectfb-dev \ 383 libdirectfb-1.2-9 \ 384 libxslt1-dev \ 385 libxslt1.1 \ 386 libudev-dev \ 387 libudev0 388 389 # get some rapberry Pi specials 390 getPackages \ 391 $DESTINATION \ 392 http://archive.raspbian.org/raspbian wheezy firmware armhf \ 393 libraspberrypi-dev 394 } 395 396 installCrossCompiler() { 397 echo 398 echo Fetching and unpacking compiler in $CROSSLIBS 399 echo 400 echo NOTE: if you use a proxy server then this download will probably fail. In that 401 echo case you need to set a value for the environment variable https_proxy and run 402 echo this script again. 403 echo 404 COMPILER_URL=https://launchpad.net/linaro-toolchain-unsupported/trunk/2012.09/+download/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux.tar.bz2 405 CMD="wget $COMPILER_URL -O - | tar jx -C $CROSSLIBS" 406 echo $CMD 407 echo 408 /bin/sh -c "$CMD" 409 } 410 411 SCRIPTDIR=`dirname $0` 412 SCRIPTDIR=`cd $SCRIPTDIR ; pwd` 413 RT=`cd $SCRIPTDIR/../.. ; pwd` 414 415 echo Using OpenJFX working directory at $RT 416 confirm() 417 if [[ $CONFIRMED -eq 0 ]]; then 418 echo -n "Enter the location of the OpenJFX working directory: " 419 read RT 420 fi 421 422 CROSSLIBS=`dirname $RT`/crosslibs 423 echo Using crosslibs directory $CROSSLIBS 424 425 mkdir -p $CROSSLIBS || exit 1 426 427 PILIBS=$CROSSLIBS/$DEST_VERSION 428 429 checkReinstall $PILIBS 430 if [[ ! -d $PILIBS ]]; then 431 installLibs 432 fi 433 434 CROSSCOMPILER=$CROSSLIBS/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux 435 checkReinstall $CROSSCOMPILER 436 if [[ ! -d $CROSSCOMPILER ]]; then 437 installCrossCompiler 438 fi 439 440 echo 441 echo "WARNING: remember to hand patch in usr/include/linux/mxcfb.h for i.mx cursor support" 442 echo 443 echo Done. 444