[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH kernel-wedge v2] Allow configuration files to be placed in a subdirectory



In a kernel source package, which will be non-native, the kernel-wedge
configuration should be placed under the debian/ directory.

copy-modules, gen-control, gen-deps, install-files: If the environment
variable $KW_CONFIG_DIR is set, look for configuration files in the
specified directory (which may be relative).
---
This adds an environment variable instead of additional parameters, as
requested.  I even remembered to update the documentation for this one.

Please apply and then upload a new version of kernel-wedge.

Ben.

 README                 |    5 +++++
 commands/copy-modules  |   17 +++++++++--------
 commands/gen-control   |   18 ++++++++++--------
 commands/gen-deps      |   12 +++++++-----
 commands/install-files |   13 +++++++------
 debian/changelog       |    1 +
 6 files changed, 39 insertions(+), 27 deletions(-)

diff --git a/README b/README
index 06f061e..6bf5b87 100644
--- a/README
+++ b/README
@@ -9,11 +9,16 @@ looking something like this:
   debian/changelog
   debian/rules
   debian/control.stub
+
   kernel-versions
   modules/<arch>/*
   exclude-packages
   package-list
 
+The second group of files may be placed in a subdirectory, in which
+case the environment variable $KW_CONFIG_DIR must be set to the
+subdirectory name.
+
 Let's get the easy files out of the way. The changelog is a changelog, like
 any other, as is the copyright. The debian/rules can be something as simple
 as this:
diff --git a/commands/copy-modules b/commands/copy-modules
index 974347d..f20ac3c 100755
--- a/commands/copy-modules
+++ b/commands/copy-modules
@@ -81,6 +81,7 @@ processmodules() {
 version=$1-$2
 flavour=$2
 installedname=$3
+configdir=$(readlink -f ${KW_CONFIG_DIR:-.})
 arch=$(dpkg-architecture -qDEB_HOST_ARCH)
 os=$(dpkg-architecture -qDEB_HOST_ARCH_OS)
 home=$PWD
@@ -102,12 +103,12 @@ if [ ! -d $moddir ]; then
 fi
 	
 # The directory of modules lists to use.
-if [ -d modules/$arch-$flavour ]; then
-	modlistdir=modules/$arch-$flavour
-elif [ -d modules/$flavour ]; then
-	modlistdir=modules/$flavour
+if [ -d $configdir/modules/$arch-$flavour ]; then
+	modlistdir=$configdir/modules/$arch-$flavour
+elif [ -d $configdir/modules/$flavour ]; then
+	modlistdir=$configdir/modules/$flavour
 else
-	modlistdir=modules/$arch
+	modlistdir=$configdir/modules/$arch
 fi
 
 if [ "$os" = "linux" ] ; then
@@ -132,9 +133,9 @@ if [ "$os" = "linux" ] ; then
 		}
 	' $modulesdep | sort -k 2,2 > $tmpdir/deps
 	
-	if [ ! -s $tmpdir/deps ] && [ ! -e $home/no-modules ]; then
+	if [ ! -s $tmpdir/deps ] && [ ! -e $configdir/no-modules ]; then
 		echo "No module interdependencies found. This probably means your modules.dep is broken." >&2
-		echo "If this is intentional, touch $home/no-modules" >&2
+		echo "If this is intentional, touch $configdir/no-modules" >&2
 		exit 1
 	fi
 else
@@ -166,7 +167,7 @@ for i in $(
 	
 	# preprocess file, handle includes and excludes and sort so that
 	# the joins work, no matter what the order of the input.
-	kernel-wedge preprocess $home/$modlistdir/$i | sort > $tmpdir/module-list/$i
+	kernel-wedge preprocess $modlistdir/$i | sort > $tmpdir/module-list/$i
 
 	# exclude modules in exclude from dependency list
 	join -2 2 -v 2 $tmpdir/exclude $tmpdir/deps |
diff --git a/commands/gen-control b/commands/gen-control
index 9845a74..5ec7bbf 100755
--- a/commands/gen-control
+++ b/commands/gen-control
@@ -11,9 +11,11 @@ my %packages;
 my @builddeps;
 my %excluded;
 
+my $configdir = ($ENV{KW_CONFIG_DIR} || '.');
+
 my $fixkernelversion = $ARGV[0];
 
-if (open(EXCLUDED, "exclude-packages")) {
+if (open(EXCLUDED, "$configdir/exclude-packages")) {
 	while (<EXCLUDED>) {
 		chomp;
 		$excluded{$_}=1;
@@ -21,7 +23,7 @@ if (open(EXCLUDED, "exclude-packages")) {
 	close EXCLUDED;
 }
 
-open(KVERS, "kernel-versions") || die "kernel-versions: $!";
+open(KVERS, "$configdir/kernel-versions") || die "kernel-versions: $!";
 while (<KVERS>) {
 	chomp;
 	next if /^#/ || ! length;
@@ -109,7 +111,7 @@ sub read_package_list
 	close LIST;
 }
 read_package_list("/usr/share/kernel-wedge/package-list");
-read_package_list("package-list");
+read_package_list("$configdir/package-list");
 
 foreach my $ver (@versions) {
 	my ($arch, $kernelversion, $flavour) = @$ver;
@@ -134,14 +136,14 @@ foreach my $ver (@versions) {
 		# Check for a modules list file for this architecture and
 		# package.
 		my $modlistdir="";
-		if (-d "modules/$arch-$flavour") {
-			$modlistdir="modules/$arch-$flavour";
+		if (-d "$configdir/modules/$arch-$flavour") {
+			$modlistdir = "$configdir/modules/$arch-$flavour";
 		}
-		elsif (-d "modules/$flavour") {
-			$modlistdir="modules/$flavour";
+		elsif (-d "$configdir/modules/$flavour") {
+			$modlistdir = "$configdir/modules/$flavour";
 		}
 		else {
-			$modlistdir="modules/$arch";
+			$modlistdir = "$configdir/modules/$arch";
 		}
 		
 		next unless -e "$modlistdir/".$package->("Package");
diff --git a/commands/gen-deps b/commands/gen-deps
index 94e77be..4509cc5 100755
--- a/commands/gen-deps
+++ b/commands/gen-deps
@@ -6,6 +6,8 @@
 my $arch=`dpkg-architecture -qDEB_HOST_ARCH`;
 chomp $arch;
 
+my $configdir = ($ENV{KW_CONFIG_DIR} || '.');
+
 my $flavour=$ARGV[0];
 
 my @out;
@@ -26,14 +28,14 @@ sub read_package_list
 			my @depends=split(", ", $1);
 			# Skip packages that are not built for this architecture.
 			my $modlistdir="";
-			if (-d "modules/$arch-$flavour") {
-				$modlistdir="modules/$arch-$flavour";
+			if (-d "$configdir/modules/$arch-$flavour") {
+				$modlistdir = "$configdir/modules/$arch-$flavour";
 			}
 			elsif (-d "modules/$flavour") {
-				$modlistdir="modules/$flavour";
+				$modlistdir = "$configdir/modules/$flavour";
 			}
 			else {
-				$modlistdir="modules/$arch";
+				$modlistdir = "$configdir/modules/$arch";
 			}
 			next unless -e "$modlistdir/$package";
 			foreach my $dep (@depends) {
@@ -48,5 +50,5 @@ sub read_package_list
 }
 
 read_package_list("/usr/share/kernel-wedge/package-list");
-read_package_list("package-list");
+read_package_list("$configdir/package-list");
 print sort @out;
diff --git a/commands/install-files b/commands/install-files
index 999cc2d..5478f1f 100755
--- a/commands/install-files
+++ b/commands/install-files
@@ -12,11 +12,12 @@ sub doit {
 my $hostarch=`dpkg-architecture -qDEB_HOST_ARCH`;
 chomp $hostarch;
 
+my $configdir = ($ENV{KW_CONFIG_DIR} || '.');
 my $fixsourcedir = $ENV{SOURCEDIR};
 
 my $fixkernelversion = $ARGV[0];
 
-open(KVERS, "kernel-versions") || die "kernel-versions: $!";
+open(KVERS, "$configdir/kernel-versions") || die "kernel-versions: $!";
 my $version = 0;
 while (<KVERS>) {
 	chomp;
@@ -70,14 +71,14 @@ while (<KVERS>) {
 	}
 	
 	my $modlistdir;
-	if (-d "modules/$arch-$flavour") {
-		$modlistdir="modules/$arch-$flavour";
+	if (-d "$configdir/modules/$arch-$flavour") {
+		$modlistdir = "$configdir/modules/$arch-$flavour";
 	}
-	elsif (-d "modules/$flavour") {
-		$modlistdir="modules/$flavour";
+	elsif (-d "$configdir/modules/$flavour") {
+		$modlistdir = "$configdir/modules/$flavour";
 	}
 	else {
-		$modlistdir="modules/$arch";
+		$modlistdir = "$configdir/modules/$arch";
 	}
 
 	if (! -e "$modlistdir/kernel-image") {
diff --git a/debian/changelog b/debian/changelog
index 9cc2682..a19ae2d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,7 @@ kernel-wedge (2.79) UNRELEASED; urgency=low
   [ Ben Hutchings ]
   * Allow kernel source packages to use kernel-wedge on themselves
   * Allow kernel ABI version to be specified as command-line argument
+  * Allow configuration files to be placed in a subdirectory
 
  -- Samuel Thibault <sthibault@debian.org>  Mon, 08 Aug 2011 18:34:12 +0200
 
-- 
1.7.5.4


Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: