Commit 3e2ab2563a599c3d3fd03952c056af09fc03b74a

Authored by Frans Pop
Committed by Sam Ravnborg
1 parent 4f66199b4b

kbuild, deb-pkg: refactor code to reduce duplication

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>
Acked-by: maximilian attems <max@stro.at>
Cc: Andres Salomon <dilinger@debian.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>

Showing 1 changed file with 20 additions and 17 deletions Side-by-side Diff

scripts/package/builddeb
... ... @@ -11,6 +11,18 @@
11 11  
12 12 set -e
13 13  
  14 +create_package() {
  15 + local pname="$1" pdir="$2"
  16 +
  17 + # Fix ownership and permissions
  18 + chown -R root:root "$pdir"
  19 + chmod -R go-w "$pdir"
  20 +
  21 + # Create the package
  22 + dpkg-gencontrol -isp -p$pname -P"$pdir"
  23 + dpkg --build "$pdir" ..
  24 +}
  25 +
14 26 # Some variables and settings used throughout the script
15 27 version=$KERNELRELEASE
16 28 revision=$(cat .version)
17 29  
18 30  
... ... @@ -77,14 +89,17 @@
77 89 EOF
78 90  
79 91 # Generate a control file
80   -if [ "$ARCH" = "um" ]; then
81   - cat <<EOF > debian/control
  92 +cat <<EOF > debian/control
82 93 Source: linux
83 94 Section: base
84 95 Priority: optional
85 96 Maintainer: $name
86 97 Standards-Version: 3.6.1
  98 +EOF
87 99  
  100 +if [ "$ARCH" = "um" ]; then
  101 + cat <<EOF >> debian/control
  102 +
88 103 Package: $packagename
89 104 Provides: kernel-image-$version, linux-image-$version
90 105 Architecture: any
... ... @@ -100,12 +115,7 @@
100 115 EOF
101 116  
102 117 else
103   - cat <<EOF > debian/control
104   -Source: linux
105   -Section: base
106   -Priority: optional
107   -Maintainer: $name
108   -Standards-Version: 3.6.1
  118 + cat <<EOF >> debian/control
109 119  
110 120 Package: $packagename
111 121 Provides: kernel-image-$version, linux-image-$version
... ... @@ -118,10 +128,6 @@
118 128  
119 129 fi
120 130  
121   -# Fix some ownership and permissions
122   -chown -R root:root "$tmpdir"
123   -chmod -R go-w "$tmpdir"
124   -
125 131 # Do we have firmware? Move it out of the way and build it into a package.
126 132 if [ -e "$tmpdir/lib/firmware" ]; then
127 133 mv "$tmpdir/lib/firmware" "$fwdir/lib/"
128 134  
... ... @@ -134,13 +140,10 @@
134 140 This package contains firmware from the Linux kernel, version $version
135 141 EOF
136 142  
137   - dpkg-gencontrol -isp -p$fwpackagename -P"$fwdir"
138   - dpkg --build "$fwdir" ..
  143 + create_package "$fwpackagename" "$fwdir"
139 144 fi
140 145  
141   -# Perform the final magic
142   -dpkg-gencontrol -isp -p$packagename
143   -dpkg --build "$tmpdir" ..
  146 +create_package "$packagename" "$tmpdir"
144 147  
145 148 exit 0