tazwok annotate chroot-scripts/cook-toolchain @ rev 334

Last commit here: tazwok is no more experimental
author Antoine Bodin <gokhlayeh@slitaz.org>
date Tue Feb 22 01:56:15 2011 +0100 (2011-02-22)
parents 32b8fbc44418
children db18d2db42c2
rev   line source
gokhlayeh@315 1 #!/bin/bash
gokhlayeh@315 2 #
gokhlayeh@315 3 # An attempt to cook a new toolchain from scratch.
gokhlayeh@315 4
gokhlayeh@315 5 # Important settings and variables.
gokhlayeh@315 6 source /usr/lib/slitaz/libtaz
gokhlayeh@315 7 source /etc/slitaz/tazwok.conf
gokhlayeh@315 8 source_lib report
gokhlayeh@315 9 report start
gokhlayeh@315 10
gokhlayeh@315 11 report step "Cooking temporary toolchain"
gokhlayeh@315 12 report open-bloc
gokhlayeh@315 13
gokhlayeh@315 14 report step "Initializing tools & environment"
gokhlayeh@315 15
gokhlayeh@315 16 # Theses fours packages will be needed later.
gokhlayeh@334 17 for p in libtaz tazwok slitaz-base-files tazpkg; do
gokhlayeh@315 18 tazwok cook $p
gokhlayeh@315 19 done
gokhlayeh@315 20
gokhlayeh@315 21 set +h
gokhlayeh@315 22 umask 022
gokhlayeh@315 23 PS1='\u:\w\$ '
gokhlayeh@315 24 LANG=POSIX
gokhlayeh@315 25 LC_ALL=POSIX
gokhlayeh@315 26
gokhlayeh@315 27 # Set BUILD_HOST to something like $ARCH-tmp-linux-gnu to enable
gokhlayeh@315 28 # of the temporary toolchain.
gokhlayeh@315 29 BUILD_HOST=$(echo $BUILD_HOST | sed 's/\(.*\)-\(.*\)-linux-gnu/\1-tmp-linux-gnu/')
gokhlayeh@315 30
gokhlayeh@315 31 PATH=/tools/bin:/tools/usr/bin:/tools/sbin:/tools/usr/sbin:/bin:/usr/bin:/sbin:/usr/sbin
gokhlayeh@315 32 CONFIG_SITE="/etc/config.site.tmptoolchain"
gokhlayeh@315 33 echo 'prefix=/tools' > /etc/config.site.tmptoolchain
gokhlayeh@315 34
gokhlayeh@315 35 export LANG LC_ALL PATH PS1 MAKEFLAGS CONFIG_SITE
gokhlayeh@315 36 unset CC CXX CPP CFLAGS CXXFLAGS LD_LIBRARY_PATH LD_PRELOAD DESTDIR
gokhlayeh@315 37
gokhlayeh@315 38 # Create the dir for the temporary toolchain and link in root of host
gokhlayeh@315 39 # system.
gokhlayeh@315 40 [ -d /tools ] && rm -r /tools
gokhlayeh@315 41 mkdir /tools
gokhlayeh@315 42
gokhlayeh@315 43 # Use some tweaked code from tazwok.
gokhlayeh@315 44 prepare_package()
gokhlayeh@315 45 {
gokhlayeh@315 46 tazwok clean $PACKAGE
gokhlayeh@315 47 tazwok get-src $PACKAGE
gokhlayeh@315 48 unset SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
gokhlayeh@315 49 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED
gokhlayeh@315 50 . $WOK/$PACKAGE/receipt
gokhlayeh@315 51 src=$WOK/$PACKAGE/$PACKAGE-$VERSION
gokhlayeh@315 52 cd $WOK/$PACKAGE
gokhlayeh@315 53 }
gokhlayeh@315 54 LOCAL_REPOSITORY=$SLITAZ_DIR/$SLITAZ_VERSION
gokhlayeh@315 55 [ "$undigest" ] && LOCAL_REPOSITORY=$SLITAZ_DIR/$undigest
gokhlayeh@315 56 WOK=$LOCAL_REPOSITORY/wok
gokhlayeh@315 57
gokhlayeh@315 58 report end-step
gokhlayeh@315 59
gokhlayeh@315 60 # Binutils and gcc need to be compiled twice.
gokhlayeh@315 61 for PACKAGE in binutils gcc; do
gokhlayeh@315 62 rm $LOCAL_REPOSITORY/log/tmp-toolchain-$PACKAGE-firstpass.html 2>/dev/null
gokhlayeh@315 63 report sublog $LOCAL_REPOSITORY/log/tmp-toolchain-$PACKAGE-firstpass.html
gokhlayeh@315 64 report step "Compiling $PACKAGE, first pass"
gokhlayeh@315 65 report open-bloc
gokhlayeh@315 66 prepare_package
gokhlayeh@315 67 report step "Running compilation rules"
gokhlayeh@315 68 precook_tmp_toolchain
gokhlayeh@315 69 report end-step || exit 1
gokhlayeh@315 70 report close-bloc
gokhlayeh@315 71 report end-sublog
gokhlayeh@315 72 done
gokhlayeh@315 73
gokhlayeh@315 74 # Compile temporary toolchain using the $TOOLCHAIN variable.
gokhlayeh@315 75 for PACKAGE in $SLITAZ_TOOLCHAIN; do
gokhlayeh@315 76 rm $LOCAL_REPOSITORY/log/tmp-toolchain-$PACKAGE.html 2>/dev/null
gokhlayeh@315 77 report sublog $LOCAL_REPOSITORY/log/tmp-toolchain-$PACKAGE.html
gokhlayeh@315 78 report step "Compiling $PACKAGE"
gokhlayeh@315 79 report open-bloc
gokhlayeh@315 80 prepare_package
gokhlayeh@315 81 report step "Running compilation rules"
gokhlayeh@315 82
gokhlayeh@315 83 # Use compile_rules if there's not function cook_tmp_toolchain in
gokhlayeh@315 84 # the receipt. Works well if both functions are the same, as
gokhlayeh@315 85 # cook-toolchain use it's own config.site to set different defaults
gokhlayeh@315 86 # pathes.
gokhlayeh@315 87 if grep -q ^cook_tmp_toolchain\(\)$ $WOK/$PACKAGE/receipt; then
gokhlayeh@315 88 cook_tmp_toolchain
gokhlayeh@315 89 else
gokhlayeh@315 90 compile_rules
gokhlayeh@315 91 fi
gokhlayeh@315 92
gokhlayeh@315 93 report end-step || exit 1
gokhlayeh@315 94 report close-bloc
gokhlayeh@315 95 report end-sublog
gokhlayeh@315 96 done
gokhlayeh@315 97
gokhlayeh@315 98 # Now we erase previous chroot tools and we switch to temporary
gokhlayeh@315 99 # toolchain.
gokhlayeh@315 100
gokhlayeh@315 101 report step "Setting up temporary toolchain environnment"
gokhlayeh@315 102
gokhlayeh@315 103 PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin:/tools/usr/bin:/tools/sbin:/tools/usr/sbin
gokhlayeh@315 104 export PATH
gokhlayeh@315 105
gokhlayeh@315 106 # Ajout manuel de libtaz et tazwok dans ce chroot.
gokhlayeh@315 107 cp -a /etc/slitaz/tazpkg.conf /tmp/tazpkg.conf
gokhlayeh@315 108 mkdir -p /tmp/backup/var/lib/tazpkg
gokhlayeh@315 109 sed 's/^AUTO_INSTALL_DEPS="yes"/AUTO_INSTALL_DEPS="no"/' -i \
gokhlayeh@315 110 /etc/slitaz/tazpkg.conf
gokhlayeh@334 111 BASE_PKGS="tazpkg tazwok slitaz-base-files libtaz"
gokhlayeh@315 112 for i in $BASE_PKGS; do
gokhlayeh@315 113 echo N | tazpkg get-install $i --root=/tmp/backup --forced
gokhlayeh@315 114 done
gokhlayeh@315 115 mkdir -p /tmp/backup/var/log/slitaz /tmp/backup/etc/slitaz
gokhlayeh@315 116 if [ -d /var/log/slitaz ]; then
gokhlayeh@315 117 cp -a /var/log/slitaz/* /tmp/backup/var/log/slitaz
gokhlayeh@315 118 fi
gokhlayeh@322 119 cp -a /var/lib/tazpkg/* /tmp/backup/var/lib/tazpkg
gokhlayeh@315 120 cp -a /etc/slitaz/* /tmp/backup/etc/slitaz
gokhlayeh@315 121 cp -a /tmp/tazpkg.conf /tmp/backup/etc/slitaz
gokhlayeh@315 122 cp -a /etc/resolv.conf /tmp/backup/etc
gokhlayeh@315 123
gokhlayeh@322 124 # Switch to temp toolchain tools entirely.
gokhlayeh@315 125 rm -r /bin /etc /lib /sbin /usr /var
gokhlayeh@315 126 cp -a /tmp/backup/* /
gokhlayeh@322 127 rm -r /tmp/backup
gokhlayeh@315 128
gokhlayeh@315 129 case $ARCH in
gokhlayeh@315 130 x86_64) ln -sv lib /lib64 && ln -sv lib /usr/lib64 ;;
gokhlayeh@315 131 esac
gokhlayeh@315 132
gokhlayeh@315 133 mkdir -p /bin /usr/bin /usr/lib
gokhlayeh@315 134 # doing a loop so we don't get {bash,cat,echo,pwd,stty} softlink
gokhlayeh@315 135 BASIC_APPS="bash cat echo pwd stty"
gokhlayeh@315 136 for i in $BASIC_APPS; do
gokhlayeh@315 137 ln -s /tools/bin/$i /bin/$i
gokhlayeh@315 138 done
gokhlayeh@315 139 BASIC_LIBS="libgcc_s.so libgcc_s.so.1 libstdc++.so libstdc++.so.6"
gokhlayeh@315 140 for i in $BASIC_LIBS; do
gokhlayeh@315 141 ln -sf /tools/lib/$i /usr/lib/$i
gokhlayeh@315 142 done
gokhlayeh@315 143
gokhlayeh@315 144 ln -s /tools/bin/perl /usr/bin
gokhlayeh@315 145 ln -s /tools/bin/gettext.sh /usr/bin
gokhlayeh@322 146 ln -s /tools/bin/busybox /bin/sh
gokhlayeh@315 147
gokhlayeh@315 148 report end-step
gokhlayeh@315 149
gokhlayeh@315 150 # Finally, cook final* version of the toolchain packages.
gokhlayeh@315 151 # * : recook toolchain against itself minus linux-api-headers
gokhlayeh@315 152 # glibc binutils & gcc can be a good idea to make things
gokhlayeh@315 153 # more robust & stable; in some cases it solves dependencies
gokhlayeh@315 154 # loops.
gokhlayeh@315 155
gokhlayeh@315 156 # Incoming packages as the only source for packages.
gokhlayeh@315 157 rm -r /var/lib/tazpkg/undigest
gokhlayeh@315 158 tazpkg setup-mirror $SLITAZ_DIR/${undigest:-$SLITAZ_VERSION}/packages-incoming
gokhlayeh@315 159 tazpkg recharge
gokhlayeh@315 160
gokhlayeh@315 161 # Get toolchain cooklist.
gokhlayeh@315 162 tazwok gen-cooklist ${undigest:+--undigest=$undigest} > /tmp/toolchain.list
gokhlayeh@315 163
gokhlayeh@315 164 # Next cook packages one by one.
gokhlayeh@315 165 # Cooking the list doesn't works because sh wouldn't take care
gokhlayeh@315 166 # of the presence of new executables even if they're first in
gokhlayeh@315 167 # $PATH.
gokhlayeh@315 168
gokhlayeh@334 169 cat /tmp/cooklist | while read PACKAGE; do
gokhlayeh@315 170 tazwok cook $PACKAGE || exit 1
gokhlayeh@315 171 done