tazwok view 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
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 stuff=$WOK/$PACKAGE/stuff
74 [ "$WANTED" ] && wanted_stuff=$WOK/$WANTED/stuff
75 cd $WOK/$PACKAGE
76 }
78 # Binutils and gcc need to be compiled twice.
79 for PACKAGE in binutils gcc; do
80 rm $LOCAL_REPOSITORY/log/tmp-toolchain-$PACKAGE-firstpass.html 2>/dev/null
81 report sublog $LOCAL_REPOSITORY/log/tmp-toolchain-$PACKAGE-firstpass.html
82 echo "tmp-toolchain-$PACKAGE-firstpass" > $LOCAL_REPOSITORY/log/package
83 report step "Compiling $PACKAGE, first pass"
84 report open-bloc
85 prepare_package
86 report step "Running compilation rules"
87 precook_tmp_toolchain
88 report end-step || exit 1
89 report close-bloc
90 report end-sublog
91 done
93 # Compile temporary toolchain using the $TOOLCHAIN variable.
94 for PACKAGE in $SLITAZ_TOOLCHAIN; do
95 rm $LOCAL_REPOSITORY/log/tmp-toolchain-$PACKAGE.html 2>/dev/null
96 report sublog $LOCAL_REPOSITORY/log/tmp-toolchain-$PACKAGE.html
97 echo "tmp-toolchain-$PACKAGE" > $LOCAL_REPOSITORY/log/package
98 report step "Compiling $PACKAGE"
99 report open-bloc
100 prepare_package
101 report step "Running compilation rules"
103 # Use compile_rules if there's no function cook_tmp_toolchain in
104 # the receipt. Works well if both functions are the same, as
105 # cook-toolchain uses its own config.site to set different default
106 # paths.
107 if grep -q ^cook_tmp_toolchain\(\)$ $WOK/$PACKAGE/receipt; then
108 cook_tmp_toolchain
109 else
110 compile_rules
111 fi
113 report end-step || exit 1
114 report close-bloc
115 report end-sublog
116 done
118 # Now we erase previous chroot tools and switch to temporary
119 # toolchain.
121 report step "Setting up temporary toolchain environnment"
123 PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin:/tools/usr/bin:/tools/sbin:/tools/usr/sbin
124 export PATH
126 # Ajout manuel de libtaz et tazwok dans ce chroot.
127 cp -a /etc/slitaz/tazpkg.conf /tmp/tazpkg.conf
128 mkdir -p /tmp/backup/var/lib/tazpkg
129 sed 's/^AUTO_INSTALL_DEPS="yes"/AUTO_INSTALL_DEPS="no"/' -i \
130 /etc/slitaz/tazpkg.conf
131 cp -a /var/lib/tazpkg/* /tmp/backup/var/lib/tazpkg
132 BASE_PKGS="tazpkg tazwok slitaz-base-files libtaz"
133 for i in $BASE_PKGS; do
134 echo N | tazpkg get-install $i --root=/tmp/backup --forced
135 done
136 mkdir -p /tmp/backup/var/log/slitaz /tmp/backup/etc/slitaz
137 if [ -d /var/log/slitaz ]; then
138 cp -a /var/log/slitaz/* /tmp/backup/var/log/slitaz
139 fi
140 cp -a /etc/slitaz/* /tmp/backup/etc/slitaz
141 cp -a /tmp/tazpkg.conf /tmp/backup/etc/slitaz
142 cp -a /etc/resolv.conf /tmp/backup/etc
144 # Switch to temp toolchain tools entirely.
145 rm -r /bin /etc /lib /sbin /usr /var
146 cp -a /tmp/backup/* /
147 rm -r /tmp/backup
149 case $ARCH in
150 x86_64) ln -sv lib /lib64 && ln -sv lib /usr/lib64 ;;
151 esac
153 mkdir -p /bin /usr/bin /usr/lib
154 # Doing a loop so we don't get {bash,cat,echo,pwd,stty} softlink
155 BASIC_APPS="bash cat echo pwd stty"
156 for i in $BASIC_APPS; do
157 ln -s /tools/bin/$i /bin/$i
158 done
159 BASIC_LIBS="libgcc_s.so libgcc_s.so.1 libstdc++.so libstdc++.so.6 ld*.so"
160 for i in $BASIC_LIBS; do
161 ln -sf /tools/lib/$i /usr/lib/$i
162 done
164 ln -s /tools/bin/perl /usr/bin
165 ln -s /tools/bin/gettext.sh /usr/bin
166 ln -s /tools/bin/busybox /bin/sh
168 # Touch /etc/config.site.tmptoolchain to make tazwok know
169 # we still cook the toolchain.
170 # (= non-conventional repositories configuration into chroot).
171 touch /etc/config.site.tmptoolchain
173 report end-step
175 # Finally, cook final* version of the toolchain packages.
176 # * : recook toolchain against itself minus linux-api-headers
177 # glibc binutils & gcc can be a good idea to make things
178 # more robust & stable; in some cases it solves dependency
179 # loops.
181 # Get toolchain cooklist.
182 tazwok gen-cooklist ${undigest:+--undigest=$undigest} > /tmp/toolchain.list
184 # Next cook packages one by one.
185 # Cooking the list doesn't work because sh won't take care
186 # of the presence of new executables even if they're first in
187 # $PATH.
189 cat /tmp/toolchain.list | while read PACKAGE; do
190 tazwok cook $PACKAGE || exit 1
191 done