core-appvm.spec 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #
  2. # The Qubes OS Project, http://www.qubes-os.org
  3. #
  4. # Copyright (C) 2010 Joanna Rutkowska <joanna@invisiblethingslab.com>
  5. # Copyright (C) 2010 Rafal Wojtczuk <rafal@invisiblethingslab.com>
  6. #
  7. # This program is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU General Public License
  9. # as published by the Free Software Foundation; either version 2
  10. # of the License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  20. #
  21. #
  22. %{!?version: %define version %(cat version_vm)}
  23. Name: qubes-core-appvm
  24. Version: %{version}
  25. Release: 1
  26. Summary: The Qubes core files for AppVM
  27. Group: Qubes
  28. Vendor: Invisible Things Lab
  29. License: GPL
  30. URL: http://www.qubes-os.org
  31. Requires: /usr/bin/xenstore-read
  32. Provides: qubes-core-vm
  33. %define _builddir %(pwd)/appvm
  34. %define kde_service_dir /usr/share/kde4/services/ServiceMenus
  35. %description
  36. The Qubes core files for installation inside a Qubes AppVM.
  37. %pre
  38. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes
  39. [ -e $RPM_BUILD_ROOT/etc/fstab ] && mv $RPM_BUILD_ROOT/etc/fstab $RPM_BUILD_ROOT/var/lib/qubes/fstab.orig
  40. %build
  41. make clean all
  42. %install
  43. mkdir -p $RPM_BUILD_ROOT/etc
  44. cp fstab $RPM_BUILD_ROOT/etc/fstab
  45. mkdir -p $RPM_BUILD_ROOT/etc/init.d
  46. cp qubes_core $RPM_BUILD_ROOT/etc/init.d/
  47. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes
  48. mkdir -p $RPM_BUILD_ROOT/usr/bin
  49. cp qubes_add_pendrive_script qubes_penctl qvm-copy-to-vm qvm-copy-to-vm.kde $RPM_BUILD_ROOT/usr/bin
  50. mkdir -p $RPM_BUILD_ROOT/%{kde_service_dir}
  51. cp qvm-copy.desktop $RPM_BUILD_ROOT/%{kde_service_dir}
  52. mkdir -p $RPM_BUILD_ROOT/etc/udev/rules.d
  53. cp qubes.rules $RPM_BUILD_ROOT/etc/udev/rules.d
  54. mkdir -p $RPM_BUILD_ROOT/etc/sysconfig
  55. cp iptables $RPM_BUILD_ROOT/etc/sysconfig/
  56. mkdir -p $RPM_BUILD_ROOT/mnt/incoming
  57. mkdir -p $RPM_BUILD_ROOT/mnt/outgoing
  58. %post
  59. if [ "$1" != 1 ] ; then
  60. # do this whole %post thing only when updating for the first time...
  61. exit 0
  62. fi
  63. echo "--> Disabling SELinux..."
  64. sed -e s/^SELINUX=.*$/SELINUX=disabled/ </etc/selinux/config >/etc/selinux/config.processed
  65. mv /etc/selinux/config.processed /etc/selinux/config
  66. setenforce 0
  67. echo "--> Turning off unnecessary services..."
  68. # FIXME: perhaps there is more elegant way to do this?
  69. for f in /etc/init.d/*
  70. do
  71. srv=`basename $f`
  72. [ $srv = 'functions' ] && continue
  73. [ $srv = 'killall' ] && continue
  74. [ $srv = 'halt' ] && continue
  75. chkconfig $srv off
  76. done
  77. echo "--> Enabling essential services..."
  78. chkconfig rsyslog on
  79. chkconfig haldaemon on
  80. chkconfig messagebus on
  81. chkconfig cups on
  82. chkconfig iptables on
  83. chkconfig --add qubes_core || echo "WARNING: Cannot add service qubes_core!"
  84. chkconfig qubes_core on || echo "WARNING: Cannot enable service qubes_core!"
  85. sed -i s/^id:.:initdefault:/id:3:initdefault:/ /etc/inittab
  86. # Remove most of the udev scripts to speed up the VM boot time
  87. # Just leave the xen* scripts, that are needed if this VM was
  88. # ever used as a net backend (e.g. as a VPN domain in the future)
  89. echo "--> Removing unnecessary udev scripts..."
  90. mkdir -p /var/lib/qubes/removed-udev-scripts
  91. for f in /etc/udev/rules.d/*
  92. do
  93. if [ $(basename $f) == "xen-backend.rules" ] ; then
  94. continue
  95. fi
  96. if [ $(basename $f) == "xend.rules" ] ; then
  97. continue
  98. fi
  99. if [ $(basename $f) == "qubes.rules" ] ; then
  100. continue
  101. fi
  102. if [ $(basename $f) == "90-hal.rules" ] ; then
  103. continue
  104. fi
  105. mv $f /var/lib/qubes/removed-udev-scripts/
  106. done
  107. mkdir -p /rw
  108. #rm -f /etc/mtab
  109. echo "--> Removing HWADDR setting from /etc/sysconfig/network-scripts/ifcfg-eth0"
  110. mv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.orig
  111. grep -v HWADDR /etc/sysconfig/network-scripts/ifcfg-eth0.orig > /etc/sysconfig/network-scripts/ifcfg-eth0
  112. %preun
  113. if [ "$1" = 0 ] ; then
  114. # no more packages left
  115. chkconfig qubes_core off
  116. mv /var/lib/qubes/fstab.orig /etc/fstab
  117. mv /var/lib/qubes/removed-udev-scripts/* /etc/udev/rules.d/
  118. fi
  119. %clean
  120. rm -rf $RPM_BUILD_ROOT
  121. %files
  122. %defattr(-,root,root,-)
  123. /etc/fstab
  124. /etc/init.d/qubes_core
  125. /usr/bin/qvm-copy-to-vm
  126. /usr/bin/qvm-copy-to-vm.kde
  127. %{kde_service_dir}/qvm-copy.desktop
  128. %attr(4755,root,root) /usr/bin/qubes_penctl
  129. /usr/bin/qubes_add_pendrive_script
  130. /etc/udev/rules.d/qubes.rules
  131. /etc/sysconfig/iptables
  132. %dir /var/lib/qubes
  133. %dir /mnt/incoming
  134. %dir /mnt/outgoing