cookutils rev 633
Add cooklinux
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Wed Feb 12 23:25:33 2014 +0100 (2014-02-12) |
parents | c15756b25b4f |
children | a9ea304f81de |
files | Makefile cook cooklinux |
line diff
1.1 --- a/Makefile Wed Feb 12 23:21:58 2014 +0100 1.2 +++ b/Makefile Wed Feb 12 23:25:33 2014 +0100 1.3 @@ -24,6 +24,7 @@ 1.4 install -m 0755 cook $(DESTDIR)$(PREFIX)/bin 1.5 install -m 0755 cooker $(DESTDIR)$(PREFIX)/bin 1.6 install -m 0755 cookiso $(DESTDIR)$(PREFIX)/bin 1.7 + install -m 0755 cooklinux $(DESTDIR)$(PREFIX)/bin 1.8 install -m 0644 cook.conf $(DESTDIR)/etc/slitaz 1.9 install -m 0644 cook.site $(DESTDIR)/etc/slitaz 1.10 install -m 0644 web/* $(DESTDIR)/var/www/cgi-bin/cooker 1.11 @@ -40,6 +41,9 @@ 1.12 rm -rf \ 1.13 $(DESTDIR)$(PREFIX)/bin/cook \ 1.14 $(DESTDIR)$(PREFIX)/bin/cooker \ 1.15 + $(DESTDIR)$(PREFIX)/bin/cookiso \ 1.16 + $(DESTDIR)$(PREFIX)/bin/cooklinux \ 1.17 + $(DESTDIR)$(PREFIX)/share/cook \ 1.18 $(DESTDIR)/etc/slitaz/cook.* \ 1.19 $(DESTDIR)/var/www/cooker 1.20
2.1 --- a/cook Wed Feb 12 23:21:58 2014 +0100 2.2 +++ b/cook Wed Feb 12 23:25:33 2014 +0100 2.3 @@ -8,7 +8,7 @@ 2.4 # 2.5 . /usr/lib/slitaz/libcook.sh 2.6 2.7 -VERSION="3.1.4" 2.8 +VERSION="3.2" 2.9 2.10 # Internationalization. 2.11 . /usr/bin/gettext.sh
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/cooklinux Wed Feb 12 23:25:33 2014 +0100 3.3 @@ -0,0 +1,233 @@ 3.4 +#!/bin/sh 3.5 +# 3.6 +# Simple utility to compile from scratch a custom Linux kernel on SliTaz. 3.7 +# No patch, aufs and co, keep it simple. The goal is to let users build 3.8 +# a custom and optimized kernel in a few commands 3.9 +# 3.10 +# Copyright (C) 2014 SliTaz GNU/Linux - BSD License 3.11 +# 3.12 +# Author: Christophe Lincoln <pankso@slitaz.org> 3.13 +# 3.14 +. /lib/libtaz.sh 3.15 +. /etc/slitaz/slitaz.conf 3.16 + 3.17 +version="$1" 3.18 +cookdir="/home/slitaz/src" 3.19 +srcurl="https://www.kernel.org/pub/linux/kernel" 3.20 + 3.21 +check_root 3.22 + 3.23 +# Help and usage 3.24 +usage() { 3.25 + cat << EOT 3.26 + 3.27 +SliTaz Linux Kernel cooker 3.28 + 3.29 +$(boldify "Usage:") $(basename $0) [version] [--options] 3.30 + 3.31 +$(boldify "Options:") 3.32 + --clean Remove most generated files but keep the config 3.33 + --mrproper Remove all generated files + config + backup files 3.34 + --defconfig New config with default from ARCH supplied defconfig 3.35 + --tazconfig New config using current SliTaz /proc/config.gz 3.36 + --localmod Update config removing all unloaded modules 3.37 + --config Update current config with a text based front-end 3.38 + --menuconfig Update current config with a menu based program 3.39 + --xconfig Update current config with a QT based front-end 3.40 + --gconfig Update current config with a GTK based front-end 3.41 + --bzImage Build the compressed kernel image 3.42 + --modules Build all kernel modules 3.43 + 3.44 +$(boldify "Examples:") 3.45 + $(basename $0) 3.8.3 --defconfig --menuconfig --bzImage 3.46 + $(basename $0) 3.2.14 --tazconfig --bzImage --modules 3.47 + 3.48 +EOT 3.49 +} 3.50 + 3.51 +# Check and install a packages 3.52 +check_pkg() { 3.53 + if [ ! -f "$PKGS_DB/installed/$1/receipt" ]; then 3.54 + echo -n "Installing package:" && colorize 34 " $1" 3.55 + tazpkg -gi $1 2>/dev/null >/dev/null 3.56 + fi 3.57 +} 3.58 + 3.59 +# 3.60 +# Commands/help - Support 3.x 2.6 and 2.4 kernel's. 3.61 +# 3.62 +case "$1" in 3.63 + 3.*) wgeturl="${srcurl}/v3.0/" ;; 3.64 + 2.6.*) wgeturl="${srcurl}/v2.6/" ;; 3.65 + 2.4.*) wgeturl="${srcurl}/v2.4/" ;; 3.66 + -h|-u|help|usage|"") 3.67 + usage && exit 0 ;; 3.68 +esac 3.69 + 3.70 +# Sanity check 3.71 +[ ! "$wgeturl" ] && echo "Unable to set download url" && exit 0 3.72 + 3.73 +# 3.74 +# Build start 3.75 +# 3.76 + 3.77 +echo -n "Building Linux kernel:" && colorize 32 " $version" 3.78 +echo -n "Source directory:" && colorize 30 " $cookdir" 3.79 + 3.80 +# Install needed packages to compile. 3.81 +for pkg in slitaz-toolchain perl xz lzma patch tar bc 3.82 +do 3.83 + check_pkg $pkg 3.84 +done 3.85 + 3.86 +# Get the source and extract tarball. 3.87 +mkdir -p $cookdir && cd $cookdir || exit 1 3.88 +if [ ! -f "linux-$version.tar.xz" ]; then 3.89 + echo "Downloading Linux kernel source..." 3.90 + wget -c --no-check-certificate ${wgeturl}linux-$version.tar.xz 3.91 +fi 3.92 +if [ ! -d "linux-$version" ]; then 3.93 + echo "Extracting: linux-$version.tar.xz" 3.94 + unxz -c linux-$version.tar.xz | tar xf - 3.95 +fi 3.96 + 3.97 +# Clean-up and get or update config 3.98 +cd linux-$version 3.99 + 3.100 +if [ "$clean" ]; then 3.101 + make clean 3.102 + rm -rf slitaz 3.103 +fi 3.104 + 3.105 +if [ "$mrproper" ]; then 3.106 + make mrproper 3.107 + rm -rf slitaz 3.108 +fi 3.109 + 3.110 +# Get SliTaz current config. 3.111 +if [ "$tazconfig" ]; then 3.112 + echo "Using current SliTaz config: /proc/config.gz" 3.113 + zcat /proc/config.gz > .config 3.114 + yes '' | make oldconfig 3.115 +fi 3.116 + 3.117 +# Create a new default config. 3.118 +if [ "$defconfig" ]; then 3.119 + make defconfig 3.120 +fi 3.121 + 3.122 +# Update config and wipe out unloaded modules. 3.123 +if [ "$localmod" ]; then 3.124 + make localmodconfig 3.125 +fi 3.126 + 3.127 +# 3.128 +# Configurators text/ncurses/Qt/GTK 3.129 +# 3.130 + 3.131 +if [ "$config" ]; then 3.132 + echo "Starting Text mode configuration tool..." 3.133 + make config 3.134 +fi 3.135 + 3.136 +if [ "$menuconfig" ]; then 3.137 + echo "Starting Ncurses configuration tool..." 3.138 + check_pkg ncurses-dev 3.139 + make menuconfig 3.140 +fi 3.141 + 3.142 +if [ "$xconfig" ]; then 3.143 + echo "Starting QT configuration tool..." 3.144 + check_pkg qt-4 3.145 + make xconfig 3.146 +fi 3.147 + 3.148 +if [ "$gconfig" ]; then 3.149 + echo "Starting GTK+ configuration tool..." 3.150 + check_pkg gtk+-dev 3.151 + check_pkg libglade-dev 3.152 + make gconfig 3.153 +fi 3.154 + 3.155 +if [ "$bzImage" ]; then 3.156 + echo "Building bzImage..." 3.157 + make bzImage || exit 1 3.158 + mkdir -p slitaz/linux-custom-$version/fs/boot 3.159 + cp -f arch/x86/boot/bzImage \ 3.160 + slitaz/linux-custom-$version/fs/boot/vmlinuz-$version 3.161 +fi 3.162 + 3.163 +if [ "$modules" ]; then 3.164 + echo "Building modules..." 3.165 + make modules || exit 1 3.166 + make INSTALL_MOD_PATH=slitaz/linux-custom-$version/fs modules_install 3.167 + rm -f slitaz/linux-custom-$version/fs/lib/modules/$version/build 3.168 + rm -f slitaz/linux-custom-$version/fs/lib/modules/$version/source 3.169 +fi 3.170 + 3.171 +# 3.172 +# Packaging 3.173 +# 3.174 + 3.175 +if [ -d "slitaz/linux-custom-$version/fs" ]; then 3.176 + echo "Packing Linux..." 3.177 + cd slitaz 3.178 +else 3.179 + echo -n "Packing Linux:" && colorize 31 " not yet build" 3.180 + exit 0 3.181 +fi 3.182 + 3.183 +# Receipt. 3.184 +echo "Creating the receipt..." 3.185 +cat > linux-custom-$version/receipt << EOF 3.186 +# SliTaz package receipt. 3.187 + 3.188 +PACKAGE="linux-custom" 3.189 +VERSION="$version" 3.190 +CATEGORY="base-system" 3.191 +SHORT_DESC="The Linux kernel and modules." 3.192 +MAINTAINER="devel@slitaz.org" 3.193 +WEB_SITE="http://www.kernel.org/" 3.194 + 3.195 +DEPENDS="kmod" 3.196 + 3.197 +## Pre and post install commands for Tazpkg. 3.198 +post_install() 3.199 +{ 3.200 + echo "Processing post-install commands..." 3.201 + depmod -a \$VERSION-custom 3.202 + echo "Check your GRUB menu.lst to boot your new kernel" 3.203 +} 3.204 + 3.205 +EOF 3.206 + 3.207 +## Pre and post install commands for Tazpkg/Spk. 3.208 +#post_install() 3.209 +#{ 3.210 + #echo "Processing post-install commands..." 3.211 + #chroot "\$1/" depmod -a \$VERSION 3.212 + ## GRUB stuff. 3.213 + #if [ -f "\$1/boot/grub/menu.lst" ]; then 3.214 + #root_dev=\$(cat $1/boot/grub/menu.lst | grep root= | sed 's/.*root=\([^ ]*\).*/\1/' | head -n 1) 3.215 + #grub_dev=\$(cat $1/boot/grub/menu.lst | grep "root (" | head -n 1) 3.216 + ## Add new kernel entry in case of upgrade for installed system. 3.217 + #if ! grep -q vmlinuz-\$VERSION \$1/boot/grub/menu.lst; then 3.218 + #cat >> \$1/boot/grub/menu.lst << EOT 3.219 + 3.220 +#title SliTaz GNU/Linux (Kernel \$VERSION) 3.221 +#\$grub_dev 3.222 +#kernel /boot/vmlinuz-\$VERSION root=\$root_dev 3.223 +#EOT 3.224 + #fi 3.225 +#} 3.226 + 3.227 +# Pack it. 3.228 +tazpkg pack linux-custom-$version 3.229 + 3.230 +# Install the new kernel. 3.231 +if [ "$install" ]; then 3.232 + cd $cookdir/linux-$version/slitaz 3.233 + tazpkg -i linux-custom-$version.tazpkg --forced 3.234 +fi 3.235 + 3.236 +exit 0