summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 50e4597e3b55db94ffed4e0a13ed433629ae224f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Maintainer: skydrome <skydrome at@at proton mail dot com>
# Contributors: Thynix

_fred=#tag=build01484
_wot=#branch=next
_keyutils=#tag=v5026
_upnp=#tag=10007

_pkgver=0.7.5
_plugins=('WebOfTrust' 'UPnP' 'KeyUtils')

# comment out to run unit tests
BUILDENV+=('!check')

pkgname=freenet
pkgver=0.7.5.1484
pkgrel=1
pkgdesc="An encrypted network without censorship"
url="https://freenetproject.org"
license=('GPL2')
arch=('i686' 'x86_64')
install='freenet.install'
depends=('java-runtime>=8' 'gmp' 'java-service-wrapper')
makedepends=('java-environment>=8' 'apache-ant' 'git' 'zip' 'gradle')
backup=('opt/freenet/wrapper.config'
        'opt/freenet/conf/freenet.ini')

source=("git+https://github.com/freenet/fred.git${_fred}"
        "git+https://github.com/freenet/plugin-UPnP.git${_upnp}"
        "git+https://github.com/freenet/plugin-KeyUtils.git${_keyutils}"
        "git+https://github.com/freenet/plugin-WebOfTrust.git${_wot}"
        "IpToCountry.dat::http://software77.net/geo-ip/?DL=4"
        "https://github.com/freenet/seedrefs/files/1609768/seednodes.zip"
        '0001-strip-non-compile-deps.patch'
        'run.sh' 'freenet.service' 'freenet.ini' 'wrapper.config')

sha256sums=('SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            '0d91d2462f36d35235cc86cbdee11890cadec91a0a01b89d96010924f6c2be99'
            'd3d2f43e2bdaa93bfaa60fa2c82f6b42fb50539db2ad48e03664b537a4aa8071'
            'a6581d33448c2989ef9f7e888e7e47a8784b0159e76bf8f6bc97eec1d7d55769'
            '434f67e2e86edb555b7dfb572a52d7ff719373989e1f1830f779bfccc678539f'
            'c0ce093a098d91dee6be294f8a2fc929aabad95612f994933194d0da5c4cdd25'
            '609705bafc02048f366711f470bebaf2d4e8c5fa1285b1611719826aef755107')

pkgver() {
    cd "fred"
    printf "%s.%s" "${_pkgver}" \
                   "$(git describe --abbrev=0 |sed 's/build0//;s/-/./g')"
}

prepare() {
    cd "fred"

    # Gradle 5.3 and Java 11 support
    git pull origin pull/658/head
    git apply -v "$srcdir/0001-strip-non-compile-deps.patch"

    sed -i "$srcdir/plugin-WebOfTrust/build.xml" \
        -e 's:value="7":value="1.8":'
    sed -i "$srcdir/plugin-UPnP/build.xml" \
        -e 's:value="1.5":value="1.8":'
    sed -i "$srcdir/plugin-KeyUtils/build.xml" \
        -e 's:value="1.6":value="1.8":'
    sed -i "gradle.properties" \
        -e "s:targetJavaVersion.*:targetJavaVersion=$(javac -version 2>&1 |awk '{print $2}'):"
}

build() {
    cd "fred"

    export GRADLE_USER_HOME="$srcdir/.gradle"

    msg "Building Freenet..."
    gradle --no-build-cache copyRuntimeLibs

    build_plugins
}

build_plugins() {
    export ANT_HOME=/usr/share/ant
    export ANT_OPTS="-Dfile.encoding=UTF-8"

    for plugin in ${_plugins[@]}; do
        msg "Building Plugin ${plugin}..."
        cd "$srcdir/plugin-${plugin}"
        ant dist \
            -Dfreenet-cvs-snapshot.location=../fred/build/output/freenet.jar \
            -Dfreenet-ext.location=../fred/build/output/freenet-ext-29.jar \
            -Dtest.skip=true
    done
}

check() {
    cd "fred"

    # these tests use alot of memory and can cause OOM's
    #rm -f test/freenet/client/async/{*Storage,ClientRequestSelector}Test.java
    gradle test
}

package() {
    cd "fred"

    # freenet
    install -dm755 "$pkgdir"/usr/bin
    install -dm700 "$pkgdir"/run/freenet
    install -dm700 "$pkgdir"/opt/freenet/tmp
    install -dm750 "$pkgdir"/opt/freenet/{downloads,lib,conf,noderef,persistent-temp,plugins/data,user/{data,certs}}

    install -m640  "$srcdir"/{wrapper.config,run.sh,IpToCountry.dat} "$pkgdir"/opt/freenet
    install -m640  "$srcdir"/freenet.ini                             "$pkgdir"/opt/freenet/conf
    install -m640  "$srcdir"/seednodes/seednodes.fref                "$pkgdir"/opt/freenet/noderef
    install -m640  "$srcdir"/fred/build/output/*.jar                 "$pkgdir"/opt/freenet/lib

    # delete bundled wrapper
    zip -qd "$pkgdir"/opt/freenet/lib/freenet-ext-29.jar "org/tanukisoftware/*"

    # plugins
    for plugin in ${_plugins[@]}; do
    install -m640 "$srcdir"/plugin-${plugin}/dist/${plugin}.jar "$pkgdir"/opt/freenet/plugins
    done
    echo "pluginmanager.loadplugin=$(echo ${_plugins[@]}|sed 's| |;|g')" \
        >>"$pkgdir"/opt/freenet/conf/freenet.ini

    # launcher
    chmod +x "$pkgdir"/opt/freenet/run.sh
    ln -s /opt/freenet/run.sh "$pkgdir"/usr/bin/freenet

    # systemd
    install -dm755 "$pkgdir"/usr/lib/tmpfiles.d
    install -Dm644 "$srcdir"/freenet.service    "$pkgdir"/usr/lib/systemd/system/freenet.service
    echo 'd /run/freenet 0700 freenet freenet' >"$pkgdir"/usr/lib/tmpfiles.d/freenet.conf

    # license
    install -dm755        "$pkgdir"/usr/share/licenses/freenet
    install -m644 LICENSE "$pkgdir"/usr/share/licenses/freenet/LICENSE
}