summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2002-05-24 11:03:41 +0000
committerru <ru@FreeBSD.org>2002-05-24 11:03:41 +0000
commit26e1492d4c6a274678008fe49106c1bf9fa69356 (patch)
tree03e6f73685b10f4361a55454ae7e66034f899073
parent74ff5f42c5ebd35d269c5794a0d51975effffc2e (diff)
downloadFreeBSD-src-26e1492d4c6a274678008fe49106c1bf9fa69356.zip
FreeBSD-src-26e1492d4c6a274678008fe49106c1bf9fa69356.tar.gz
Convert Perl scripts to awk(1).
-rw-r--r--release/Makefile4
-rwxr-xr-xrelease/scripts/driver-copy2.awk96
-rw-r--r--release/scripts/driver-copy2.pl78
-rwxr-xr-x[-rw-r--r--]release/scripts/driver-remove.awk (renamed from release/scripts/driver-remove.pl)77
4 files changed, 148 insertions, 107 deletions
diff --git a/release/Makefile b/release/Makefile
index 370b6f1..2fb5f9a 100644
--- a/release/Makefile
+++ b/release/Makefile
@@ -647,11 +647,11 @@ release.9:
sh ${.CURDIR}/${TARGET_ARCH}/dokern.sh ${FDSIZE} < GENERIC > BOOTMFS && \
[ -r GENERIC.hints ] && cp GENERIC.hints BOOTMFS.hints
.if exists(${.CURDIR}/${TARGET}/drivers.conf)
- @perl ${.CURDIR}/scripts/driver-remove.pl \
+ @awk -f ${.CURDIR}/scripts/driver-remove.awk \
${.CURDIR}/${TARGET}/drivers.conf \
${.CURDIR}/../sys/${TARGET}/conf/BOOTMFS
@mkdir -p ${RD}/mfsfd/stand/modules
- @perl ${.CURDIR}/scripts/driver-copy2.pl \
+ @awk -f ${.CURDIR}/scripts/driver-copy2.awk \
${.CURDIR}/${TARGET}/drivers.conf \
${RD}/trees/base/boot/kernel ${RD}/mfsfd/stand/modules
.endif
diff --git a/release/scripts/driver-copy2.awk b/release/scripts/driver-copy2.awk
new file mode 100755
index 0000000..f5789f4
--- /dev/null
+++ b/release/scripts/driver-copy2.awk
@@ -0,0 +1,96 @@
+#!/usr/bin/awk -f
+#
+# Copyright (c) 2000 "HOSOKAWA, Tatsumi" <hosokawa@FreeBSD.org>
+# Copyright (c) 2002 Ruslan Ermilov <ru@FreeBSD.org>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+function usage()
+{
+ print "usage: driver-copy2.awk config_file src_ko_dir dst_ko_dir" > "/dev/stderr";
+ exit 1;
+}
+
+function err(eval, fmt, what)
+{
+ printf "driver-copy2.awk: " fmt ": %s\n", what, ERRNO > "/dev/stderr";
+ exit eval;
+}
+
+function errx(eval, fmt, what)
+{
+ printf "driver-copy2.awk: " fmt "\n", what > "/dev/stderr";
+ exit eval;
+}
+
+function readconfig(config)
+{
+ while ((getline < config) > 0) {
+ sub("#.*$", "");
+ if (split(gensub(/^(\w+)[ \t]+(\w+)[ \t]+([0-9]+)[ \t]+(\w+)[ \t]+\"(.*)\"[ \t]*$/,
+ "\\1#\\2#\\3#\\4#\\5", "g"), arg, "#") == 5) {
+ flp[arg[2]] = arg[3];
+ dsc[arg[2]] = arg[5];
+ }
+ }
+ if (ERRNO)
+ err(1, "reading %s", config);
+ close(config);
+}
+
+BEGIN {
+ if (ARGC != 4)
+ usage();
+
+ config = ARGV[1];
+ srcdir = ARGV[2];
+ dstdir = ARGV[3];
+
+ readconfig(config);
+
+ if (system("test -d " srcdir) != 0)
+ errx(1, "cannot find %s directory", srcdir);
+ if (system("test -d " dstdir) != 0)
+ errx(1, "cannot find %s directory", dstdir);
+
+ for (f in flp) {
+ if (flp[f] == 1) {
+ print f ": There's nothing to do with driver on first floppy." > "/dev/stderr";
+ } else if (flp[f] == 2) {
+ srcfile = srcdir "/" f ".ko";
+ dstfile = dstdir "/" f ".ko";
+ dscfile = dstdir "/" f ".dsc";
+ print "Copying " f ".ko to " dstdir > "/dev/stderr";
+ if (system("cp " srcfile " " dstfile) != 0)
+ exit 1;
+ printf "%s", dsc[f] > dscfile;
+ close(dscfile);
+ } else if (flp[f] == 3) {
+ # third driver floppy (not yet implemented)
+ errx(1, "%s: 3rd driver floppy support is not implemented", f);
+ }
+ }
+}
diff --git a/release/scripts/driver-copy2.pl b/release/scripts/driver-copy2.pl
deleted file mode 100644
index 6c4dfe6..0000000
--- a/release/scripts/driver-copy2.pl
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (c) 2000 "HOSOKAWA, Tatsumi" <hosokawa@FreeBSD.org>
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-# $FreeBSD$
-#
-
-if ($#ARGV != 2) {
- print STDERR "usage: driver-copy.pl config_file src_ko_dir dst_ko_dir\n";
- exit 1;
-}
-
-$config = $ARGV[0];
-$srcdir = $ARGV[1];
-$dstdir = $ARGV[2];
-
-open CONFIG, "< $config" or die "Cannot open $config.\n";
-while (<CONFIG>) {
- s/#.*$//;
- if (/^(\w+)\s+(\w+)\s+(\d+)\s+(\w+)\s+\"(.*)\"\s*$/) {
- $flp{$2} = $3;
- $dsc{$2} = $5;
- }
-}
-close CONFIG;
-
--d $srcdir or die "Cannot find $srcdir directory.\n";
--d $dstdir or die "Cannot find $dstdir directory.\n";
-
-undef $/;
-
-foreach $f (sort keys %flp) {
- if ($flp{$f} == 1) {
- print STDERR "$f: There's nothing to do with driver on first floppy.\n";
- }
- elsif ($flp{$f} == 2) {
- $srcfile = $srcdir . '/' . $f . '.ko';
- $dstfile = $dstdir . '/' . $f . '.ko';
- $dscfile = $dstdir . '/' . $f . '.dsc';
- print STDERR "Copying $f.ko to $dstdir\n";
- open SRC, "< $srcfile" or die "Cannot open $srcfile\n";
- $file = <SRC>;
- close SRC;
- open DST, "> $dstfile" or die "Cannot open $dstfile\n";
- print DST $file;
- close DST;
- open DSC, "> $dscfile" or die "Cannot open $dscfile\n";
- print DSC $dsc{$f};
- close DSC;
- }
- elsif ($flp{$f} == 3) {
- # third driver floppy (currently not implemnted yet...)
- print STDERR "3rd driver floppy support has not implemented yet\n";
- exit 1;
- }
-}
diff --git a/release/scripts/driver-remove.pl b/release/scripts/driver-remove.awk
index 879e290..0c15bde 100644..100755
--- a/release/scripts/driver-remove.pl
+++ b/release/scripts/driver-remove.awk
@@ -1,6 +1,7 @@
-#!/usr/bin/perl
+#!/usr/bin/awk -f
#
# Copyright (c) 2000 "HOSOKAWA, Tatsumi" <hosokawa@FreeBSD.org>
+# Copyright (c) 2002 Ruslan Ermilov <ru@FreeBSD.org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -27,37 +28,59 @@
# $FreeBSD$
#
-if ($#ARGV != 1) {
- print STDERR "usage: driver-remove.pl config_file BOOTMFS\n";
- exit 1;
+function usage()
+{
+ print "usage: driver-remove.awk config_file BOOTMFS" > "/dev/stderr";
+ exit 1;
}
-$config = $ARGV[0];
-$bootmfs = $ARGV[1];
+function err(eval, fmt, what)
+{
+ printf "driver-remove.awk: " fmt ": %s\n", what, ERRNO > "/dev/stderr";
+ exit eval;
+}
-open CONFIG, "< $config" or die "Cannot open $config.\n";
-while (<CONFIG>) {
- s/#.*$//;
- if (/^(\w+)\s+(\w+)\s+(\d+)\s+(\w+)\s+\"(.*)\"\s*$/) {
- if ($4 eq "options") {
- $options{$1} = 1;
- } else {
- $drivers{$1} = 1;
+function readconfig(config)
+{
+ while ((getline < config) > 0) {
+ sub("#.*$", "");
+ if (split(gensub(/^(\w+)[ \t]+(\w+)[ \t]+([0-9]+)[ \t]+(\w+)[ \t]+\"(.*)\"[ \t]*$/,
+ "\\1#\\2#\\3#\\4#\\5", "g"), arg, "#") == 5) {
+ if (arg[4] == "options")
+ options[arg[1]] = 1;
+ else
+ drivers[arg[1]] = 1;
+ }
}
- }
+ if (ERRNO)
+ err(1, "reading %s", config);
+ close(config);
}
-close CONFIG;
-open BOOTMFS, "< $bootmfs" or die "Cannot open $bootmfs.\n";
-while (<BOOTMFS>) {
- next if (/^device\s+(\w+)/ && $drivers{$1});
- next if (/^options\s+(\w+)/ && $options{$1});
- push @bootmfs, $_;
-}
-close BOOTMFS;
+BEGIN {
+ if (ARGC != 3)
+ usage();
+
+ config = ARGV[1];
+ bootmfs = ARGV[2];
-open BOOTMFS, "> $bootmfs" or die "Cannot open $bootmfs.\n";
-foreach (@bootmfs) {
- print BOOTMFS;
+ readconfig(config);
+
+ lines = 0;
+ while ((getline < bootmfs) > 0) {
+ if (/^device[ \t]+\w+/ &&
+ gensub(/^device[ \t]+(\w+).*$/, "\\1", "g") in drivers)
+ continue;
+ if (/^options[ \t]+\w+/ &&
+ gensub(/^options[ \t]+(\w+).*$/, "\\1", "g") in options)
+ continue;
+ line[lines++] = $0;
+ }
+ if (ERRNO)
+ err(1, "reading %s", bootmfs);
+ close(bootmfs);
+ printf "" > bootmfs;
+ for (i = 0; i < lines; i++)
+ print line[i] >> bootmfs;
+ close(bootmfs);
}
-close BOOTMFS;
OpenPOWER on IntegriCloud