core-netvm.spec 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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-netvm
  24. Version: %{version}
  25. Release: 1
  26. Summary: The Qubes core files for NetVM
  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)/netvm
  34. %description
  35. The Qubes core files for installation inside a Qubes NetVM.
  36. %pre
  37. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes
  38. [ -e $RPM_BUILD_ROOT/etc/fstab ] && mv $RPM_BUILD_ROOT/etc/fstab $RPM_BUILD_ROOT/var/lib/qubes/fstab.orig
  39. %build
  40. %install
  41. mkdir -p $RPM_BUILD_ROOT/etc/sysconfig
  42. cp iptables $RPM_BUILD_ROOT/etc/sysconfig
  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. %post
  49. if [ "$1" != 1 ] ; then
  50. # do this whole %post thing only when updating for the first time...
  51. exit 0
  52. fi
  53. echo "--> Disabling SELinux..."
  54. sed -e s/^SELINUX=.*$/SELINUX=disabled/ </etc/selinux/config >/etc/selinux/config.processed
  55. mv /etc/selinux/config.processed /etc/selinux/config
  56. setenforce 0
  57. echo "--> Turning off unnecessary services..."
  58. # FIXME: perhaps there is more elegant way to do this?
  59. for f in /etc/init.d/*
  60. do
  61. srv=`basename $f`
  62. [ $srv = 'functions' ] && continue
  63. [ $srv = 'killall' ] && continue
  64. [ $srv = 'halt' ] && continue
  65. chkconfig $srv off
  66. done
  67. echo "--> Enabling essential services..."
  68. chkconfig iptables on
  69. chkconfig rsyslog on
  70. chkconfig haldaemon on
  71. chkconfig messagebus on
  72. chkconfig NetworkManager on
  73. chkconfig --add qubes_core || echo "WARNING: Cannot add service qubes_core!"
  74. chkconfig qubes_core on || echo "WARNING: Cannot enable service qubes_core!"
  75. sed -i s/^id:.:initdefault:/id:3:initdefault:/ /etc/inittab
  76. # Remove most of the udev scripts to speed up the VM boot time
  77. # Just leave the xen* scripts, that are needed if this VM was
  78. # ever used as a net backend (e.g. as a VPN domain in the future)
  79. echo "--> Removing unnecessary udev scripts..."
  80. mkdir -p /var/lib/qubes/removed-udev-scripts
  81. for f in /etc/udev/rules.d/*
  82. do
  83. if [ $(basename $f) == "xen-backend.rules" ] ; then
  84. continue
  85. fi
  86. if [ $(basename $f) == "xend.rules" ] ; then
  87. continue
  88. fi
  89. if [ $(basename $f) == "qubes.rules" ] ; then
  90. continue
  91. fi
  92. if [ $(basename $f) == "90-hal.rules" ] ; then
  93. continue
  94. fi
  95. mv $f /var/lib/qubes/removed-udev-scripts/
  96. done
  97. #rm -f /etc/mtab
  98. #echo "--> Removing HWADDR setting from /etc/sysconfig/network-scripts/ifcfg-eth0"
  99. #mv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.orig
  100. #grep -v HWADDR /etc/sysconfig/network-scripts/ifcfg-eth0.orig > /etc/sysconfig/network-scripts/ifcfg-eth0
  101. %preun
  102. if [ "$1" = 0 ] ; then
  103. # no more packages left
  104. chkconfig qubes_core off
  105. mv /var/lib/qubes/fstab.orig /etc/fstab
  106. mv /var/lib/qubes/removed-udev-scripts/* /etc/udev/rules.d/
  107. fi
  108. %clean
  109. rm -rf $RPM_BUILD_ROOT
  110. %files
  111. %defattr(-,root,root,-)
  112. /etc/fstab
  113. /etc/sysconfig/iptables
  114. /etc/init.d/qubes_core
  115. %dir /var/lib/qubes