Skip to content

Commit c05fa2f

Browse files
committed
Make package installation on Linux optional
Xamarin.Android needs a number of packages to be installed on Linux in order to build properly. The makefile provides support for that but it requires using `sudo` to invoke the package installer. That may not be desired on build bots and so this commit makes package installation optional. In order to avoid package installation invoke make like so: make NO_SUDO=true prepare In this mode the makefile will merely report the installation status of all the dependency packages instead of installing them.
1 parent b184649 commit c05fa2f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ include build-tools/scripts/BuildEverything.mk
4444

4545
# Please keep the package names sorted
4646
ifeq ($(OS),Linux)
47+
NO_SUDO ?= false
48+
4749
UBUNTU_DEPS = \
4850
autoconf \
4951
autotools-dev \
@@ -84,10 +86,34 @@ prepare:: linux-prepare-$(LINUX_DISTRO) linux-prepare-$(LINUX_DISTRO)-$(LINUX_DI
8486
cat Documentation/binfmt_misc-warning-Linux.txt ; \
8587
fi
8688

89+
ifeq ($(NO_SUDO),false)
8790
linux-prepare-Ubuntu::
91+
@echo
8892
@echo Installing build depedencies for $(LINUX_DISTRO)
8993
@echo Will use sudo, please provide your password as needed
94+
@echo
9095
sudo apt-get -f -u install $(UBUNTU_DEPS)
96+
else
97+
linux-prepare-Ubuntu::
98+
@echo
99+
@echo sudo is disabled, cannot install dependencies
100+
@echo Listing status of all the dependencies
101+
@PACKAGES_MISSING=no ; \
102+
for p in $(UBUNTU_DEPS); do \
103+
if dpkg -l $$p > /dev/null 2>&1 ; then \
104+
echo "[INSTALLED] $$p" ; \
105+
else \
106+
echo "[ MISSING ] $$p" ; \
107+
PACKAGES_MISSING=yes ; \
108+
fi ; \
109+
done ; \
110+
echo ; \
111+
if [ "x$$PACKAGES_MISSING" = "xyes" ]; then \
112+
echo Some packages are missing, cannot continue ; \
113+
echo ; \
114+
false ; \
115+
fi
116+
endif
91117

92118
linux-prepare-$(LINUX_DISTRO)::
93119

0 commit comments

Comments
 (0)