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

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