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://0001-libltdl-remove-reference-to-nonexisting-directory.patch \
23           file://squid.nm \
24           "
25
26SRC_URI[sha256sum] = "f3df3abb2603a513266f24a5d4699a9f0d76b9f554d1848b67f9c51cd3b3cb50"
27
28LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
29                    file://errors/COPYRIGHT;md5=6fbb6a2adc362e206da7b4f42846cdec \
30                    "
31DEPENDS = "libtool"
32
33inherit autotools pkgconfig useradd ptest perlnative systemd
34
35LDFLAGS:append:mipsarch = " -latomic"
36LDFLAGS:append:powerpc = " -latomic"
37LDFLAGS:append:riscv64 = " -latomic"
38LDFLAGS:append:riscv32 = " -latomic"
39
40USERADD_PACKAGES = "${PN}"
41USERADD_PARAM:${PN} = "--system --no-create-home --home-dir /var/run/squid --shell /bin/false --user-group squid"
42
43PACKAGECONFIG ??= "auth url-rewrite-helpers \
44    ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)} \
45    ${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} \
46"
47
48PACKAGECONFIG[libnetfilter-conntrack] = "--with-netfilter-conntrack=${includedir}, --without-netfilter-conntrack, libnetfilter-conntrack"
49PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6,"
50PACKAGECONFIG[werror] = "--enable-strict-error-checking,--disable-strict-error-checking,"
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                 --disable-esi \
71"
72
73# Workaround a build failure when using a native compiler that need -std=c++17
74# with a cross-compiler that doesn't.
75# Upstream issue closed as invalid : https://bugs.squid-cache.org/show_bug.cgi?id=5376
76BUILD_CXXFLAGS += "-std=c++17"
77
78export BUILDCXXFLAGS="${BUILD_CXXFLAGS}"
79
80TESTDIR = "test-suite"
81
82do_configure:prepend() {
83    export SYSROOT=$PKG_CONFIG_SYSROOT_DIR
84}
85
86do_configure:append() {
87   sed -i -e 's|${WORKDIR}||g' ${B}/include/autoconf.h
88}
89
90do_compile_ptest() {
91    oe_runmake -C ${TESTDIR} buildtest-TESTS
92}
93
94do_install_ptest() {
95    cp -rf ${B}/${TESTDIR} ${D}${PTEST_PATH}
96    cp -rf ${S}/${TESTDIR} ${D}${PTEST_PATH}
97
98    # Install default config
99    install -d ${D}${PTEST_PATH}/src
100    install -m 0644 ${B}/src/squid.conf.default ${D}${PTEST_PATH}/src
101
102    # autoconf.h is needed during squid-conf-tests
103    install -d ${D}${PTEST_PATH}/include
104    install -m 0644 ${B}/include/autoconf.h ${D}${PTEST_PATH}/include
105
106    # do NOT need to rebuild Makefile itself
107    sed -i 's/^Makefile:.*$/Makefile:/' ${D}${PTEST_PATH}/${TESTDIR}/Makefile
108
109    # Ensure the path for command true is correct
110    sed -i 's:^TRUE = .*$:TRUE = /bin/true:' ${D}${PTEST_PATH}/${TESTDIR}/Makefile
111}
112
113do_install:append() {
114    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
115        # Install service unit file
116        install -d ${D}/${systemd_unitdir}/system
117        install ${S}/tools/systemd/squid.service ${D}/${systemd_unitdir}/system
118        sed -i 's:/var/run/:/run/:g' ${D}/${systemd_unitdir}/system/squid.service
119
120        # Configure tmpfiles.d
121        install -d ${D}${sysconfdir}/tmpfiles.d
122        echo "d ${localstatedir}/run/${BPN} 0755 squid squid -" >> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
123        echo "d ${localstatedir}/log/${BPN} 0750 squid squid -" >> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
124    fi
125
126    install -d ${D}${sysconfdir}/default/volatiles
127    install -m 0644 ${UNPACKDIR}/volatiles.03_squid ${D}${sysconfdir}/default/volatiles/03_squid
128
129    rmdir "${D}${localstatedir}/run/${BPN}"
130    rmdir --ignore-fail-on-non-empty "${D}${localstatedir}/run"
131
132    rmdir "${D}${localstatedir}/log/${BPN}"
133    rmdir --ignore-fail-on-non-empty "${D}${localstatedir}/log"
134
135    # Install NetworkManager dispatcher reload hooks
136    install -d ${D}${libdir}/NetworkManager/dispatcher.d
137    install -m 0755 ${UNPACKDIR}/squid.nm ${D}${libdir}/NetworkManager/dispatcher.d/20-squid
138}
139
140SYSTEMD_AUTO_ENABLE = "disable"
141SYSTEMD_SERVICE:${PN} = "squid.service"
142
143FILES:${PN} += "${libdir} ${datadir}/errors ${datadir}/icons"
144FILES:${PN}-dbg += "/usr/src/debug"
145FILES:${PN}-doc += "${datadir}/*.txt"
146FILES:${PN}-conf += "${sysconfdir}/squid"
147FILES:${PN}-networkmanager = "${libdir}/NetworkManager/dispatcher.d"
148
149RDEPENDS:${PN} += "perl ${PN}-conf"
150RDEPENDS:${PN}-ptest += "perl make bash"
151