cookutils view cooklinux @ rev 728

Move to using short i18n functions with "printf", so rewrite sources and po files. Fix: stripping before list files (python packages listed missed .pyc files). Also remove few hacks from code, make pot and msgmerge.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu May 07 15:11:47 2015 +0300 (2015-05-07)
parents 14605a8b8489
children 0b59118bbd03
line source
1 #!/bin/sh
2 #
3 # Simple utility to compile from scratch a custom Linux kernel on SliTaz.
4 # No patches, aufs and co, keep it simple. The goal is to let users build
5 # a custom and optimized kernel in a few commands
6 #
7 # Copyright (C) 2014-15 SliTaz GNU/Linux - BSD License
8 #
9 # Author: Christophe Lincoln <pankso@slitaz.org>
10 #
12 . /lib/libtaz.sh
13 . /etc/slitaz/slitaz.conf
15 version="$1"
16 cookdir='/home/slitaz/src'
17 srcurl='https://www.kernel.org/pub/linux/kernel'
19 check_root
22 # Help and usage
24 usage() {
25 cat <<EOT
27 SliTaz Linux Kernel cooker
29 $(boldify 'Usage:') $(basename $0) [version] [--options]
31 $(boldify 'Options:')
32 --clean Remove various generated files but keep the config
33 --mrproper Remove all generated files + config + backup files
34 --defconfig New config with default from ARCH supplied defconfig
35 --tazconfig New config using current SliTaz /proc/config.gz
36 --localmod Update config removing all unloaded modules
37 --config Update current config with a text based front-end
38 --menuconfig Update current config with a menu based program
39 --xconfig Update current config with a QT based front-end
40 --gconfig Update current config with a GTK based front-end
41 --bzImage Build the compressed kernel image
42 --modules Build all kernel modules
44 $(boldify 'Examples:')
45 $(basename $0) 3.8.3 --defconfig --menuconfig --bzImage
46 $(basename $0) 3.2.14 --tazconfig --bzImage --modules
48 EOT
49 }
52 # Check and install a packages
54 check_pkg() {
55 if [ ! -f "$PKGS_DB/installed/$1/receipt" ]; then
56 echo -n "Installing package:"; colorize 34 " $1"
57 tazpkg -gi $1 2>/dev/null >/dev/null
58 fi
59 }
62 #
63 # Commands/help - Support 3.x 2.6 and 2.4 kernels.
64 #
66 case "$1" in
67 3.*) wgeturl="${srcurl}/v3.0/" ;;
68 2.6.*) wgeturl="${srcurl}/v2.6/" ;;
69 2.4.*) wgeturl="${srcurl}/v2.4/" ;;
70 -h|-u|help|usage|"")
71 usage; exit 0 ;;
72 esac
75 # Sanity check
76 if [ -z "$wgeturl" ]; then
77 echo 'Unable to set download url';
78 exit 0
79 fi
82 #
83 # Build start
84 #
86 echo -n 'Building Linux kernel:'; colorize 32 " $version"
87 echo -n 'Source directory:'; colorize 30 " $cookdir"
89 # Install needed packages to compile.
90 for pkg in slitaz-toolchain perl xz lzma patch tar bc; do
91 check_pkg $pkg
92 done
94 # Get the source and extract tarball.
95 mkdir -p $cookdir && cd $cookdir || exit 1
96 if [ ! -f "linux-$version.tar.xz" ]; then
97 echo "Downloading Linux kernel source..."
98 wget -c --no-check-certificate ${wgeturl}linux-$version.tar.xz
99 fi
100 if [ ! -d "linux-$version" ]; then
101 echo "Extracting: linux-$version.tar.xz"
102 unxz -c linux-$version.tar.xz | tar -xf -
103 fi
105 # Clean-up and get or update config
106 cd linux-$version
108 if [ -n "$clean" ]; then
109 make clean
110 rm -rf slitaz
111 fi
113 if [ -n "$mrproper" ]; then
114 make mrproper
115 rm -rf slitaz
116 fi
118 # Get SliTaz current config.
119 if [ -n "$tazconfig" ]; then
120 echo 'Using current SliTaz config: /proc/config.gz'
121 zcat /proc/config.gz > .config
122 yes '' | make oldconfig
123 fi
125 # Create a new default config.
126 if [ -n "$defconfig" ]; then
127 make defconfig
128 fi
130 # Update config and wipe out unloaded modules.
131 if [ -n "$localmod" ]; then
132 make localmodconfig
133 fi
136 #
137 # Configurators text/ncurses/Qt/GTK
138 #
140 if [ -n "$config" ]; then
141 echo 'Starting Text mode configuration tool...'
142 make config
143 fi
145 if [ -n "$menuconfig" ]; then
146 echo 'Starting Ncurses configuration tool...'
147 check_pkg ncurses-dev
148 make menuconfig
149 fi
151 if [ -n "$xconfig" ]; then
152 echo 'Starting Qt configuration tool...'
153 check_pkg qt-4
154 make xconfig
155 fi
157 if [ -n "$gconfig" ]; then
158 echo 'Starting GTK+ configuration tool...'
159 check_pkg gtk+-dev
160 check_pkg libglade-dev
161 make gconfig
162 fi
164 if [ -n "$bzImage" ]; then
165 echo 'Building bzImage...'
166 make bzImage || exit 1
167 mkdir -p slitaz/linux-custom-$version/fs/boot
168 cp -f arch/x86/boot/bzImage \
169 slitaz/linux-custom-$version/fs/boot/vmlinuz-$version
170 fi
172 if [ -n "$modules" ]; then
173 echo 'Building modules...'
174 make modules || exit 1
175 make INSTALL_MOD_PATH=slitaz/linux-custom-$version/fs modules_install
176 rm -f slitaz/linux-custom-$version/fs/lib/modules/$version/build
177 rm -f slitaz/linux-custom-$version/fs/lib/modules/$version/source
178 fi
181 #
182 # Packaging
183 #
185 if [ -d "slitaz/linux-custom-$version/fs" ]; then
186 echo 'Packing Linux...'
187 cd slitaz
188 else
189 echo -n 'Packing Linux:'; colorize 31 ' not yet built'
190 exit 0
191 fi
193 # Receipt.
194 echo 'Creating the receipt...'
195 cat > linux-custom-$version/receipt <<EOF
196 # SliTaz package receipt.
198 PACKAGE="linux-custom"
199 VERSION="$version"
200 CATEGORY="base-system"
201 SHORT_DESC="The Linux kernel and modules."
202 MAINTAINER="devel@slitaz.org"
203 WEB_SITE="http://www.kernel.org/"
205 DEPENDS="kmod"
207 ## Pre and post install commands for Tazpkg.
208 post_install()
209 {
210 echo "Processing post-install commands..."
211 depmod -a \$VERSION-custom
212 echo "Check your GRUB menu.lst to boot your new kernel"
213 }
215 EOF
217 ## Pre and post install commands for Tazpkg/Spk.
218 #post_install()
219 #{
220 #echo "Processing post-install commands..."
221 #chroot "\$1/" depmod -a \$VERSION
222 ## GRUB stuff.
223 #if [ -f "\$1/boot/grub/menu.lst" ]; then
224 #root_dev=\$(cat $1/boot/grub/menu.lst | grep root= | sed 's/.*root=\([^ ]*\).*/\1/' | head -n 1)
225 #grub_dev=\$(cat $1/boot/grub/menu.lst | grep "root (" | head -n 1)
226 ## Add new kernel entry in case of upgrade for installed system.
227 #if ! grep -q vmlinuz-\$VERSION \$1/boot/grub/menu.lst; then
228 #cat >> \$1/boot/grub/menu.lst << EOT
230 #title SliTaz GNU/Linux (Kernel \$VERSION)
231 #\$grub_dev
232 #kernel /boot/vmlinuz-\$VERSION root=\$root_dev
233 #EOT
234 #fi
235 #}
237 # Pack it.
238 tazpkg pack linux-custom-$version
240 # Install the new kernel.
241 if [ -n "$install" ]; then
242 cd $cookdir/linux-$version/slitaz
243 tazpkg -i linux-custom-$version.tazpkg --forced
244 fi
246 exit 0