tazwok view chroot-scripts/cook-toolchain @ rev 352

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