nginx.inc 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. SUMMARY = "HTTP and reverse proxy server"
  2. DESCRIPTION = "Nginx is a web server and a reverse proxy server for \
  3. HTTP, SMTP, POP3 and IMAP protocols, with a strong focus on high \
  4. concurrency, performance and low memory usage."
  5. HOMEPAGE = "http://nginx.org/"
  6. LICENSE = "BSD-2-Clause"
  7. SECTION = "net"
  8. DEPENDS = "libpcre zlib openssl"
  9. SRC_URI = " \
  10. http://nginx.org/download/nginx-${PV}.tar.gz \
  11. file://nginx-cross.patch \
  12. file://0001-Allow-the-overriding-of-the-endianness-via-the-confi.patch \
  13. file://nginx.conf \
  14. file://nginx.init \
  15. file://nginx-volatile.conf \
  16. file://nginx.service \
  17. "
  18. inherit siteinfo update-rc.d useradd systemd
  19. SYSTEMD_SERVICE_${PN} = "nginx.service"
  20. CFLAGS_append = " -fPIE -pie"
  21. CXXFLAGS_append = " -fPIE -pie"
  22. NGINX_WWWDIR ?= "${localstatedir}/www/localhost"
  23. NGINX_USER ?= "www"
  24. EXTRA_OECONF = ""
  25. DISABLE_STATIC = ""
  26. PACKAGECONFIG[http2] = "--with-http_v2_module,,"
  27. do_configure () {
  28. if [ "${SITEINFO_BITS}" = "64" ]; then
  29. PTRSIZE=8
  30. else
  31. PTRSIZE=4
  32. fi
  33. echo $CFLAGS
  34. echo $LDFLAGS
  35. # Add the LDFLAGS to the main nginx link to avoid issues with missing GNU_HASH
  36. echo "MAIN_LINK=\"\${MAIN_LINK} ${LDFLAGS}\"" >> auto/cc/conf
  37. ./configure \
  38. --crossbuild=Linux:${TUNE_ARCH} \
  39. --with-endian=${@oe.utils.conditional('SITEINFO_ENDIANNESS', 'le', 'little', 'big', d)} \
  40. --with-int=4 \
  41. --with-long=${PTRSIZE} \
  42. --with-long-long=8 \
  43. --with-ptr-size=${PTRSIZE} \
  44. --with-sig-atomic-t=${PTRSIZE} \
  45. --with-size-t=${PTRSIZE} \
  46. --with-off-t=${PTRSIZE} \
  47. --with-time-t=${PTRSIZE} \
  48. --with-sys-nerr=132 \
  49. --conf-path=${sysconfdir}/nginx/nginx.conf \
  50. --http-log-path=${localstatedir}/log/nginx/access.log \
  51. --error-log-path=${localstatedir}/log/nginx/error.log \
  52. --http-client-body-temp-path=/run/nginx/client_body_temp \
  53. --http-proxy-temp-path=/run/nginx/proxy_temp \
  54. --http-fastcgi-temp-path=/run/nginx/fastcgi_temp \
  55. --http-uwsgi-temp-path=/run/nginx/uwsgi_temp \
  56. --http-scgi-temp-path=/run/nginx/scgi_temp \
  57. --pid-path=/run/nginx/nginx.pid \
  58. --prefix=${prefix} \
  59. --with-http_ssl_module \
  60. --with-http_gzip_static_module \
  61. ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS}
  62. }
  63. do_install () {
  64. oe_runmake 'DESTDIR=${D}' install
  65. rm -fr ${D}${localstatedir}/run ${D}/run
  66. if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
  67. install -d ${D}${sysconfdir}/tmpfiles.d
  68. echo "d /run/${BPN} - - - -" \
  69. > ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
  70. echo "d /${localstatedir}/log/${BPN} 0755 root root -" \
  71. >> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
  72. fi
  73. install -d ${D}${sysconfdir}/${BPN}
  74. ln -snf ${localstatedir}/run/${BPN} ${D}${sysconfdir}/${BPN}/run
  75. install -d ${D}${NGINX_WWWDIR}
  76. mv ${D}/usr/html ${D}${NGINX_WWWDIR}/
  77. chown ${NGINX_USER}:www-data -R ${D}${NGINX_WWWDIR}
  78. install -d ${D}${sysconfdir}/init.d
  79. install -m 0755 ${WORKDIR}/nginx.init ${D}${sysconfdir}/init.d/nginx
  80. sed -i 's,/usr/sbin/,${sbindir}/,g' ${D}${sysconfdir}/init.d/nginx
  81. sed -i 's,/etc/,${sysconfdir}/,g' ${D}${sysconfdir}/init.d/nginx
  82. install -d ${D}${sysconfdir}/nginx
  83. install -m 0644 ${WORKDIR}/nginx.conf ${D}${sysconfdir}/nginx/nginx.conf
  84. sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/nginx/nginx.conf
  85. sed -i 's/^user.*/user ${NGINX_USER};/g' ${D}${sysconfdir}/nginx/nginx.conf
  86. install -d ${D}${sysconfdir}/nginx/sites-enabled
  87. install -d ${D}${sysconfdir}/default/volatiles
  88. install -m 0644 ${WORKDIR}/nginx-volatile.conf ${D}${sysconfdir}/default/volatiles/99_nginx
  89. sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/default/volatiles/99_nginx
  90. sed -i 's,@NGINX_USER@,${NGINX_USER},g' ${D}${sysconfdir}/default/volatiles/99_nginx
  91. if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)};then
  92. install -d ${D}${systemd_unitdir}/system
  93. install -m 0644 ${WORKDIR}/nginx.service ${D}${systemd_unitdir}/system/
  94. sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \
  95. -e 's,@LOCALSTATEDIR@,${localstatedir},g' \
  96. -e 's,@SBINDIR@,${sbindir},g' \
  97. ${D}${systemd_unitdir}/system/nginx.service
  98. fi
  99. }
  100. pkg_postinst_${PN} () {
  101. if [ -z "$D" ]; then
  102. if type systemd-tmpfiles >/dev/null; then
  103. systemd-tmpfiles --create
  104. elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then
  105. ${sysconfdir}/init.d/populate-volatile.sh update
  106. fi
  107. fi
  108. }
  109. FILES_${PN} += " \
  110. ${localstatedir}/ \
  111. ${systemd_unitdir}/system/nginx.service \
  112. "
  113. CONFFILES_${PN} = " \
  114. ${sysconfdir}/nginx/nginx.conf \
  115. ${sysconfdir}/nginx/fastcgi.conf \
  116. ${sysconfdir}/nginx/fastcgi_params \
  117. ${sysconfdir}/nginx/koi-utf \
  118. ${sysconfdir}/nginx/koi-win \
  119. ${sysconfdir}/nginx/mime.types \
  120. ${sysconfdir}/nginx/scgi_params \
  121. ${sysconfdir}/nginx/uwsgi_params \
  122. ${sysconfdir}/nginx/win-utf \
  123. "
  124. INITSCRIPT_NAME = "nginx"
  125. INITSCRIPT_PARAMS = "defaults 92 20"
  126. USERADD_PACKAGES = "${PN}"
  127. USERADD_PARAM_${PN} = " \
  128. --system --no-create-home \
  129. --home ${NGINX_WWWDIR} \
  130. --groups www-data \
  131. --user-group ${NGINX_USER}"