Linux-KBuild Archive on lore.kernel.org
 help / color / Atom feed
From: Frans Pop <elendil@planet.nl>
To: linux-kbuild@vger.kernel.org
Cc: Sam Ravnborg <sam@ravnborg.org>, maximilian attems <max@stro.at>,
	Andres Salomon <dilinger@debian.org>
Subject: [PATCH 2/14] deb-pkg: refactor code to reduce duplication
Date: Thu, 23 Apr 2009 01:08:44 +0200
Message-ID: <200904230108.46011.elendil@planet.nl> (raw)
In-Reply-To: <200904230034.59627.elendil@planet.nl>

Factor out code to build package into separate function and
only write "source" section for the debian/control file once.

Signed-off-by: Frans Pop <elendil@planet.nl>
Cc: maximilian attems <max@stro.at>
Cc: Andres Salomon <dilinger@debian.org>
---

Because of this patch some things that needed to be done in two places in
later patches in the series now only need to be done once.

diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index eff7f9d..feebd69 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -11,6 +11,18 @@
 
 set -e
 
+create_package() {
+	local pname="$1" pdir="$2"
+
+	# Fix ownership and permissions
+	chown -R root:root "$pdir"
+	chmod -R go-w "$pdir"
+
+	# Create the package
+	dpkg-gencontrol -isp -p$pname -P"$pdir"
+	dpkg --build "$pdir" ..
+}
+
 # Some variables and settings used throughout the script
 version=$KERNELRELEASE
 revision=$(cat .version)
@@ -77,13 +89,16 @@ linux ($version-$revision) unstable; urgency=low
 EOF
 
 # Generate a control file
-if [ "$ARCH" = "um" ]; then
-	cat <<EOF > debian/control
+cat <<EOF > debian/control
 Source: linux
 Section: base
 Priority: optional
 Maintainer: $name
 Standards-Version: 3.6.1
+EOF
+
+if [ "$ARCH" = "um" ]; then
+	cat <<EOF >> debian/control
 
 Package: $packagename
 Provides: kernel-image-$version, linux-image-$version
@@ -100,12 +115,7 @@ Description: User Mode Linux kernel, version $version
 EOF
 
 else
-	cat <<EOF > debian/control
-Source: linux
-Section: base
-Priority: optional
-Maintainer: $name
-Standards-Version: 3.6.1
+	cat <<EOF >> debian/control
 
 Package: $packagename
 Provides: kernel-image-$version, linux-image-$version
@@ -118,10 +128,6 @@ EOF
 
 fi
 
-# Fix some ownership and permissions
-chown -R root:root "$tmpdir"
-chmod -R go-w "$tmpdir"
-
 # Do we have firmware? Move it out of the way and build it into a package.
 if [ -e "$tmpdir/lib/firmware" ]; then
 	mv "$tmpdir/lib/firmware" "$fwdir/lib/"
@@ -134,12 +140,9 @@ Description: Linux kernel firmware, version $version
  This package contains firmware from the Linux kernel, version $version
 EOF
 
-	dpkg-gencontrol -isp -p$fwpackagename -P"$fwdir"
-	dpkg --build "$fwdir" ..
+	create_package "$fwpackagename" "$fwdir"
 fi
 
-# Perform the final magic
-dpkg-gencontrol -isp -p$packagename
-dpkg --build "$tmpdir" ..
+create_package "$packagename" "$tmpdir"
 
 exit 0

  parent reply index

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-22 22:34 [PATCH 0/14] deb-pkg target improvements Frans Pop
2009-04-22 23:08 ` [PATCH 1/14] deb-pkg: minor general improvements in builddeb script Frans Pop
2009-04-22 23:08 ` Frans Pop [this message]
2009-04-22 23:09 ` [PATCH 3/14] deb-pkg: fix 'file not found' error when building .deb package for arm Frans Pop
2009-04-22 23:09 ` [PATCH 4/14] deb-pkg: pass Debian maintainer script parameters to packaging hook scripts Frans Pop
2009-04-22 23:09 ` [PATCH 5/14] deb-pkg: allow to specify a custom revision for .deb packages Frans Pop
2009-04-22 23:10 ` [PATCH 6/14] deb-pkg: allow alternative hook scripts directory in " Frans Pop
2009-04-22 23:10 ` [PATCH 7/14] dep-pkg: improve changelog entry and package descriptions Frans Pop
2009-04-22 23:11 ` [PATCH 8/14] deb-pkg: generate debian/copyright file Frans Pop
2009-04-24 17:08   ` [PATCH 8/14 v2] " Frans Pop
2009-04-22 23:11 ` [PATCH 9/14] deb-pkg: improve maintainer identification Frans Pop
2009-04-22 23:11 ` [PATCH 10/14] deb-pkg: improve Source field Frans Pop
2009-04-22 23:12 ` [PATCH 11/14] deb-pkg: fix generated package name Frans Pop
2009-04-22 23:12 ` [PATCH 12/14] deb-pkg: fix Provides field Frans Pop
2009-04-22 23:12 ` [PATCH 13/14] deb-pkg: fix Section field Frans Pop
2009-04-22 23:12 ` [PATCH 14/14] deb-pkg: bump standards version Frans Pop
2009-04-23  9:14 ` [PATCH 0/14] deb-pkg target improvements maximilian attems
2009-05-01 11:38   ` Sam Ravnborg
2009-05-04 15:17     ` maximilian attems
2009-05-04 15:25       ` Sam Ravnborg
2009-05-05  9:17         ` maximilian attems

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200904230108.46011.elendil@planet.nl \
    --to=elendil@planet.nl \
    --cc=dilinger@debian.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=max@stro.at \
    --cc=sam@ravnborg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-KBuild Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-kbuild/0 linux-kbuild/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-kbuild linux-kbuild/ https://lore.kernel.org/linux-kbuild \
		linux-kbuild@vger.kernel.org
	public-inbox-index linux-kbuild

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kbuild


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git