#!/bin/sh # makedeb - build .debs out of already-compiled kernel trees # Copyright (C) 2005 Christian 'Greek0' Aichinger # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. # # If you want to contact me write an email to Greek0@gmx.net set -e function make_clean() { rm -rf debian conf.vars stamp-* if $OOT; then rm -rf Documentation fi } function make_conf_vars() { head -n 4 "$SOURCE/Makefile" > conf.vars } function AppendMakefile() { if ! egrep "^$1 +=" Makefile 1>/dev/null 2>&1; then cp Makefile Makefile.new; mv -f Makefile.new Makefile egrep "^$1 +=" conf.vars >> Makefile 2>/dev/null fi } function make_Makefile() { if $OOT; then AppendMakefile "VERSION" AppendMakefile "PATCHLEVEL" AppendMakefile "SUBLEVEL" AppendMakefile "EXTRAVERSION" fi } function make_Changes() { if $OOT; then mkdir -p Documentation cp "$SOURCE/Documentation/Changes" Documentation fi } function make_debian() { make-kpkg --rootcmd fakeroot debian } function make_buildinfo() { COLUMNS=150 dpkg -l 'gcc*' perl dpkg 'libc6*' binutils ldso make dpkg-dev |\ awk '$$1 ~ /[hi]i/ { printf("%s-%s\n", $$2, $$3) }' > debian/buildinfo echo this was built on a machine with the kernel: >> debian/buildinfo uname -a >> debian/buildinfo echo using the compiler: >> debian/buildinfo grep LINUX_COMPILER include/linux/compile.h | \ sed -e 's/.*LINUX_COMPILER "//' -e 's/"$$//' >> debian/buildinfo } function make_stamps() { touch stamp-build stamp-configure stamp-kernel-configure } function make_package() { make-kpkg --rootcmd fakeroot kernel_image } function Usage() { echo "Usage: $0 [O=] [V=1] " echo " Supported targets: clean build" exit 1 } function check_tree() { if [ ! -e "$SOURCE/include/linux" ]; then echo "E: Not in the top-level kernel tree" Usage fi if [ ! -e "vmlinux" ]; then echo "E: The tree doesn't seem to be built" Usage fi } ############################### # Main entry point ############################## SOURCE=`pwd` OOT=false VERBOSE=false # parse commandline arguments declare -a TARGETS for i in $@; do if echo "$i" | grep -q "^O="; then if $OOT; then echo "E: An O= option mustn't be passed twice" Usage fi # We got a build-tree option, set the out-of-tree flag and cd to the # new location OOT=true cd "`echo \"$i\" | sed -e 's/^O=//'`" elif echo "$i" | grep -q "^V="; then if ! echo "$i" | grep -q "^V=1$"; then echo "E: Unknown parameter to V=: '$i'" Usage fi VERBOSE=true else # Append $i to the list of targets TARGETS[${#TARGETS[@]}]="$i" fi done if [ ${#TARGETS[@]} -eq 0 ]; then # no targets passed TARGETS[0]=build fi # Check if source and build tree are ok check_tree $VERBOSE && set -x for i in ${TARGETS[@]}; do case "$i" in clean) make_clean ;; build) make_clean make_conf_vars make_Makefile make_Changes make_debian make_buildinfo make_stamps make_package ;; *) echo "E: unknown target: '$i'" Usage esac done