actions.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Licensed under the GNU General Public License, version 3.
  5. # See the file http://www.gnu.org/licenses/gpl.txt
  6. from pisi.actionsapi import autotools
  7. from pisi.actionsapi import pisitools
  8. from pisi.actionsapi import shelltools
  9. from pisi.actionsapi import get
  10. WorkDir = "httpd-%s" % get.srcVERSION()
  11. def config_layout():
  12. return """
  13. <Layout PisiLinux>
  14. prefix: /usr
  15. exec_prefix: /usr
  16. bindir: /usr/bin
  17. sbindir: /usr/sbin
  18. libdir: /usr/lib
  19. libexecdir: /usr/lib/apache2/modules
  20. mandir: /usr/share/man
  21. infodir: /usr/share/info
  22. includedir: /usr/include/apache2
  23. installbuilddir: /usr/lib/apache2/build
  24. datadir: /var/www/localhost
  25. errordir: /var/www/localhost/error
  26. iconsdir: /var/www/localhost/icons
  27. htdocsdir: /var/www/localhost/htdocs
  28. cgidir: /var/www/localhost/cgi-bin
  29. manualdir: /usr/share/doc/version/manual
  30. sysconfdir: /etc/apache2
  31. localstatedir: /var
  32. runtimedir: /run
  33. logfiledir: /var/log/apache2
  34. proxycachedir: /var/cache/apache2
  35. </Layout>"""
  36. def modules_config():
  37. disabled = ['bucketeer', 'example', 'optional-fn-export', 'optional-fn-import',
  38. 'optional-hook-export','optional-hook-import']
  39. static = ['so']
  40. # auth_ldap, ldap needed
  41. shared = ['actions', 'alias', 'asis', 'auth_basic', 'authn_dbm', 'authn_file',
  42. 'auth_digest', 'authz_host', 'autoindex', 'cache', 'case_filter',
  43. 'case-filter-in', 'cern-meta', 'cgi', 'cgid', 'charset-lite', 'dav',
  44. 'dav-fs', 'deflate', 'dir', 'disk-cache', 'echo', 'env', 'expires',
  45. 'ext-filter', 'file-cache', 'headers', 'imagemap', 'include', 'info',
  46. 'log_config', 'logio', 'mem-cache', 'mime', 'mime-magic', 'negotiation',
  47. 'proxy', 'proxy-connect','proxy-ftp', 'proxy-http', 'rewrite', 'setenvif',
  48. 'speling', 'status', 'unique-id', 'userdir', 'usertrack', 'vhost-alias']
  49. conf = ""
  50. for i in disabled:
  51. conf += "--disable-%s " % i
  52. for i in static:
  53. conf += "--enable-%s=yes " % i
  54. for i in shared:
  55. conf += "--enable-%s=shared " % i
  56. return conf
  57. def setup():
  58. shelltools.echo("config.layout", config_layout())
  59. pisitools.dosed("config.layout", "version", get.srcNAME())
  60. #for d in ["apr","apr-util","pcre"]:
  61. #shelltools.unlinkDir("srclib/%s" % d)
  62. # this fixes segfaults, remember omit-frame-pointer will be default soon
  63. if get.ARCH() == "i686":
  64. shelltools.export("CFLAGS", "%s -fno-omit-frame-pointer" % get.CFLAGS())
  65. shelltools.export("LDFLAGS", "-Wl,-z,relro,-z,now")
  66. autotools.rawConfigure('--with-mpm=prefork \
  67. --enable-layout=PisiLinux \
  68. --enable-mods-shared=all \
  69. --with-ssl=/usr \
  70. --enable-ssl=shared \
  71. %s \
  72. --with-z=/usr \
  73. --with-port=80 \
  74. --with-program-name=apache2 \
  75. --with-apr=/usr/bin/apr-1-config \
  76. --with-apr-util=/usr/bin/apu-1-config \
  77. --with-suexec-safepath="/usr/bin:/bin" \
  78. --with-suexec-logfile=/var/log/apache2/suexec_log \
  79. --with-suexec-bin=/usr/sbin/suexec \
  80. --with-suexec-userdir="public_html" \
  81. --with-suexec-caller=apache \
  82. --with-suexec-docroot=/var/www \
  83. --with-suexec-uidmin=1000 \
  84. --with-suexec-gidmin=100 \
  85. --with-suexec-umask=077 \
  86. --enable-suexec=shared \
  87. --enable-pie \
  88. --with-pcre=/usr/bin/pcre-config' % modules_config())
  89. pisitools.dosed("include/ap_config_auto.h", "apache2\.conf", "httpd.conf")
  90. def build():
  91. autotools.make()
  92. def install():
  93. autotools.rawInstall("DESTDIR=%s INSTALL_SUEXEC='setuid'" % get.installDIR())
  94. pisitools.dosym("/usr/lib", "/usr/lib/apache2/lib")
  95. pisitools.dosym("/var/log/apache2", "/usr/lib/apache2/logs")
  96. pisitools.dosym("/etc/apache2", "/usr/lib/apache2/conf")
  97. pisitools.dosbin("support/split-logfile")
  98. pisitools.dosbin("support/list_hooks.pl")
  99. pisitools.dosbin("support/logresolve.pl")
  100. pisitools.dosbin("support/log_server_status")
  101. pisitools.dosbin("apache2")
  102. pisitools.domove("/usr/sbin/envvars*", "/usr/lib/apache2/build")
  103. pisitools.dosed("%s/usr/bin/apxs" % get.installDIR(), \
  104. "my \$envvars = get_vars\(\"bindir\"\) \. \"/envvars\";", \
  105. "my $envvars = \"$installbuilddir/envvars\";")
  106. # Clean-up
  107. pisitools.remove("/etc/apache2/*")
  108. pisitools.remove("/var/www/localhost/htdocs/*")
  109. # Add conf.d for 3rd party configuration files
  110. pisitools.dodir("/etc/apache2/conf.d")
  111. # ssl enabled apache needs that one
  112. pisitools.dodir("/var/cache/apache2")
  113. # Fix wrong libtool path
  114. pisitools.dosed("%s/usr/lib/apache2/build/config_vars.mk" % get.installDIR(), \
  115. "/usr/lib/apache2/build/libtool", \
  116. "/usr/bin/libtool")
  117. # Remove cgi scripts which are vulnerable, see CVE-2007-4049
  118. pisitools.remove("/var/www/localhost/cgi-bin/*")
  119. pisitools.dodoc("ABOUT_APACHE", "CHANGES", "LAYOUT", "LICENSE", "README*")
  120. pisitools.removeDir("/run")