Makefile 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. RPMS_DIR=rpm/
  2. VERSION := $(shell cat version)
  3. LIBDIR ?= /usr/lib
  4. SYSLIBDIR ?= /lib
  5. PYTHON ?= /usr/bin/python3
  6. # This makefile uses some bash-isms, make uses /bin/sh by default.
  7. SHELL = /bin/bash
  8. help:
  9. @echo "make rpms -- generate binary rpm packages"
  10. @echo "make rpms-vm -- generate binary rpm packages for VM"
  11. @echo "make clean -- cleanup"
  12. @echo "make install-vm -- install VM related files"
  13. @echo ""
  14. @echo "You must have lsb_release, rpm-sign and pandoc installed."
  15. rpms: rpms-vm
  16. rpms-vm:
  17. [ "$$BACKEND_VMM" != "" ] || { echo "error: you must define variable BACKEND_VMM" >&2 ; exit 1 ; }
  18. lsb_release >/dev/null 2>&1 || { echo "error: you need lsb_release (package lsb) installed" >&2 ; exit 1 ; }
  19. type pandoc >/dev/null 2>&1 || { echo "error: you need pandoc installed" >&2 ; exit 1 ; }
  20. type rpmsign >/dev/null 2>&1 || { echo "error: you need rpm-sign installed" >&2 ; exit 1 ; }
  21. rpmbuild --define "_rpmdir $(RPMS_DIR)" -bb rpm_spec/core-vm.spec
  22. rpmbuild --define "_rpmdir $(RPMS_DIR)" -bb rpm_spec/core-vm-doc.spec
  23. [ "$$SKIP_SIGNING" != "" ] || rpm --addsign \
  24. $(RPMS_DIR)/x86_64/qubes-core-vm-*$(VERSION)*.rpm \
  25. $(RPMS_DIR)/x86_64/qubes-core-vm-doc-*$(VERSION)*.rpm
  26. rpms-dom0:
  27. @true
  28. clean:
  29. make -C misc clean
  30. make -C qubes-rpc clean
  31. make -C doc clean
  32. rm -rf qubesagent/*.pyc qubesagent/__pycache__
  33. rm -rf test-packages/__pycache__
  34. rm -rf test-packages/qubesagent.egg-info
  35. rm -rf __pycache__
  36. rm -f .coverage
  37. all:
  38. $(MAKE) -C misc VERSION=$(VERSION)
  39. $(MAKE) -C qubes-rpc
  40. # Dropin Directory
  41. SYSTEM_DROPIN_DIR ?= "lib/systemd/system"
  42. USER_DROPIN_DIR ?= "usr/lib/systemd/user"
  43. SYSTEM_DROPINS := boot.automount chronyd.service crond.service
  44. SYSTEM_DROPINS += cups.service cups-browsed.service cups.path cups.socket ModemManager.service
  45. SYSTEM_DROPINS += getty@tty.service
  46. SYSTEM_DROPINS += tmp.mount
  47. SYSTEM_DROPINS += org.cups.cupsd.service org.cups.cupsd.path org.cups.cupsd.socket
  48. SYSTEM_DROPINS += systemd-random-seed.service
  49. SYSTEM_DROPINS += tor.service tor@default.service
  50. SYSTEM_DROPINS += systemd-timesyncd.service
  51. SYSTEM_DROPINS_NETWORKING := NetworkManager.service NetworkManager-wait-online.service
  52. SYSTEM_DROPINS_NETWORKING += tinyproxy.service
  53. USER_DROPINS := pulseaudio.service pulseaudio.socket
  54. # Ubuntu Dropins
  55. ifeq ($(shell lsb_release -is), Ubuntu)
  56. # 'crond.service' is named 'cron.service in Debian
  57. SYSTEM_DROPINS := $(strip $(patsubst crond.service, cron.service, $(SYSTEM_DROPINS)))
  58. SYSTEM_DROPINS += anacron.service
  59. SYSTEM_DROPINS += anacron-resume.service
  60. SYSTEM_DROPINS += netfilter-persistent.service
  61. SYSTEM_DROPINS += exim4.service
  62. SYSTEM_DROPINS += avahi-daemon.service
  63. endif
  64. # Debian Dropins
  65. ifeq ($(shell lsb_release -is), Debian)
  66. # 'crond.service' is named 'cron.service in Debian
  67. SYSTEM_DROPINS := $(strip $(patsubst crond.service, cron.service, $(SYSTEM_DROPINS)))
  68. # Wheezy System Dropins
  69. # Disable sysinit 'network-manager.service' since systemd 'NetworkManager.service' is already installed
  70. SYSTEM_DROPINS += $(strip $(if $(filter wheezy, $(shell lsb_release -cs)), network-manager.service,))
  71. # handled by qubes-iptables service now
  72. SYSTEM_DROPINS += netfilter-persistent.service
  73. SYSTEM_DROPINS += anacron.service
  74. SYSTEM_DROPINS += anacron-resume.service
  75. SYSTEM_DROPINS += exim4.service
  76. SYSTEM_DROPINS += avahi-daemon.service
  77. endif
  78. install-systemd-dropins:
  79. # Install system dropins
  80. @for dropin in $(SYSTEM_DROPINS); do \
  81. install -d $(DESTDIR)/$(SYSTEM_DROPIN_DIR)/$${dropin}.d ;\
  82. install -m 0644 vm-systemd/$${dropin}.d/*.conf $(DESTDIR)/$(SYSTEM_DROPIN_DIR)/$${dropin}.d/ ;\
  83. done
  84. # Install user dropins
  85. @for dropin in $(USER_DROPINS); do \
  86. install -d $(DESTDIR)/$(USER_DROPIN_DIR)/$${dropin}.d ;\
  87. install -m 0644 vm-systemd/user/$${dropin}.d/*.conf $(DESTDIR)/$(USER_DROPIN_DIR)/$${dropin}.d/ ;\
  88. done
  89. install-systemd-networking-dropins:
  90. # Install system dropins
  91. @for dropin in $(SYSTEM_DROPINS_NETWORKING); do \
  92. install -d $(DESTDIR)/$(SYSTEM_DROPIN_DIR)/$${dropin}.d ;\
  93. install -m 0644 vm-systemd/$${dropin}.d/*.conf $(DESTDIR)/$(SYSTEM_DROPIN_DIR)/$${dropin}.d/ ;\
  94. done
  95. install-init:
  96. install -d $(DESTDIR)$(LIBDIR)/qubes/init
  97. # FIXME: do a source code move vm-systemd/*.sh to init/
  98. # since those scripts are shared between sysvinit and systemd.
  99. install -m 0755 init/*.sh vm-systemd/*.sh $(DESTDIR)$(LIBDIR)/qubes/init/
  100. install -m 0644 init/functions $(DESTDIR)$(LIBDIR)/qubes/init/
  101. # Systemd service files
  102. SYSTEMD_ALL_SERVICES := $(wildcard vm-systemd/qubes-*.service)
  103. SYSTEMD_NETWORK_SERVICES := vm-systemd/qubes-firewall.service vm-systemd/qubes-iptables.service vm-systemd/qubes-updates-proxy.service
  104. SYSTEMD_CORE_SERVICES := $(filter-out $(SYSTEMD_NETWORK_SERVICES), $(SYSTEMD_ALL_SERVICES))
  105. install-systemd: install-init
  106. install -d $(DESTDIR)$(SYSLIBDIR)/systemd/system{,-preset} $(DESTDIR)$(LIBDIR)/qubes/init $(DESTDIR)$(SYSLIBDIR)/modules-load.d
  107. install -m 0644 $(SYSTEMD_CORE_SERVICES) $(DESTDIR)$(SYSLIBDIR)/systemd/system/
  108. install -m 0644 vm-systemd/qubes-*.timer $(DESTDIR)$(SYSLIBDIR)/systemd/system/
  109. install -m 0644 vm-systemd/75-qubes-vm.preset $(DESTDIR)$(SYSLIBDIR)/systemd/system-preset/
  110. install -m 0644 vm-systemd/qubes-core.conf $(DESTDIR)$(SYSLIBDIR)/modules-load.d/
  111. install-sysvinit: install-init
  112. install -d $(DESTDIR)/etc/init.d
  113. install vm-init.d/qubes-sysinit $(DESTDIR)/etc/init.d/
  114. install vm-init.d/qubes-core-early $(DESTDIR)/etc/init.d/
  115. install vm-init.d/qubes-core $(DESTDIR)/etc/init.d/
  116. install vm-init.d/qubes-core-netvm $(DESTDIR)/etc/init.d/
  117. install vm-init.d/qubes-firewall $(DESTDIR)/etc/init.d/
  118. install vm-init.d/qubes-updates-proxy $(DESTDIR)/etc/init.d/
  119. install vm-init.d/qubes-updates-proxy-forwarder $(DESTDIR)/etc/init.d/
  120. install -D vm-init.d/qubes-core.modules $(DESTDIR)/etc/sysconfig/modules/qubes-core.modules
  121. install network/qubes-iptables $(DESTDIR)/etc/init.d/
  122. install-rh: install-systemd install-systemd-dropins install-sysvinit
  123. install-doc:
  124. $(MAKE) -C doc install
  125. install-common: install-doc
  126. $(MAKE) -C autostart-dropins install
  127. $(MAKE) -C applications-dropins install
  128. # force /usr/bin before /bin to have /usr/bin/python instead of /bin/python
  129. PATH="/usr/bin:$(PATH)" $(PYTHON) setup.py install $(PYTHON_PREFIX_ARG) -O1 --root $(DESTDIR)
  130. # Networking install target includes:
  131. # * basic network functionality (setting IP address, DNS, default gateway)
  132. # * package update proxy client
  133. install-networking:
  134. install -d $(DESTDIR)$(SYSLIBDIR)/systemd/system
  135. install -m 0644 vm-systemd/qubes-*.socket $(DESTDIR)$(SYSLIBDIR)/systemd/system/
  136. # Netvm install target includes:
  137. # * qubes-firewall service (FirewallVM)
  138. # * DNS redirection setup
  139. # * proxy service used by TemplateVMs to download updates
  140. install-netvm:
  141. install -D -m 0644 $(SYSTEMD_NETWORK_SERVICES) $(DESTDIR)$(SYSLIBDIR)/systemd/system/
  142. install -D -m 0755 network/qubes-iptables $(DESTDIR)$(LIBDIR)/qubes/init/qubes-iptables
  143. install -D -m 0644 vm-systemd/qubes-core-agent-linux.tmpfiles \
  144. $(DESTDIR)/usr/lib/tmpfiles.d/qubes-core-agent-linux.conf
  145. install -D network/qubes-setup-dnat-to-ns $(DESTDIR)$(LIBDIR)/qubes/qubes-setup-dnat-to-ns
  146. install -d $(DESTDIR)/etc/dhclient.d
  147. ln -s /usr/lib/qubes/qubes-setup-dnat-to-ns $(DESTDIR)/etc/dhclient.d/qubes-setup-dnat-to-ns.sh
  148. install -D network/vif-route-qubes $(DESTDIR)/etc/xen/scripts/vif-route-qubes
  149. install -D network/vif-qubes-nat.sh $(DESTDIR)/etc/xen/scripts/vif-qubes-nat.sh
  150. install -m 0644 -D network/tinyproxy-updates.conf $(DESTDIR)/etc/tinyproxy/tinyproxy-updates.conf
  151. install -m 0644 -D network/updates-blacklist $(DESTDIR)/etc/tinyproxy/updates-blacklist
  152. install -m 0755 -D network/iptables-updates-proxy $(DESTDIR)$(LIBDIR)/qubes/iptables-updates-proxy
  153. install -m 0400 -D network/iptables $(DESTDIR)/etc/qubes/iptables.rules
  154. install -m 0400 -D network/ip6tables $(DESTDIR)/etc/qubes/ip6tables.rules
  155. install -m 0400 -D network/ip6tables-enabled $(DESTDIR)/etc/qubes/ip6tables-enabled.rules
  156. install -m 0755 -D qubes-rpc/qubes.UpdatesProxy $(DESTDIR)/etc/qubes-rpc/qubes.UpdatesProxy
  157. # networkmanager install target allow integration of NetworkManager for Qubes VM:
  158. # * make connections config persistent
  159. # * adjust DNS redirections when needed
  160. # * show/hide NetworkManager applet icon
  161. install-networkmanager:
  162. install -d $(DESTDIR)$(LIBDIR)/qubes/
  163. install network/qubes-fix-nm-conf.sh $(DESTDIR)$(LIBDIR)/qubes/
  164. install network/network-manager-prepare-conf-dir $(DESTDIR)$(LIBDIR)/qubes/
  165. install -d $(DESTDIR)/etc/NetworkManager/dispatcher.d/
  166. install network/{qubes-nmhook,30-qubes-external-ip} $(DESTDIR)/etc/NetworkManager/dispatcher.d/
  167. install -d $(DESTDIR)/usr/lib/NetworkManager/conf.d
  168. install -m 0644 network/nm-30-qubes.conf $(DESTDIR)/usr/lib/NetworkManager/conf.d/30-qubes.conf
  169. install -d $(DESTDIR)/etc/xdg/autostart
  170. install -m 0755 network/show-hide-nm-applet.sh $(DESTDIR)$(LIBDIR)/qubes/
  171. install -m 0644 network/show-hide-nm-applet.desktop $(DESTDIR)/etc/xdg/autostart/00-qubes-show-hide-nm-applet.desktop
  172. install-deb: install-common install-systemd install-systemd-dropins install-systemd-networking-dropins install-networking install-networkmanager install-netvm
  173. install -d $(DESTDIR)/etc/sysctl.d
  174. install -m 644 network/80-qubes.conf $(DESTDIR)/etc/sysctl.d/
  175. install -d $(DESTDIR)/etc/needrestart/conf.d
  176. install -D -m 0644 misc/50_qubes.conf $(DESTDIR)/etc/needrestart/conf.d/50_qubes.conf
  177. mkdir -p $(DESTDIR)/etc/systemd/system/
  178. install -m 0644 vm-systemd/haveged.service $(DESTDIR)/etc/systemd/system/
  179. install-corevm: install-rh install-common install-systemd install-sysvinit install-systemd-dropins install-networking
  180. install-netvm: install-systemd-networking-dropins install-networkmanager
  181. install-vm: install-corevm install-netvm