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

Showing the changes to scripts/package (1 of 1 file). Show all

Unified · Split

scripts/package/builddeb+11−7
@@ -25,8 +25,13 @@ create_package() { · 24 unmodified lines
25 chown -R root:root "$pdir"25 chown -R root:root "$pdir"
26 chmod -R go-w "$pdir"26 chmod -R go-w "$pdir"
27 27
28 # Create the package
29 dpkg-gencontrol $forcearch -Vkernel:debarch="${debarch}" -p$pname -P"$pdir"
30 dpkg --build "$pdir" ..
31}
32
33set_debarch() {
28 # Attempt to find the correct Debian architecture34 # Attempt to find the correct Debian architecture
29 local forcearch="" debarch=""
30 case "$UTS_MACHINE" in35 case "$UTS_MACHINE" in
31 i386|ia64|alpha)36 i386|ia64|alpha)
32 debarch="$UTS_MACHINE" ;;37 debarch="$UTS_MACHINE" ;;
@@ -47,6 +52,7 @@ create_package() { · 14 unmodified lines
47 arm*)52 arm*)
48 debarch=arm$(grep -q CONFIG_AEABI=y $KCONFIG_CONFIG && echo el || true) ;;53 debarch=arm$(grep -q CONFIG_AEABI=y $KCONFIG_CONFIG && echo el || true) ;;
49 *)54 *)
55 debarch=$(dpkg --print-architecture)
50 echo "" >&256 echo "" >&2
51 echo "** ** ** WARNING ** ** **" >&257 echo "** ** ** WARNING ** ** **" >&2
52 echo "" >&258 echo "" >&2
@@ -59,13 +65,8 @@ create_package() { · 6 unmodified lines
59 if [ -n "$KBUILD_DEBARCH" ] ; then65 if [ -n "$KBUILD_DEBARCH" ] ; then
60 debarch="$KBUILD_DEBARCH"66 debarch="$KBUILD_DEBARCH"
61 fi67 fi
62 if [ -n "$debarch" ] ; then68 forcearch="-DArchitecture=$debarch"
63 forcearch="-DArchitecture=$debarch"
64 fi
65 69
66 # Create the package
67 dpkg-gencontrol $forcearch -Vkernel:debarch="${debarch:-$(dpkg --print-architecture)}" -p$pname -P"$pdir"
68 dpkg --build "$pdir" ..
69}70}
70 71
71# Some variables and settings used throughout the script72# Some variables and settings used throughout the script
@@ -86,6 +87,9 @@ fwpackagename=linux-firmware-image-$version · 14 unmodified lines
86kernel_headers_packagename=linux-headers-$version87kernel_headers_packagename=linux-headers-$version
87libc_headers_packagename=linux-libc-dev88libc_headers_packagename=linux-libc-dev
88dbg_packagename=$packagename-dbg89dbg_packagename=$packagename-dbg
90debarch=
91forcearch=
92set_debarch
89 93
90if [ "$ARCH" = "um" ] ; then94if [ "$ARCH" = "um" ] ; then
91 packagename=user-mode-linux-$version95 packagename=user-mode-linux-$version