cookutils view cooklinux @ rev 840

Update translations.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sat Nov 19 22:48:02 2016 +0200 (2016-11-19)
parents da66e6be1add
children 9611369825b9
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 4.x, 3.x, 2.6 and 2.4 kernels.
64 #
66 case "$1" in
67 4.*) wgeturl="${srcurl}/v4.x/" ;;
68 3.*) wgeturl="${srcurl}/v3.0/" ;;
69 2.6.*) wgeturl="${srcurl}/v2.6/" ;;
70 2.4.*) wgeturl="${srcurl}/v2.4/" ;;
71 -h|-u|help|usage|"")
72 usage; exit 0 ;;
73 esac
76 # Sanity check
77 if [ -z "$wgeturl" ]; then
78 echo 'Unable to set download url';
79 exit 0
80 fi
83 #
84 # Build start
85 #
87 echo -n 'Building Linux kernel:'; colorize 32 " $version"
88 echo -n 'Source directory:'; colorize 30 " $cookdir"
90 # Install needed packages to compile.
91 for pkg in slitaz-toolchain pkg-config perl xz lzma patch tar bc; do
92 check_pkg $pkg
93 done
95 # Get the source and extract tarball.
96 mkdir -p $cookdir && cd $cookdir || exit 1
97 if [ ! -f "linux-$version.tar.xz" ]; then
98 echo "Downloading Linux kernel source..."
99 wget -c --no-check-certificate ${wgeturl}linux-$version.tar.xz
100 fi
101 if [ ! -d "linux-$version" ]; then
102 echo "Extracting: linux-$version.tar.xz"
103 unxz -c linux-$version.tar.xz | tar -xf -
104 fi
106 # Clean-up and get or update config
107 cd linux-$version
109 if [ -n "$clean" ]; then
110 make clean
111 rm -rf slitaz
112 fi
114 if [ -n "$mrproper" ]; then
115 make mrproper
116 rm -rf slitaz
117 fi
119 # Get SliTaz current config.
120 if [ -n "$tazconfig" ]; then
121 echo 'Using current SliTaz config: /proc/config.gz'
122 zcat /proc/config.gz > .config
123 yes '' | make oldconfig
124 fi
126 # Create a new default config.
127 if [ -n "$defconfig" ]; then
128 make defconfig
129 fi
131 # Update config and wipe out unloaded modules.
132 if [ -n "$localmod" ]; then
133 make localmodconfig
134 fi
137 #
138 # Configurators text/ncurses/Qt/GTK
139 #
141 if [ -n "$config" ]; then
142 echo 'Starting Text mode configuration tool...'
143 make config
144 fi
146 if [ -n "$menuconfig" ]; then
147 echo 'Starting Ncurses configuration tool...'
148 check_pkg ncurses-dev
149 make menuconfig
150 fi
152 if [ -n "$xconfig" ]; then
153 echo 'Starting Qt configuration tool...'
154 check_pkg Qt4-dev
155 make xconfig
156 fi
158 if [ -n "$gconfig" ]; then
159 echo 'Starting GTK+ configuration tool...'
160 check_pkg gtk+-dev
161 check_pkg libglade-dev
162 make gconfig
163 fi
165 if [ -n "$bzImage" ]; then
166 echo 'Building bzImage...'
167 make bzImage || exit 1
168 mkdir -p slitaz/linux-custom-$version/fs/boot
169 cp -f arch/x86/boot/bzImage \
170 slitaz/linux-custom-$version/fs/boot/vmlinuz-$version
171 fi
173 if [ -n "$modules" ]; then
174 echo 'Building modules...'
175 make modules || exit 1
176 make INSTALL_MOD_PATH=slitaz/linux-custom-$version/fs modules_install
177 rm -f slitaz/linux-custom-$version/fs/lib/modules/$version/build
178 rm -f slitaz/linux-custom-$version/fs/lib/modules/$version/source
179 fi
182 #
183 # Packaging
184 #
186 if [ -d "slitaz/linux-custom-$version/fs" ]; then
187 echo 'Packing Linux...'
188 cd slitaz
189 else
190 echo -n 'Packing Linux:'; colorize 31 ' not yet built'
191 exit 0
192 fi
194 # Receipt.
195 echo 'Creating the receipt...'
196 cat > linux-custom-$version/receipt <<EOF
197 # SliTaz package receipt.
199 PACKAGE="linux-custom"
200 VERSION="$version"
201 CATEGORY="base-system"
202 SHORT_DESC="The Linux kernel and modules."
203 MAINTAINER="devel@slitaz.org"
204 WEB_SITE="http://www.kernel.org/"
206 DEPENDS="kmod"
208 ## Pre and post install commands for Tazpkg.
209 post_install()
210 {
211 echo "Processing post-install commands..."
212 depmod -a \$VERSION-custom
213 echo "Check your GRUB menu.lst to boot your new kernel"
214 }
216 EOF
218 ## Pre and post install commands for Tazpkg/Spk.
219 #post_install()
220 #{
221 #echo "Processing post-install commands..."
222 #chroot "\$1/" depmod -a \$VERSION
223 ## GRUB stuff.
224 #if [ -f "\$1/boot/grub/menu.lst" ]; then
225 #root_dev=\$(cat $1/boot/grub/menu.lst | grep root= | sed 's/.*root=\([^ ]*\).*/\1/' | head -n 1)
226 #grub_dev=\$(cat $1/boot/grub/menu.lst | grep "root (" | head -n 1)
227 ## Add new kernel entry in case of upgrade for installed system.
228 #if ! grep -q vmlinuz-\$VERSION \$1/boot/grub/menu.lst; then
229 #cat >> \$1/boot/grub/menu.lst << EOT
231 #title SliTaz GNU/Linux (Kernel \$VERSION)
232 #\$grub_dev
233 #kernel /boot/vmlinuz-\$VERSION root=\$root_dev
234 #EOT
235 #fi
236 #}
238 # Pack it.
239 tazpkg pack linux-custom-$version
241 # Install the new kernel.
242 if [ -n "$install" ]; then
243 cd $cookdir/linux-$version/slitaz
244 tazpkg -i linux-custom-$version.tazpkg --forced
245 fi
247 exit 0