Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2016
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 11.40 KB | None | 0 0
  1. # Maintainer: skydrome <skydrome at@at i2pmail do.t org>
  2. # Contributors:
  3.  
  4. _wot=#tag=build0018
  5. _bcprov=jdk15on-154
  6.  
  7. pkgname=freenet
  8. pkgver=0.7.5.testing.build.1471.pre3.33.g54c4b71
  9. pkgrel=1
  10. _pkgver=0.7.5
  11. pkgdesc="An encrypted network without censorship"
  12. url="https://downloads.freenetproject.org"
  13. license=('GPL2')
  14. arch=('any')
  15. install='freenet.install'
  16.  
  17. depends=('java-runtime>=7' 'gmp' 'java-service-wrapper')
  18. makedepends=('java-environment>=7' 'apache-ant' 'git')
  19. checkdepends=('junit')
  20. # comment out to run unit tests
  21. BUILDENV+=('!check')
  22.  
  23. backup=('opt/freenet/wrapper.config'
  24.         'opt/freenet/conf/freenet.ini')
  25.  
  26. _plugins=('WebOfTrust' 'UPnP' 'KeyUtils')
  27.  
  28. # these are packages we need to download to prevent ant from
  29. # downloading them itself we are also going to build as much
  30. # as we can from source, including this array
  31. _deps=("http://downloads.sourceforge.net/project/sevenzip/LZMA%20SDK/4.65/lzma465.tar.bz2"
  32.        "league-lzmajio-0.95-0-gd38bf5c.tar.gz::https://codeload.github.com/league/lzmajio/legacy.tar.gz/0.95"
  33.        "http://downloads.sourceforge.net/project/bitcollider/jBitcollider%20%28Java%29/0.8/jBitcollider-0.8.zip"
  34.        "https://www.spaceroots.org/software/mantissa/mantissa-7.2-src.zip"
  35.        "${url}/contrib/db4o-7.4-java.zip")
  36.  
  37. # ant will extract these
  38. noextract=('lzma465.tar.bz2'
  39.            'league-lzmajio-0.95-0-gd38bf5c.tar.gz'
  40.            'jBitcollider-0.8.zip'
  41.            'mantissa-7.2-src.zip'
  42.            'db4o-7.4-java.zip'
  43.            'commons-compress.jar'
  44.            "bcprov-${_bcprov}.jar")
  45.  
  46. # here we have only java-commons-compress coming prebuilt by
  47. # the freenetproject, the rest we build ourselves
  48. source=("git+https://github.com/freenet/fred.git"
  49.         "git+https://github.com/freenet/contrib.git"
  50.         "git+https://github.com/freenet/plugin-UPnP.git"
  51.         "git+https://github.com/freenet/plugin-KeyUtils.git"
  52.         "git+https://github.com/freenet/plugin-WebOfTrust.git${_wot}"
  53.         "${url}/alpha/opennet/seednodes.fref"
  54.         "IpToCountry.dat::http://software77.net/geo-ip/?DL=4"
  55.         "${url}/contrib/jar/latest/commons-compress.jar"
  56.         "https://www.bouncycastle.org/download/bcprov-${_bcprov}.jar"
  57.         "http://downloads.sourceforge.net/project/ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3-bin.tar.bz2"
  58.         "https://raw.githubusercontent.com/i2p/i2p.i2p/master/core/c/jcpuid/src/jcpuid.c"
  59.         "https://raw.githubusercontent.com/i2p/i2p.i2p/master/core/c/jcpuid/include/jcpuid.h"
  60.         'fred.properties' 'contrib.properties' 'run.sh'
  61.         'freenet.service' 'freenet.ini' 'wrapper.config'
  62.         "${_deps[@]}")
  63.  
  64. sha256sums=('SKIP'
  65.             'SKIP'
  66.             'SKIP'
  67.             'SKIP'
  68.             'SKIP'
  69.             'SKIP'
  70.             'SKIP'
  71.             '16924be3c8f1322b659f3ff08060a43f45f2e8de6f95af28d86fe9876e79008d'
  72.             'd0ae14598f9c528d2ab7bb8ed00e785a5440f692712cd362d69328aba25efb57'
  73.             '96effcca2581c1ab42a4828c770b48d54852edf9e71cefc9ed2ffd6590571ad1'
  74.             'f1ecddb5395892e0b2e6282bc3a1437d06afa52758057850ecccfa0a79c45c5d'
  75.             '9ec758801a9864ae10caf851ee60ed22c3ef44428e77689c203d9b890921a6d2'
  76.             '236adfd42be0a7a74f2dec1356e517442b2ddcbb5d44cb0dab3671b6fddfca79'
  77.             '865c1f259d9c544861cc12b4ea64ad35ec6388c1392b3e5247eaed0f316e42b7'
  78.             '9912dcfc8f30143b68e6f9c51505ae921100eb6b24690a8680582bb23559d95a'
  79.             '434f67e2e86edb555b7dfb572a52d7ff719373989e1f1830f779bfccc678539f'
  80.             '6ae810e40ac177b4238e95b31329d099f6a7cc95154ec1b1844538580e692f64'
  81.             'f7bceda39b36d1d79e70c8ba8e0e68d4cfe060b16e67d8341078af5fda13b405'
  82.             'c935fd04dd8e0e8c688a3078f3675d699679a90be81c12686837e0880aa0fa1e'
  83.             '265f7ed2dd4fecb058884d3f8974674b06e0be46131c3b2bc6a310373937d2ef'
  84.             'b36482ee9e919c669bb1797ff7e50f57edf505af67664e280fe1dff361861044'
  85.             'e438135d69139ed4fa44400f416ea73935d16afe50dfe490b7bba0602ee89476'
  86.             '73f307a8cbd114fdc0af8daa067994a2cdc364c4053e6734d16b8dd1d5a0469f')
  87.  
  88. pkgver() {
  89.     cd "$srcdir/fred"
  90.     echo "${_pkgver}.$(git describe |sed 's/build0//;s/-/./g')"
  91. }
  92.  
  93. if [[ "$CARCH" = 'i686' ]]; then
  94.      _arch=x86
  95.     __arch=i386
  96. else
  97.      _arch=x86_64
  98.     __arch=amd64
  99. fi
  100.  
  101. prepare() {
  102.     cd "$srcdir/fred"
  103.  
  104.     rm -rf contrib
  105.     ln -sf ../contrib contrib
  106.     mkdir -p contrib/freenet-ext/{dist,lib}
  107.  
  108.     # no need to fetch this file every time freenet starts as its only updated
  109.     # monthly, if it even changes at all
  110.     sed -i src/freenet/node/updater/NodeUpdateManager.java \
  111.         -e "s:updateIPToCountry =.*:updateIPToCountry = false;:"
  112.  
  113.     # had a hard time building these sources, we'll use the prebuilt jars
  114.     cp "$srcdir/commons-compress.jar" contrib/freenet-ext/dist
  115.  
  116.     # this is done to satisfy ant
  117.     ln -sf /usr/share/java/wrapper.jar contrib/freenet-ext/dist/
  118.     ln -sf /usr/share/java/{hamcrest-core,junit}.jar lib/
  119.     ln -sf "$srcdir"/ant-contrib/{ant-contrib-1.0b3,ant-contrib}.jar
  120.     cp "$srcdir"/bcprov-${_bcprov}.jar lib/bcprov.jar
  121.     cp "$srcdir"/{lzma465.tar.bz2,league-lzmajio-0.95-0-gd38bf5c.tar.gz,jBitcollider-0.8.zip,mantissa-7.2-src.zip,db4o-7.4-java.zip} contrib/freenet-ext/lib
  122.  
  123.     # we're going to compile our own C libraries
  124.     cd "$srcdir/contrib"
  125.     rm -rf NativeBigInteger/lib/net/i2p/util/*
  126.     rm -rf NativeThread/lib/freenet/support/io/*.so
  127.     rm -rf onion-fec/bin/lib/{freebsd,linux,win32}-*
  128.  
  129.     # these are from the I2P project
  130.     cd "$srcdir/contrib/jcpuid"
  131.     rm -rf lib/freenet/support/CPUInformation/* include/jcpuid.h
  132.     ln -sf "$srcdir"/jcpuid.h include/
  133.     ln -sf "$srcdir"/jcpuid.c src/
  134. }
  135.  
  136. build() {
  137.     source /etc/profile.d/apache-ant.sh
  138.     source /etc/profile.d/jre.sh
  139.     export JAVA_HOME="${JAVA_HOME:-/usr/lib/jvm/default}"
  140.  
  141.     build_jbigi
  142.     build_nativethread
  143.     build_jcpuid
  144.     build_fec
  145.  
  146.     msg "Building Contrib Modules..."
  147.     cd "$srcdir/fred/contrib/freenet-ext"
  148.     ant -propertyfile "$srcdir/contrib.properties" \
  149.         -Djava.class.dirs.user="$srcdir/ant-contrib"
  150.  
  151.     # ant doesnt seem to put all the required folders into the
  152.     # freenet-ext.jar correctly, make sure to do it here
  153.     cd dist
  154.     for dep in bitcollider-core commons-compress db4o lzmajio mantissa wrapper
  155.     do
  156.         jar xf "${dep}.jar"
  157.     done
  158.     jar uf freenet-ext.jar com net org SevenZip
  159.  
  160.     msg "Building Freenet..."
  161.     cd "$srcdir/fred"
  162.     ant package-only -propertyfile "$srcdir/fred.properties" \
  163.         -f build-clean.xml -Ddoc.skip=true
  164.  
  165.     build_plugins
  166. }
  167.  
  168. build_jbigi() {
  169.     msg "Building NativeBigInt..."
  170.     cd "$srcdir/contrib/NativeBigInteger"
  171.  
  172.     _objdir='lib/net/i2p/util'
  173.     CFLAGS+=" -fPIC -Wall"
  174.     INCLUDES="-I./jbigi/include -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux"
  175.     LDFLAGS="-shared -Wl,-O1,--sort-common,-z,relro,-soname,libjbigi.so -lgmp"
  176.     rm -f *.o *.so
  177.  
  178.     set -x
  179.     gcc -c $CFLAGS $INCLUDES jbigi/src/jbigi.c
  180.     gcc $LDFLAGS jbigi.o -o "$_objdir"/libjbigi-linux-none.so
  181.     set +x
  182. }
  183.  
  184. build_nativethread() {
  185.     msg "Building NativeThread..."
  186.     cd "$srcdir/contrib/NativeThread"
  187.  
  188.     _objdir='lib/freenet/support/io'
  189.     INCLUDES="-I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux"
  190.     LDFLAGS="-shared -Wl,-O1,--sort-common,-z,relro,-soname,llibnative.so -lc"
  191.     rm -f *.o *.so NativeThread.h
  192.  
  193.     set -x
  194.     javah -o NativeThread.h -classpath ../../fred/src freenet.support.io.NativeThread
  195.     gcc -c $CFLAGS $INCLUDES NativeThread.c
  196.     gcc $LDFLAGS NativeThread.o -o "$_objdir"/libNativeThread-${__arch}.so
  197.     set +x
  198. }
  199.  
  200. build_jcpuid() {
  201.     msg "Building NativeCPUID..."
  202.     cd "$srcdir/contrib/jcpuid"
  203.  
  204.     _objdir='lib/freenet/support/CPUInformation'
  205.     INCLUDES="-I./include -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux"
  206.     LDFLAGS="-shared -Wl,-O1,--sort-common,-z,relro,-soname,libjcpuid-x86-linux.so"
  207.     rm -f *.o *.so
  208.  
  209.     set -x
  210.     gcc -c $CFLAGS $INCLUDES src/jcpuid.c
  211.     gcc $LDFLAGS jcpuid.o -o "$_objdir"/libjcpuid-${_arch}-linux.so
  212.     set +x
  213. }
  214.  
  215. build_fec() {
  216.     msg "Building onion-fec..."
  217.     cd "$srcdir/contrib/onion-fec/src/csrc"
  218.  
  219.     _objdir='../../bin/lib/linux-${_arch}'
  220.     LDFLAGS="-shared -Wl,-O1,--sort-common,-z,relro"
  221.     INCLUDES="-I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux"
  222.     _CLASSPATH="-classpath ../ com.onionnetworks.fec"
  223.  
  224.     mkdir -p "$_objdir"
  225.     rm -f *.o *.so *.S com_*.h
  226.  
  227.     set -x
  228.     javah -o com_onionnetworks_fec_Native8Code.h  ${_CLASSPATH}.Native8Code
  229.     javah -o com_onionnetworks_fec_Native16Code.h ${_CLASSPATH}.Native16Code
  230.     gcc -S $CFLAGS fec.c -DGF_BITS=8  -o fec8.S
  231.     gcc -S $CFLAGS fec.c -DGF_BITS=16 -o fec16.S
  232.     gcc -c $CFLAGS $INCLUDES fec-jinterf.c -DGF_BITS=8  -o fec8-jinterf.o
  233.     gcc -c $CFLAGS $INCLUDES fec-jinterf.c -DGF_BITS=16 -o fec16-jinterf.o
  234.     gcc -c $CFLAGS fec8.S  -DGF_BITS=8  -o fec8.o
  235.     gcc -c $CFLAGS fec16.S -DGF_BITS=16 -o fec16.o
  236.     gcc $LDFLAGS fec8.o fec8-jinterf.o   -o "$_objdir"/libfec8.so
  237.     gcc $LDFLAGS fec16.o fec16-jinterf.o -o "$_objdir"/libfec16.so
  238.     set +x
  239. }
  240.  
  241. build_plugins() {
  242.     for plugin in ${_plugins[@]}; do
  243.         msg "Building Plugin ${plugin}..."
  244.         cd "$srcdir/plugin-${plugin}"
  245.         ant dist \
  246.             -Dfreenet-cvs-snapshot.location=../fred/dist/freenet.jar \
  247.             -Dfreenet-ext.location=../contrib/freenet-ext/dist/freenet-ext.jar \
  248.             -Djunit.location=/usr/share/java/junit.jar \
  249.             -Dtest.skip=true
  250.     done
  251. }
  252.  
  253. check() {
  254.     cd "$srcdir/fred"
  255.  
  256.     # these tests use alot of memory and can cause OOM's
  257.     rm -f test/freenet/client/async/{*Storage,ClientRequestSelector}Test.java
  258.  
  259.     ant unit -propertyfile "$srcdir/fred.properties" \
  260.         -f build-clean.xml
  261. }
  262.  
  263. package() {
  264.     cd "$srcdir/fred"
  265.  
  266.     # freenet
  267.     install -dm755 "$pkgdir"/usr/bin
  268.     install -dm700 "$pkgdir"/run/freenet
  269.     install -dm750 "$pkgdir"/opt/freenet/{downloads,lib,conf,noderef,persistent-temp,tmp,plugins/data,user/{data,certs}}
  270.  
  271.     install -m640 "$srcdir"/{wrapper.config,run.sh,IpToCountry.dat} \
  272.                                                                 "$pkgdir"/opt/freenet
  273.     install -m640 "$srcdir"/freenet.ini                         "$pkgdir"/opt/freenet/conf
  274.     install -m640 contrib/freenet-ext/dist/freenet-ext.jar \
  275.                   dist/freenet.jar                         \
  276.                   lib/bcprov.jar                                "$pkgdir"/opt/freenet/lib
  277.  
  278.     # FIXME Workaround for https://bugs.freenetproject.org/view.php?id=6684
  279.     install -m640 "$srcdir"/seednodes.fref                      "$pkgdir"/opt/freenet
  280.     ln -s /opt/freenet/seednodes.fref "$pkgdir"/opt/freenet/noderef/
  281.  
  282.     # plugins
  283.     for plugin in ${_plugins[@]}; do
  284.     install -m640 "$srcdir"/plugin-${plugin}/dist/${plugin}.jar "$pkgdir"/opt/freenet/plugins
  285.     done
  286.  
  287.     echo "pluginmanager.loadplugin=$(echo ${_plugins[@]}|sed 's| |;|g')" \
  288.         >>"$pkgdir"/opt/freenet/conf/freenet.ini
  289.  
  290.     # launcher
  291.     chmod +x "$pkgdir"/opt/freenet/run.sh
  292.     ln -s /opt/freenet/run.sh "$pkgdir"/usr/bin/freenet
  293.  
  294.     # systemd
  295.     install -dm755 "$pkgdir"/usr/lib/tmpfiles.d
  296.     install -Dm644 "$srcdir"/freenet.service    "$pkgdir"/usr/lib/systemd/system/freenet.service
  297.     echo 'd /run/freenet 0700 freenet freenet' >"$pkgdir"/usr/lib/tmpfiles.d/freenet.conf
  298.  
  299.     # license
  300.     install -dm755        "$pkgdir"/usr/share/licenses/freenet
  301.     install -m644 LICENSE "$pkgdir"/usr/share/licenses/freenet/LICENSE
  302. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement