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