1SUMMARY = "A fully-featured http proxy and web-cache daemon for Linux"
2DESCRIPTION = "A fully-featured http proxy and web-cache daemon for Linux. \
3Squid offers a rich access control, authorization and logging environment to \
4develop web proxy and content serving applications. \
5Squid offers a rich set of traffic optimization options, most of which are \
6enabled by default for simpler installation and high performance. \
7"
8HOMEPAGE = "http://www.squid-cache.org"
9SECTION = "web"
10LICENSE = "GPL-2.0-or-later"
11
12MAJ_VER = "${@oe.utils.trim_version("${PV}", 1)}"
13MIN_VER = "${@oe.utils.trim_version("${PV}", 2)}"
14
15SRC_URI = "http://www.squid-cache.org/Versions/v${MAJ_VER}/${BPN}-${PV}.tar.xz \
16           file://Set-up-for-cross-compilation.patch \
17           file://Skip-AC_RUN_IFELSE-tests.patch \
18           file://squid-use-serial-tests-config-needed-by-ptest.patch \
19           file://run-ptest \
20           file://volatiles.03_squid \
21           file://0002-squid-make-squid-conf-tests-run-on-target-device.patch \
22           file://squid.nm \
23           "
24
25SRC_URI[sha256sum] = "1ad72d46e1cb556e9561214f0fb181adb87c7c47927ef69bc8acd68a03f61882"
26
27LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
28                    file://errors/COPYRIGHT;md5=d324bc1f9447d1d1588d75b22a678dc4 \
29                    "
30DEPENDS = "libtool"
31
32inherit autotools pkgconfig useradd ptest perlnative systemd
33
34LDFLAGS:append:mipsarch = " -latomic"
35LDFLAGS:append:powerpc = " -latomic"
36LDFLAGS:append:riscv64 = " -latomic"
37LDFLAGS:append:riscv32 = " -latomic"
38
39USERADD_PACKAGES = "${PN}"
40USERADD_PARAM:${PN} = "--system --no-create-home --home-dir /var/run/squid --shell /bin/false --user-group squid"
41
42PACKAGECONFIG ??= "auth url-rewrite-helpers \
43    ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)} \
44    ${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} \
45"
46
47PACKAGECONFIG[libnetfilter-conntrack] = "--with-netfilter-conntrack=${includedir}, --without-netfilter-conntrack, libnetfilter-conntrack"
48PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6,"
49PACKAGECONFIG[werror] = "--enable-strict-error-checking,--disable-strict-error-checking,"
50PACKAGECONFIG[esi] = "--enable-esi,--disable-esi,expat libxml2"
51PACKAGECONFIG[ssl] = "--with-openssl=yes,--with-openssl=no,openssl"
52PACKAGECONFIG[auth] = "--enable-auth-basic='${BASIC_AUTH}',--disable-auth --disable-auth-basic,krb5 openldap db cyrus-sasl"
53PACKAGECONFIG[url-rewrite-helpers] = "--enable-url-rewrite-helpers,--disable-url-rewrite-helpers,"
54PACKAGECONFIG[systemd] = "--with-systemd,--without-systemd,systemd"
55
56PACKAGES =+ " \
57    ${PN}-conf \
58    ${PN}-networkmanager \
59"
60
61BASIC_AUTH = "DB SASL LDAP"
62
63DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'libpam', '', d)}"
64BASIC_AUTH += "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'PAM', '', d)}"
65
66EXTRA_OECONF += "--with-default-user=squid \
67                 --sysconfdir=${sysconfdir}/${BPN} \
68                 --with-logdir=${localstatedir}/log/${BPN} \
69                 'PERL=${USRBINPATH}/env perl'"
70
71# Workaround a build failure when using a native compiler that need -std=c++17
72# with a cross-compiler that doesn't.
73# Upstream issue closed as invalid : https://bugs.squid-cache.org/show_bug.cgi?id=5376
74BUILD_CXXFLAGS += "-std=c++17"
75
76export BUILDCXXFLAGS="${BUILD_CXXFLAGS}"
77
78TESTDIR = "test-suite"
79
80do_configure:prepend() {
81    export SYSROOT=$PKG_CONFIG_SYSROOT_DIR
82}
83
84do_configure:append() {
85   sed -i -e 's|${WORKDIR}||g' ${B}/include/autoconf.h
86}
87
88do_compile_ptest() {
89    oe_runmake -C ${TESTDIR} buildtest-TESTS
90}
91
92do_install_ptest() {
93    cp -rf ${B}/${TESTDIR} ${D}${PTEST_PATH}
94    cp -rf ${S}/${TESTDIR} ${D}${PTEST_PATH}
95
96    # Install default config
97    install -d ${D}${PTEST_PATH}/src
98    install -m 0644 ${B}/src/squid.conf.default ${D}${PTEST_PATH}/src
99
100    # autoconf.h is needed during squid-conf-tests
101    install -d ${D}${PTEST_PATH}/include
102    install -m 0644 ${B}/include/autoconf.h ${D}${PTEST_PATH}/include
103
104    # do NOT need to rebuild Makefile itself
105    sed -i 's/^Makefile:.*$/Makefile:/' ${D}${PTEST_PATH}/${TESTDIR}/Makefile
106
107    # Ensure the path for command true is correct
108    sed -i 's:^TRUE = .*$:TRUE = /bin/true:' ${D}${PTEST_PATH}/${TESTDIR}/Makefile
109}
110
111do_install:append() {
112    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
113        # Install service unit file
114        install -d ${D}/${systemd_unitdir}/system
115        install ${S}/tools/systemd/squid.service ${D}/${systemd_unitdir}/system
116        sed -i 's:/var/run/:/run/:g' ${D}/${systemd_unitdir}/system/squid.service
117
118        # Configure tmpfiles.d
119        install -d ${D}${sysconfdir}/tmpfiles.d
120        echo "d ${localstatedir}/run/${BPN} 0755 squid squid -" >> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
121        echo "d ${localstatedir}/log/${BPN} 0750 squid squid -" >> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
122    fi
123
124    install -d ${D}${sysconfdir}/default/volatiles
125    install -m 0644 ${UNPACKDIR}/volatiles.03_squid ${D}${sysconfdir}/default/volatiles/03_squid
126
127    rmdir "${D}${localstatedir}/run/${BPN}"
128    rmdir --ignore-fail-on-non-empty "${D}${localstatedir}/run"
129
130    rmdir "${D}${localstatedir}/log/${BPN}"
131    rmdir --ignore-fail-on-non-empty "${D}${localstatedir}/log"
132
133    # Install NetworkManager dispatcher reload hooks
134    install -d ${D}${libdir}/NetworkManager/dispatcher.d
135    install -m 0755 ${UNPACKDIR}/squid.nm ${D}${libdir}/NetworkManager/dispatcher.d/20-squid
136}
137
138SYSTEMD_AUTO_ENABLE = "disable"
139SYSTEMD_SERVICE:${PN} = "squid.service"
140
141FILES:${PN} += "${libdir} ${datadir}/errors ${datadir}/icons"
142FILES:${PN}-dbg += "/usr/src/debug"
143FILES:${PN}-doc += "${datadir}/*.txt"
144FILES:${PN}-conf += "${sysconfdir}/squid"
145FILES:${PN}-networkmanager = "${libdir}/NetworkManager/dispatcher.d"
146
147RDEPENDS:${PN} += "perl ${PN}-conf"
148RDEPENDS:${PN}-ptest += "perl make bash"
149