actions.py 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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 get
  7. from pisi.actionsapi import autotools
  8. from pisi.actionsapi import pisitools
  9. from pisi.actionsapi import shelltools
  10. def extensions():
  11. configure_disabled = []
  12. configure_enabled = [
  13. 'exif', 'ftp', 'soap', 'sockets', 'bcmath',
  14. 'dom', 'wddx', 'tokenizer', 'simplexml', 'mbstring', 'calendar',
  15. 'gd-native-ttf', 'gd'
  16. ]
  17. configure_shared = [
  18. 'dba', 'embedded-mysqli', 'zip', 'gd'
  19. ]
  20. configure_with = [
  21. 'bz2', 'curl', 'iconv', 'mysql', 'mysqli', 'kerberos', 'sqlite3',
  22. 'xsl', 'gdbm', 'db', 'ldap', 'gd', 'gettext',
  23. 'regex=php', 'pic', 'pcre-regex', 'pgsql', 'pdo-mysql', 'pdo-pgsql',
  24. 'openssl'
  25. ]
  26. configure_without = []
  27. conf = []
  28. for i in configure_disabled:
  29. conf.append("--disable-%s" % i)
  30. for i in configure_enabled:
  31. conf.append("--enable-%s " % i)
  32. for i in configure_shared:
  33. conf.append("--enable-%s=shared" % i)
  34. for i in configure_with:
  35. conf.append("--with-%s" % i)
  36. for i in configure_without:
  37. conf.append("--without-%s" % i)
  38. return ' '.join(conf)
  39. def setup():
  40. #shelltools.unlinkDir("ext/openssl")
  41. # create directories for apache, fcgi and fpm's Makefiles
  42. shelltools.makedirs("fcgi")
  43. shelltools.makedirs("apache")
  44. shelltools.makedirs("fpm")
  45. shelltools.makedirs("common")
  46. # link configure script
  47. shelltools.sym("../configure", "fcgi/configure")
  48. shelltools.sym("../configure", "apache/configure")
  49. shelltools.sym("../configure", "fpm/configure")
  50. shelltools.sym("../configure", "common/configure")
  51. shelltools.export("LC_ALL", "C")
  52. shelltools.export("CFLAGS", "%s -fwrapv -lkrb5 -lgssapi_krb5 -lpam -DU_USING_ICU_NAMESPACE=1" % get.CFLAGS())
  53. shelltools.export("NO_INTERACTION", "1")
  54. shelltools.export("EXTENSION_DIR", "/usr/lib/php/modules")
  55. # shelltools.system("sed -i '/APACHE_THREADED_MPM=/d' sapi/apache2handler/config.m4")
  56. # pisitools.dosed("ext/pgsql/config.m4", "include/postgresql", " include/postgresql/pgsql")
  57. # Don't touch apache.conf
  58. # for i in pisitools.ls("sapi/*/config.m4"):
  59. # pisitools.dosed(i, "\\-i \\-a \\-n php8", "-i -n php8")
  60. # pisitools.dosed(i, "\\-i \\-A \\-n php8", "-i -n php8")
  61. autotools.autoconf()
  62. # workaround for pkg-config 0.28
  63. pisitools.dosed("configure", " && test -n \"\$OPENSSL_INCS\"")
  64. common_options = "--sysconfdir=/etc \
  65. --cache-file=./config.cache \
  66. --with-zlib-dir=/usr/lib \
  67. --with-libxml-dir=/usr/lib \
  68. --with-jpeg-dir=/usr/lib/ \
  69. --with-png-dir=/usr/lib/ \
  70. --with-freetype-dir=/usr \
  71. --with-zend-vm=GOTO \
  72. --with-zend-vm=SWITCH \
  73. --with-db4=/usr/lib \
  74. --with-pic \
  75. --with-libzip \
  76. --with-gnu-ld \
  77. --enable-gd=shared \
  78. --with-external-gd \
  79. --config-cache \
  80. --with-system-tzdata=/usr/share/zoneinfo \
  81. --with-mcrypt=/usr/bin/mcrypt \
  82. --with-imap=shared \
  83. --with-imap-ssl \
  84. --with-mysql-sock=/run/mysqld/mysqld.sock \
  85. --with-pear \
  86. --with-zlib \
  87. --with-zip=shared \
  88. --disable-rpath \
  89. "
  90. # Enable FastCGI and CGI
  91. shelltools.cd("fcgi")
  92. autotools.configure("--enable-cgi \
  93. --disable-cli \
  94. --with-config-file-path=/etc/php/cli \
  95. --with-config-file-scan-dir=/etc/php/cli/ext \
  96. %s \
  97. %s" % (common_options, extensions()))
  98. # Enable Apache
  99. shelltools.cd("../apache")
  100. autotools.configure("--with-apxs2=/usr/bin/apxs \
  101. --disable-cli \
  102. --with-config-file-path=/etc/php/apache2 \
  103. --with-config-file-scan-dir=/etc/php/apache2/ext \
  104. %s \
  105. %s" % (common_options, extensions()))
  106. # Enable FPM
  107. shelltools.cd("../fpm")
  108. autotools.configure("--enable-fpm \
  109. --disable-cli \
  110. --with-fpm-user=apache \
  111. --with-fpm-group=apache \
  112. --with-config-file-path=/etc/php/apache2 \
  113. --with-config-file-scan-dir=/etc/php/apache2/ext \
  114. %s \
  115. %s" % (common_options, extensions()))
  116. # Enable common
  117. shelltools.cd("../common")
  118. autotools.configure("--enable-cli \
  119. --enable-phpdbg \
  120. %s \
  121. %s" % (common_options, extensions()))
  122. def build():
  123. shelltools.cd("fcgi")
  124. shelltools.export("LC_ALL", "en_US.UTF-8")
  125. autotools.make()
  126. shelltools.cd("../apache")
  127. autotools.make()
  128. shelltools.cd("../fpm")
  129. autotools.make()
  130. shelltools.cd("../common")
  131. autotools.make()
  132. def check():
  133. shelltools.cd("apache")
  134. autotools.make("test")
  135. def install():
  136. shelltools.cd("fcgi")
  137. # autotools.rawInstall("INSTALL_ROOT=\"%s\"" % get.installDIR(), "install-modules install-build install-headers install-programs install-pharcmd")
  138. autotools.rawInstall("INSTALL_ROOT=\"%s\"" % get.installDIR(), "install-cgi")
  139. autotools.rawInstall("INSTALL_ROOT=\"%s\"" % get.installDIR(), "install-sapi")
  140. shelltools.cd("../apache")
  141. # autotools.rawInstall("INSTALL_ROOT=\"%s\"" % get.installDIR(), "install-modules install-sapi")
  142. pisitools.insinto("/usr/lib/apache2/modules", "libs/libphp.so")
  143. shelltools.chmod(get.installDIR() + "/usr/lib/apache2/modules/libphp.so")
  144. shelltools.cd("../fpm")
  145. autotools.rawInstall("INSTALL_ROOT=\"%s\"" % get.installDIR(), "install-fpm")
  146. shelltools.cd("../common")
  147. autotools.rawInstall("INSTALL_ROOT=\"%s\"" % get.installDIR(), "install")
  148. shelltools.cd("..")
  149. pisitools.insinto("/etc/php/apache2/", "php.ini-development", "php.ini")
  150. pisitools.insinto("/etc/php/cli/", "php.ini-development", "php.ini")
  151. pisitools.dosed("%s/etc/php/*/php.ini" % get.installDIR(), "(extension_dir = .*)", ";\\1")
  152. pisitools.dosed("%s/etc/php/*/php.ini" % get.installDIR(), r";include_path = \".:/php/includes\"",
  153. "include_path = \".:/usr/share/php5/PEAR\"")
  154. pisitools.dodir("/etc/php/ext")
  155. pisitools.dodir("/etc/php/apache2/ext")
  156. pisitools.dodir("/etc/php/cli/ext")
  157. # Operations for php-zip package
  158. pisitools.dosym("/etc/php/ext/10-php-zip.ini", "/etc/php/cli/ext/10-php-zip.ini")
  159. # Operations for php-imap package
  160. pisitools.dosym("/etc/php/ext/11-php-imap.ini", "/etc/php/cli/ext/11-php-imap.ini")
  161. pisitools.dosym("/etc/php/ext/11-php-imap.ini", "/etc/php/apache2/ext/11-php-imap.ini")
  162. # Move /var/run to run
  163. pisitools.domove("/var/run", "/")
  164. pisitools.remove("/etc/php-fpm.conf.default")
  165. pisitools.dodir("/var/log/php-fpm/")
  166. pisitools.remove("/.depdb")
  167. pisitools.remove("/.depdblock")
  168. pisitools.remove("/.lock")
  169. pisitools.remove("/.filemap")
  170. pisitools.removeDir("/.channels")
  171. pisitools.removeDir("/.registry")