Skip to content

Commit 32db18c

Browse files
grendellojonpryor
authored andcommitted
[build] Fix build on Debian (#1060)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=60901 The root cause of the bug is the condition in build-tools/libzip/libzip.props which checks whether to build libzip or not and, currently, does NOT build the library only on Ubuntu machines. The reason for this was that, so far, none of us tested the build on Debian and it wasn't certain what, if any, changes would be required (despite Ubuntu being based on Debian) in order for the build to work on Debian proper and, possibly, other related distros. This commit introduces a new msbuild property, `$(HostOsFlavor)` which can be used to cluster related distros/operating systems into groups with the purpose of sharing certain behaviors or operations - like building, or not, of libzip. This commit also introduces a `make prepare` script to install dependencies on Debian (tested on Debian 9.1.2 64-bit) as well as rearranges the order in which we check for distro-specific prepration script. We now first seek for script specific to the current distro version/release and only then for the "generic" script for this distribution. With the changes in place `make prepare && make` work start-to-finish on Debian.
1 parent 4e0dacb commit 32db18c

File tree

6 files changed

+74
-46
lines changed

6 files changed

+74
-46
lines changed

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ linux-prepare::
7272
if [ "x$$BINFMT_WARN" = "xyes" ]; then \
7373
cat Documentation/binfmt_misc-warning-Linux.txt ; \
7474
fi; \
75-
if [ -f build-tools/scripts/dependencies/linux-prepare-$(LINUX_DISTRO).sh ]; then \
76-
sh build-tools/scripts/dependencies/linux-prepare-$(LINUX_DISTRO).sh; \
77-
elif [ -f build-tools/scripts/dependencies/linux-prepare-$(LINUX_DISTRO)-$(LINUX_DISTRO_RELEASE).sh ]; then \
75+
if [ -f build-tools/scripts/dependencies/linux-prepare-$(LINUX_DISTRO)-$(LINUX_DISTRO_RELEASE).sh ]; then \
7876
sh build-tools/scripts/dependencies/linux-prepare-$(LINUX_DISTRO)-$(LINUX_DISTRO_RELEASE).sh; \
79-
fi; \
77+
elif [ -f build-tools/scripts/dependencies/linux-prepare-$(LINUX_DISTRO).sh ]; then \
78+
sh build-tools/scripts/dependencies/linux-prepare-$(LINUX_DISTRO).sh; \
79+
fi
8080

8181
# $(call GetPath,path)
8282
GetPath = $(shell $(MSBUILD) $(MSBUILD_FLAGS) /p:DoNotLoadOSProperties=True /nologo /v:minimal /t:Get$(1)FullPath build-tools/scripts/Paths.targets | tr -d '[[:space:]]' )

build-tools/libzip/libzip.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
4-
<_LinuxBuildLibZip Condition=" '$(_LinuxBuildLibZip)' == '' AND '$(HostOS)' == 'Linux' AND '$(HostOsName)' != 'Ubuntu' ">true</_LinuxBuildLibZip>
4+
<_LinuxBuildLibZip Condition=" '$(_LinuxBuildLibZip)' == '' AND '$(HostOS)' == 'Linux' AND '$(HostOsFlavor)' != 'Debian' ">true</_LinuxBuildLibZip>
55
</PropertyGroup>
66
</Project>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
DEBIAN_COMMON_DEPS="autoconf
2+
autotools-dev
3+
automake
4+
clang
5+
curl
6+
g++-mingw-w64
7+
gcc-mingw-w64
8+
git
9+
libtool
10+
libz-mingw-w64-dev
11+
libzip4
12+
linux-libc-dev
13+
make
14+
openjdk-8-jdk
15+
unzip
16+
vim-common
17+
"
18+
19+
if [ "$OS_ARCH" = "x86_64" ]; then
20+
UBUNTU_DEPS="$UBUNTU_DEPS
21+
lib32stdc++6
22+
lib32z1
23+
gcc-multilib
24+
g++-multilib
25+
"
26+
fi
27+
28+
debian_install()
29+
{
30+
if [ "$NO_SUDO" = "true" ]; then
31+
for p in $DISTRO_DEPS; do
32+
if dpkg -l $p > /dev/null 2>&1 ; then
33+
echo "[INSTALLED] $p"
34+
else
35+
echo "[ MISSING ] $p"
36+
PACKAGES_MISSING=yes
37+
fi
38+
done
39+
if [ "x$PACKAGES_MISSING" = "xyes" ]; then
40+
echo Some packages are missing, cannot continue
41+
echo
42+
exit 1
43+
fi
44+
else
45+
sudo apt-get -f -u install $DISTRO_DEPS
46+
fi
47+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
. "`dirname $0`"/debian-common.sh
2+
3+
DISTRO_DEPS="$DEBIAN_COMMON_DEPS \
4+
zlib1g-dev
5+
"
6+
7+
debian_install
Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,13 @@
1-
UBUNTU_DEPS="autoconf
2-
autotools-dev
3-
automake
4-
clang
5-
curl
6-
g++-mingw-w64
7-
gcc-mingw-w64
8-
git
9-
libtool
10-
libz-mingw-w64-dev
11-
libzip4
12-
linux-libc-dev
13-
make
14-
openjdk-8-jdk
15-
unzip
16-
vim-common
17-
"
1+
. "`dirname $0`"/debian-common.sh
2+
3+
DISTRO_DEPS="$DEBIAN_COMMON_DEPS"
184

195
if [ "$OS_ARCH" = "x86_64" ]; then
20-
UBUNTU_DEPS="$UBUNTU_DEPS
21-
lib32stdc++6
22-
lib32z1
23-
gcc-multilib
24-
g++-multilib
25-
libx32tinfo-dev
26-
linux-libc-dev:i386
6+
DISTRO_DEPS="$DISTRO_DEPS
7+
libx32tinfo-dev
8+
linux-libc-dev:i386
279
zlib1g-dev:i386
2810
"
29-
fi
30-
if [ "$NO_SUDO" = "true" ]; then
31-
for p in $UBUNTU_DEPS; do
32-
if dpkg -l $p > /dev/null 2>&1 ; then
33-
echo "[INSTALLED] $p"
34-
else
35-
echo "[ MISSING ] $p"
36-
PACKAGES_MISSING=yes
37-
fi
38-
done
39-
if [ "x$PACKAGES_MISSING" = "xyes" ]; then
40-
echo Some packages are missing, cannot continue
41-
echo
42-
exit 1
43-
fi
44-
else
45-
sudo apt-get -f -u install $UBUNTU_DEPS
4611
fi
12+
13+
debian_install

build-tools/scripts/generate-os-info

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ function getInfo_Linux()
3737
OS_RELEASE="`lsb_release -rs`"
3838
fi
3939

40+
case "$OS_NAME" in
41+
Ubuntu|Debian) HOST_OS_FLAVOR=Debian ;;
42+
*) OS_FLAVOR=Generic ;;
43+
esac
44+
4045
HOST_CPUS="`nproc`"
4146

