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

Move tazwok-related chroot scripts from tazchroot to tazwok sources
author Antoine Bodin <gokhlayeh@slitaz.org>
date Fri Feb 18 18:13:38 2011 +0100 (2011-02-18)
parents
children 32b8fbc44418
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
8 source_lib report
9 report start
11 report step "Cooking temporary toolchain"
12 report open-bloc
14 report step "Initializing tools & environment"
16 # Theses fours packages will be needed later.
17 for p in libtaz tazwok-experimental slitaz-base-files tazpkg; do
18 tazwok cook $p
19 done
21 set +h
22 umask 022
23 PS1='\u:\w\$ '
24 LANG=POSIX
25 LC_ALL=POSIX
27 # Set BUILD_HOST to something like $ARCH-tmp-linux-gnu to enable
28 # of the temporary toolchain.
29 BUILD_HOST=$(echo $BUILD_HOST | sed 's/\(.*\)-\(.*\)-linux-gnu/\1-tmp-linux-gnu/')
31 PATH=/tools/bin:/tools/usr/bin:/tools/sbin:/tools/usr/sbin:/bin:/usr/bin:/sbin:/usr/sbin
32 CONFIG_SITE="/etc/config.site.tmptoolchain"
33 echo 'prefix=/tools' > /etc/config.site.tmptoolchain
35 export LANG LC_ALL PATH PS1 MAKEFLAGS CONFIG_SITE
36 unset CC CXX CPP CFLAGS CXXFLAGS LD_LIBRARY_PATH LD_PRELOAD DESTDIR
38 # Create the dir for the temporary toolchain and link in root of host
39 # system.
40 [ -d /tools ] && rm -r /tools
41 mkdir /tools
43 # Use some tweaked code from tazwok.
44 prepare_package()
45 {
46 tazwok clean $PACKAGE
47 tazwok get-src $PACKAGE
48 unset SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
49 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED
50 . $WOK/$PACKAGE/receipt
51 src=$WOK/$PACKAGE/$PACKAGE-$VERSION
52 cd $WOK/$PACKAGE
53 }
54 LOCAL_REPOSITORY=$SLITAZ_DIR/$SLITAZ_VERSION
55 [ "$undigest" ] && LOCAL_REPOSITORY=$SLITAZ_DIR/$undigest
56 WOK=$LOCAL_REPOSITORY/wok
58 report end-step
60 # Binutils and gcc need to be compiled twice.
61 for PACKAGE in binutils gcc; do
62 rm $LOCAL_REPOSITORY/log/tmp-toolchain-$PACKAGE-firstpass.html 2>/dev/null
63 report sublog $LOCAL_REPOSITORY/log/tmp-toolchain-$PACKAGE-firstpass.html
64 report step "Compiling $PACKAGE, first pass"
65 report open-bloc
66 prepare_package
67 report step "Running compilation rules"
68 precook_tmp_toolchain
69 report end-step || exit 1
70 report close-bloc
71 report end-sublog
72 done
74 # Compile temporary toolchain using the $TOOLCHAIN variable.
75 for PACKAGE in $SLITAZ_TOOLCHAIN; do
76 rm $LOCAL_REPOSITORY/log/tmp-toolchain-$PACKAGE.html 2>/dev/null
77 report sublog $LOCAL_REPOSITORY/log/tmp-toolchain-$PACKAGE.html
78 report step "Compiling $PACKAGE"
79 report open-bloc
80 prepare_package
81 report step "Running compilation rules"
83 # Use compile_rules if there's not function cook_tmp_toolchain in
84 # the receipt. Works well if both functions are the same, as
85 # cook-toolchain use it's own config.site to set different defaults
86 # pathes.
87 if grep -q ^cook_tmp_toolchain\(\)$ $WOK/$PACKAGE/receipt; then
88 cook_tmp_toolchain
89 else
90 compile_rules
91 fi
93 report end-step || exit 1
94 report close-bloc
95 report end-sublog
96 done
98 # Now we erase previous chroot tools and we switch to temporary
99 # toolchain.
101 report step "Setting up temporary toolchain environnment"
103 PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin:/tools/usr/bin:/tools/sbin:/tools/usr/sbin
104 export PATH
106 # Ajout manuel de libtaz et tazwok dans ce chroot.
107 cp -a /etc/slitaz/tazpkg.conf /tmp/tazpkg.conf
108 mkdir -p /tmp/backup/var/lib/tazpkg
109 cp -a /var/lib/tazpkg/* /tmp/backup/var/lib/tazpkg
110 sed 's/^AUTO_INSTALL_DEPS="yes"/AUTO_INSTALL_DEPS="no"/' -i \
111 /etc/slitaz/tazpkg.conf
112 BASE_PKGS="tazpkg tazwok-experimental slitaz-base-files libtaz"
113 for i in $BASE_PKGS; do
114 echo N | tazpkg get-install $i --root=/tmp/backup --forced
115 done
116 mkdir -p /tmp/backup/var/log/slitaz /tmp/backup/etc/slitaz
117 if [ -d /var/log/slitaz ]; then
118 cp -a /var/log/slitaz/* /tmp/backup/var/log/slitaz
119 fi
120 cp -a /etc/slitaz/* /tmp/backup/etc/slitaz
121 cp -a /tmp/tazpkg.conf /tmp/backup/etc/slitaz
122 cp -a /etc/resolv.conf /tmp/backup/etc
123 # make sure that if /bin/sh link is not delete we use bash in tools for sh
124 # otherwise you may get sigment fail
125 mkdir -p /tmp/backup/bin
126 ln -s /tools/bin/bash /tmp/backup/bin/sh
128 rm -r /bin /etc /lib /sbin /usr /var
129 cp -a /tmp/backup/* /
130 #rm -r /tmp/backup
132 case $ARCH in
133 x86_64) ln -sv lib /lib64 && ln -sv lib /usr/lib64 ;;
134 esac
136 mkdir -p /bin /usr/bin /usr/lib
137 # doing a loop so we don't get {bash,cat,echo,pwd,stty} softlink
138 BASIC_APPS="bash cat echo pwd stty"
139 for i in $BASIC_APPS; do
140 ln -s /tools/bin/$i /bin/$i
141 done
142 BASIC_LIBS="libgcc_s.so libgcc_s.so.1 libstdc++.so libstdc++.so.6"
143 for i in $BASIC_LIBS; do
144 ln -sf /tools/lib/$i /usr/lib/$i
145 done
147 ln -s /tools/bin/perl /usr/bin
148 ln -s /tools/bin/gettext.sh /usr/bin
150 report end-step
152 # Finally, cook final* version of the toolchain packages.
153 # * : recook toolchain against itself minus linux-api-headers
154 # glibc binutils & gcc can be a good idea to make things
155 # more robust & stable; in some cases it solves dependencies
156 # loops.
158 # Incoming packages as the only source for packages.
159 rm -r /var/lib/tazpkg/undigest
160 tazpkg setup-mirror $SLITAZ_DIR/${undigest:-$SLITAZ_VERSION}/packages-incoming
161 tazpkg recharge
163 # Get toolchain cooklist.
164 tazwok gen-cooklist ${undigest:+--undigest=$undigest} > /tmp/toolchain.list
166 # Next cook packages one by one.
167 # Cooking the list doesn't works because sh wouldn't take care
168 # of the presence of new executables even if they're first in
169 # $PATH.
171 cat /tmp/toolchain.list | while read PACKAGE; do
172 tazwok cook $PACKAGE || exit 1
173 done