History

deb-pkg: move setting debarch for a separate function

create_package() function tries to resolve used architecture for everry package. Split the setting the architecture to a new function, set_debarch(), called once on startup. This allows using debarch from other parts of script as needed. v2: Follow Michals suggestion on setting variables at top scope and also setting the fallback $debarch in the new function

Riku Voipio committed 11 years ago

Commit dca0c021 parent 92f43c41 file · +11 −7Browse files

Unified · Split

scripts/package/builddeb+11−7
@@ -25,8 +25,13 @@ create_package() { · 24 unmodified lines
2525 chown -R root:root "$pdir"
2626 chmod -R go-w "$pdir"
2727
28+ # Create the package
29+ dpkg-gencontrol $forcearch -Vkernel:debarch="${debarch}" -p$pname -P"$pdir"
30+ dpkg --build "$pdir" ..
31+}
32+
33+set_debarch() {
2834 # Attempt to find the correct Debian architecture
29− local forcearch="" debarch=""
3035 case "$UTS_MACHINE" in
3136 i386|ia64|alpha)
3237 debarch="$UTS_MACHINE" ;;
@@ -47,6 +52,7 @@ create_package() { · 14 unmodified lines
4752 arm*)
4853 debarch=arm$(grep -q CONFIG_AEABI=y $KCONFIG_CONFIG && echo el || true) ;;
4954 *)
55+ debarch=$(dpkg --print-architecture)
5056 echo "" >&2
5157 echo "** ** ** WARNING ** ** **" >&2
5258 echo "" >&2
@@ -59,13 +65,8 @@ create_package() { · 6 unmodified lines
5965 if [ -n "$KBUILD_DEBARCH" ] ; then
6066 debarch="$KBUILD_DEBARCH"
6167 fi
62− if [ -n "$debarch" ] ; then
63− forcearch="-DArchitecture=$debarch"
64− fi
68+ forcearch="-DArchitecture=$debarch"
6569
66− # Create the package
67− dpkg-gencontrol $forcearch -Vkernel:debarch="${debarch:-$(dpkg --print-architecture)}" -p$pname -P"$pdir"
68− dpkg --build "$pdir" ..
6970 }
7071
7172 # Some variables and settings used throughout the script
@@ -86,6 +87,9 @@ fwpackagename=linux-firmware-image-$version · 14 unmodified lines
8687 kernel_headers_packagename=linux-headers-$version
8788 libc_headers_packagename=linux-libc-dev
8889 dbg_packagename=$packagename-dbg
90+debarch=
91+forcearch=
92+set_debarch
8993
9094 if [ "$ARCH" = "um" ] ; then
9195 packagename=user-mode-linux-$version