xref: /openbmc/openbmc/meta-openembedded/meta-networking/recipes-support/openvpn/openvpn_2.6.14.bb (revision eaae0b339f806200d8722cb09e5e3b83c15a5956)
1SUMMARY = "A full-featured SSL VPN solution via tun device."
2HOMEPAGE = "https://openvpn.net/"
3SECTION = "net"
4LICENSE = "GPL-2.0-only"
5LIC_FILES_CHKSUM = "file://COPYING;md5=89196bacc47ed37a5b242a535661a049"
6DEPENDS = "lzo lz4 openssl iproute2 libcap-ng ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'libpam', '', d)} ${@bb.utils.contains('PTEST_ENABLED', '1', 'cmocka', '', d)} "
7
8inherit autotools systemd update-rc.d pkgconfig ptest
9
10SRC_URI = "http://swupdate.openvpn.org/community/releases/${BP}.tar.gz \
11           file://0001-configure.ac-eliminate-build-path-from-openvpn-versi.patch \
12           file://openvpn \
13           file://run-ptest \
14          "
15
16UPSTREAM_CHECK_URI = "https://openvpn.net/community-downloads"
17
18SRC_URI[sha256sum] = "9eb6a6618352f9e7b771a9d38ae1631b5edfeed6d40233e243e602ddf2195e7a"
19
20CVE_STATUS[CVE-2020-27569] = "not-applicable-config: Applies only Aviatrix OpenVPN client, not openvpn"
21
22INITSCRIPT_PACKAGES = "${PN}"
23INITSCRIPT_NAME:${PN} = "openvpn"
24INITSCRIPT_PARAMS:${PN} = "start 10 2 3 4 5 . stop 70 0 1 6 ."
25
26CFLAGS += "-fno-inline"
27
28# I want openvpn to be able to read password from file (hrw)
29EXTRA_OECONF += "--enable-iproute2"
30EXTRA_OECONF += "${@bb.utils.contains('DISTRO_FEATURES', 'pam', '', '--disable-plugin-auth-pam', d)}"
31
32# Explicitly specify IPROUTE to bypass the configure-time check for /sbin/ip on the host.
33EXTRA_OECONF += "IPROUTE=${base_sbindir}/ip"
34
35EXTRA_OECONF += "SYSTEMD_UNIT_DIR=${systemd_system_unitdir} \
36                 TMPFILES_DIR=${nonarch_libdir}/tmpfiles.d \
37                "
38
39PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} \
40                   ${@bb.utils.filter('DISTRO_FEATURES', 'selinux', d)} \
41                  "
42
43PACKAGECONFIG[systemd] = "--enable-systemd,--disable-systemd,systemd"
44PACKAGECONFIG[selinux] = "--enable-selinux,--disable-selinux,libselinux"
45
46RDEPENDS:${PN}-ptest:append = " make bash"
47
48do_install:append() {
49    install -d ${D}/${sysconfdir}/init.d
50    install -m 755 ${UNPACKDIR}/openvpn ${D}/${sysconfdir}/init.d
51
52    install -d ${D}/${sysconfdir}/openvpn
53    install -d ${D}/${sysconfdir}/openvpn/server
54    install -d ${D}/${sysconfdir}/openvpn/client
55
56    install -d ${D}/${sysconfdir}/openvpn/sample
57    install -m 644 ${S}/sample/sample-config-files/loopback-server  ${D}${sysconfdir}/openvpn/sample/loopback-server.conf
58    install -m 644 ${S}/sample/sample-config-files/loopback-client  ${D}${sysconfdir}/openvpn/sample/loopback-client.conf
59    install -dm 755 ${D}${sysconfdir}/openvpn/sample/sample-config-files
60    install -dm 755 ${D}${sysconfdir}/openvpn/sample/sample-keys
61    install -dm 755 ${D}${sysconfdir}/openvpn/sample/sample-scripts
62    install -m 644 ${S}/sample/sample-config-files/* ${D}${sysconfdir}/openvpn/sample/sample-config-files
63    install -m 644 ${S}/sample/sample-keys/* ${D}${sysconfdir}/openvpn/sample/sample-keys
64    install -m 644 ${S}/sample/sample-scripts/* ${D}${sysconfdir}/openvpn/sample/sample-scripts
65
66    install -d -m 710 ${D}/${localstatedir}/lib/openvpn
67}
68
69do_compile_ptest () {
70    for x in `find ${B}/tests/unit_tests -name Makefile -exec grep -l buildtest-TESTS {} \;`; do
71        dir=`dirname ${x}`
72        case $dir in
73            *example*)
74                echo "Skipping directory: $dir"
75                ;;
76            *)
77                oe_runmake -C ${dir} buildtest-TESTS
78                ;;
79        esac
80    done
81}
82
83do_install_ptest() {
84    for x in $(find ${B}/tests/unit_tests -name Makefile -exec grep -l buildtest-TESTS {} \;); do
85        dir=$(dirname ${x})
86
87        if [[ "$dir" == *example* ]]; then
88            continue
89        fi
90
91        target_dir="${D}/${PTEST_PATH}/unit_tests/$(basename ${dir})"
92        mkdir -p ${target_dir}
93        cp -f ${dir}/Makefile ${target_dir}/
94        sed -i "s/^Makefile:/MM:/g" ${target_dir}/Makefile
95        sed -i 's/^#TESTS = $(am__EXEEXT_4)/TESTS = $(am__EXEEXT_4)/' ${target_dir}/Makefile
96
97        for testfile in $(find ${dir} -name "*testdriver"); do
98            cp -rf ${testfile} ${target_dir}/
99        done
100    done
101    sed -i 's|find ./|find ${PTEST_PATH}|g' ${D}${PTEST_PATH}/run-ptest
102    sed -i 's|${top_builddir}/src/openvpn|${sbindir}|g' ${S}/tests/t_lpback.sh
103    cp -f ${S}/tests/t_lpback.sh ${D}/${PTEST_PATH}
104    cp -f ${B}/tests/Makefile ${D}/${PTEST_PATH}
105    sed -i "s/^Makefile:/MM:/g" ${D}/${PTEST_PATH}/Makefile
106    sed -i "s/^test_scripts = t_client.sh t_lpback.sh t_cltsrv.sh/test_scripts = t_lpback.sh/g" ${D}/${PTEST_PATH}/Makefile
107
108}
109
110PACKAGES =+ " ${PN}-sample "
111
112RRECOMMENDS:${PN} = "kernel-module-tun"
113
114FILES:${PN}-dbg += "${libdir}/openvpn/plugins/.debug"
115FILES:${PN} += "${systemd_system_unitdir}/openvpn-server@.service \
116                ${systemd_system_unitdir}/openvpn-client@.service \
117                ${nonarch_libdir}/tmpfiles.d \
118               "
119FILES:${PN}-sample = "${sysconfdir}/openvpn/sample/ \
120                     "
121