Makefile 8.8 KB

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