4247
if echo $compiler_version | grep -i "Free Software Foundation" > /dev/null 2>&1; then
@@ -89,6 +94,7 @@ function getInfo_Darwin()
8994
HOST_CXX32="clang++ -m32"
9095
HOST_CC64=clang
9196
HOST_CXX64=clang++
97+
HOST_OS_FLAVOR=macOS
9298
}
9399

94100
if [ -z "$1" ]; then
@@ -108,6 +114,7 @@ cat <<EOF > "$1"
108114
<PropertyGroup>
109115
<HostOS Condition=" '\$(HostOS)' == '' ">$OS_TYPE</HostOS>
110116
<HostOsName Condition=" '\$(HostOsName)' == '' ">$OS_NAME</HostOsName>
117+
<HostOsFlavor Condition=" '\$(HostOsFlavor)' == '' ">$HOST_OS_FLAVOR</HostOsFlavor>
111118
<HostOsRelease Condition=" '\$(HostOsRelease)' == '' ">$OS_RELEASE</HostOsRelease>
112119
<HostTriplet Condition=" '\$(HostTriplet)' == '' ">$HOST_TRIPLET</HostTriplet>
113120
<HostTriplet32 Condition=" '\$(HostTriplet32)' == '' ">$HOST_TRIPLET32</HostTriplet32>

0 commit comments

Comments
 (0)