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

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