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