From 3d904bb14a330fb72f60d4b78a40435389398655 Mon Sep 17 00:00:00 2001 From: Mike Baker Date: Sun, 6 Mar 2005 03:34:52 +0000 Subject: nbd's makefile/menuconfig rewrite git-svn-id: svn://svn.openwrt.org/openwrt/trunk/openwrt@307 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- scripts/configtest.pl | 12 +++++++ scripts/gen_busybox_config.pl | 22 +++++++++++++ scripts/gen_busybox_menuconfig.pl | 69 +++++++++++++++++++++++++++++++++++++++ scripts/make-ipkg-dir.sh | 11 +++++++ scripts/patch-kernel.sh | 53 ++++++++++++++++++++++++++++++ 5 files changed, 167 insertions(+) create mode 100755 scripts/configtest.pl create mode 100755 scripts/gen_busybox_config.pl create mode 100644 scripts/gen_busybox_menuconfig.pl create mode 100755 scripts/make-ipkg-dir.sh create mode 100755 scripts/patch-kernel.sh (limited to 'scripts') diff --git a/scripts/configtest.pl b/scripts/configtest.pl new file mode 100755 index 0000000000..01323a5211 --- /dev/null +++ b/scripts/configtest.pl @@ -0,0 +1,12 @@ +#!/usr/bin/perl + +my %change = ( + 'BUSYBOX' => 'make -C package busybox-clean', + '' => 'make target_clean' +); + +foreach my $change (keys %change) { + my $v1 = `grep '$change' .config.test`; + my $v2 = `grep '$change' .config`; + $v1 eq $v2 or system($change{$change}); +} diff --git a/scripts/gen_busybox_config.pl b/scripts/gen_busybox_config.pl new file mode 100755 index 0000000000..1a84ab999d --- /dev/null +++ b/scripts/gen_busybox_config.pl @@ -0,0 +1,22 @@ +#!/usr/bin/perl +use strict; + +my $line; +my $l1 = ''; +my $l2 = '=y'; +while (<>) { + chomp; + /^(# )BR2_LARGEFILE(.+)$/ and do { + $l1 = $1; + $l2 = $2; + }; + /^(# )?BUSYBOX_(.+)/ and do { + my $p1 = $1; + my $p2 = $2; + $p2 =~ /(CONFIG_LFS|FDISK_SUPPORT_LARGE_DISKS)/ and do { + $p1 = $l1; + $p2 = "$1$l2"; + }; + print "$p1$p2\n"; + } +} diff --git a/scripts/gen_busybox_menuconfig.pl b/scripts/gen_busybox_menuconfig.pl new file mode 100644 index 0000000000..6ce323bb13 --- /dev/null +++ b/scripts/gen_busybox_menuconfig.pl @@ -0,0 +1,69 @@ +#!/usr/bin/perl +use strict; +my $PATH = $ARGV[0]; +($PATH and -d $PATH) or die 'invalid path'; +my $DEFCONFIG = $ARGV[1]; +($DEFCONFIG and -f $DEFCONFIG) or die 'invalid config file'; + +my %config; + +open CONFIG, $DEFCONFIG or die 'cannot open config file'; +while () { + /^([\w_]+)=([ym])/ and $config{$1} = $2; + /^([\w_]+)=(\d+)/ and $config{$1} = $2; + /^([\w_]+)=(".+")/ and $config{$1} = $2; +} +close CONFIG; + +open FIND, "find \"$PATH\" -name Config.in |"; +while () { + chomp; + my $input = $_; + s/^$PATH\///g; + s/sysdeps\/linux\///g; + my $output = $_; + print STDERR "$input => $output\n"; + $output =~ /^(.+)\/[^\/]+$/ and system("mkdir -p $1"); + + open INPUT, $input; + open OUTPUT, ">$output"; + my ($cur, $default_set, $line); + while ($line = ) { + next if $line =~ /^\s*mainmenu/; + + # FIXME: make this dynamic + $line =~ s/default CONFIG_FEATURE_BUFFERS_USE_MALLOC/default CONFIG_FEATURE_BUFFERS_GO_ON_STACK/; + $line =~ s/default BUSYBOX_CONFIG_FEATURE_SH_IS_NONE/default BUSYBOX_CONFIG_FEATURE_SH_IS_ASH/; + + if ($line =~ /^\s*config\s*([\w_]+)/) { + $cur = $1; + undef $default_set; + } + if ($line =~ /^\s*(menu|choice|end|source)/) { + undef $cur; + undef $default_set; + } + $line =~ s/^(\s*source\s+)/$1package\/busybox\/config\//; + + $line =~ s/(\s+)((CONFIG|FDISK|USING|CROSS|EXTRA|PREFIX|FEATURE|HAVE|BUSYBOX)[\w_]*)/$1BUSYBOX_$2/g; + + if ($cur) { + ($cur !~ /^CONFIG/ or $cur eq 'CONFIG_LFS') and do { + $line =~ s/^(\s*(bool|tristate|string))\s*".+"$/$1/; + }; + if ($line =~ /^\s*default/) { + my $c; + $default_set = 1; + $c = $config{$cur} or $c = 'n'; + + $line =~ s/^(\s*default\s*)(\w+|"[^"]*")(.*)/$1$c$3/; + } + } + + print OUTPUT $line; + } + close OUTPUT; + close INPUT; + +} +close FIND; diff --git a/scripts/make-ipkg-dir.sh b/scripts/make-ipkg-dir.sh new file mode 100755 index 0000000000..f725413ae3 --- /dev/null +++ b/scripts/make-ipkg-dir.sh @@ -0,0 +1,11 @@ +#!/bin/bash +TARGET=$1 +CONTROL=$2 +VERSION=$3 +ARCH=$4 + +mkdir -p "$TARGET/CONTROL" +grep '^[^(Version|Architecture)]' "$CONTROL" > "$TARGET/CONTROL/control" +echo "Version: $VERSION" >> "$TARGET/CONTROL/control" +echo "Architecture: $ARCH" >> "$TARGET/CONTROL/control" +chmod 644 "$TARGET/CONTROL/control" diff --git a/scripts/patch-kernel.sh b/scripts/patch-kernel.sh new file mode 100755 index 0000000000..79401c2a74 --- /dev/null +++ b/scripts/patch-kernel.sh @@ -0,0 +1,53 @@ +#! /bin/sh +# A little script I whipped up to make it easy to +# patch source trees and have sane error handling +# -Erik +# +# (c) 2002 Erik Andersen + +# Set directories from arguments, or use defaults. +targetdir=${1-.} +patchdir=${2-../kernel-patches} +patchpattern=${3-*} + +if [ ! -d "${targetdir}" ] ; then + echo "Aborting. '${targetdir}' is not a directory." + exit 1 +fi +if [ ! -d "${patchdir}" ] ; then + echo "Aborting. '${patchdir}' is not a directory." + exit 1 +fi + +for i in ${patchdir}/${patchpattern} ; do + case "$i" in + *.gz) + type="gzip"; uncomp="gunzip -dc"; ;; + *.bz) + type="bzip"; uncomp="bunzip -dc"; ;; + *.bz2) + type="bzip2"; uncomp="bunzip2 -dc"; ;; + *.zip) + type="zip"; uncomp="unzip -d"; ;; + *.Z) + type="compress"; uncomp="uncompress -c"; ;; + *) + type="plaintext"; uncomp="cat"; ;; + esac + echo "" + echo "Applying ${i} using ${type}: " + ${uncomp} ${i} | patch -p1 -E -d ${targetdir} + if [ $? != 0 ] ; then + echo "Patch failed! Please fix $i!" + exit 1 + fi +done + +# Check for rejects... +if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then + echo "Aborting. Reject files found." + exit 1 +fi + +# Remove backup files +find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \; -- cgit v1.2.3