summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authormbm <mbm@3c298f89-4303-0410-b956-a3cf2f4a3e73>2005-03-06 03:34:52 +0000
committermbm <mbm@3c298f89-4303-0410-b956-a3cf2f4a3e73>2005-03-06 03:34:52 +0000
commitf77b88d124ea1c900f9cf5e04046939aad48bbe1 (patch)
tree4c6922d42353c39b46dcd7cd09982fbe9c1f9765 /scripts
parent7d3d15851a890855f0a752304fa50e5d8e927222 (diff)
nbd's makefile/menuconfig rewrite
git-svn-id: svn://svn.openwrt.org/openwrt/trunk/openwrt@307 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/configtest.pl12
-rwxr-xr-xscripts/gen_busybox_config.pl22
-rw-r--r--scripts/gen_busybox_menuconfig.pl69
-rwxr-xr-xscripts/make-ipkg-dir.sh11
-rwxr-xr-xscripts/patch-kernel.sh53
5 files changed, 167 insertions, 0 deletions
diff --git a/scripts/configtest.pl b/scripts/configtest.pl
new file mode 100755
index 000000000..01323a521
--- /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 000000000..1a84ab999
--- /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 000000000..6ce323bb1
--- /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 (<CONFIG>) {
+ /^([\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 (<FIND>) {
+ 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 = <INPUT>) {
+ 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 000000000..f725413ae
--- /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 000000000..79401c2a7
--- /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 <andersen@codepoet.org>
+
+# 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 {} \;