Skip to content

Commit

Permalink
Synology support (spk) (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
phnzb authored Dec 15, 2023
1 parent d337cf0 commit 3f8fd6d
Show file tree
Hide file tree
Showing 28 changed files with 536 additions and 6 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ jobs:
build-osx:
uses: ./.github/workflows/osx.yml

build-synology:
uses: ./.github/workflows/synology.yml

generate-signatures:
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
runs-on: ubuntu-latest
needs: [build-windows, build-linux, build-osx]
needs: [build-windows, build-linux, build-osx, build-synology]
steps:

- name: Download build artifacts
Expand All @@ -30,9 +33,10 @@ jobs:
- name: Generate signatures
run: |
mkdir -p builds
mv nzbget-windows-installers/* builds
mv nzbget-linux-installers/* builds
mv nzbget-osx-installers/* builds
mv nzbget-windows-installers/* builds || true
mv nzbget-linux-installers/* builds || true
mv nzbget-osx-installers/* builds || true
mv nzbget-synology-packages/* builds || true
cd builds
VERSION=$(ls | grep bin-windows-setup | cut -d - -f 2)
if [ "$GITHUB_REF_NAME" != "main" ]; then VERSION="$VERSION-testing"; fi
Expand All @@ -44,7 +48,7 @@ jobs:
echo "nzbget_signatures({" | tee $SIGS_FILE
echo | tee -a $SIGS_FILE
for FILE in *.exe *.run *.zip; do
for FILE in *.exe *.run *.zip *.spk; do
[ -f $FILE ] || continue
MD5=$(openssl dgst -md5 $FILE | cut -d ' ' -f 2)
Expand Down Expand Up @@ -80,6 +84,7 @@ jobs:
nzbget-windows-installers
nzbget-linux-installers
nzbget-osx-installers
nzbget-synology-packages
make-testing-release:
runs-on: ubuntu-latest
Expand All @@ -95,7 +100,7 @@ jobs:
- name: Create latest artifacts
run: |
cp $(find nzbget-installers/ -name *linux.run) nzbget-installers/nzbget-latest-testing-bin-linux.run
cp $(find nzbget-installers/ -name *windows-setup.exe) nzbget-installers/nzbget-latest-testing-bin-windows-setup
cp $(find nzbget-installers/ -name *windows-setup.exe) nzbget-installers/nzbget-latest-testing-bin-windows-setup.exe
- name: Delete tag and release
uses: dev-drprasad/delete-tag-and-release@v0.2.1
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/synology.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: synology build

on:
workflow_call:
workflow_dispatch:

jobs:
build:
runs-on: [self-hosted, linux]

steps:

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Build
run: |
sudo -E bash synology/build-nzbget.sh
- name: Rename build artifacts
if: github.ref_name != 'main'
run: |
cd /toolkit/result_spk/nzbget/
VERSION=$(date '+%Y%m%d')
NEW_VERSION="$VERSION-testing"
for FILE in *.spk; do
[ -f $FILE ] || continue
NEW_FILE=${FILE/$VERSION/$NEW_VERSION}
sudo mv $FILE $NEW_FILE
done
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: nzbget-synology-packages
path: /toolkit/result_spk/nzbget/*.spk
retention-days: 5

- name: Cleanup
run: |
sudo rm /toolkit/result_spk/nzbget/*.spk
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ ipch/
# NZBGet specific
nzbget
build
!synology/package/SynoBuildConf/build
*.temp
*.pyc
pytest.ini
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[![windows build](https://github.com/nzbgetcom/nzbget/actions/workflows/windows.yml/badge.svg?branch=main)](https://github.com/nzbgetcom/nzbget/actions/workflows/windows.yml)
[![osx build](https://github.com/nzbgetcom/nzbget/actions/workflows/osx.yml/badge.svg)](https://github.com/nzbgetcom/nzbget/actions/workflows/osx.yml)
[![docker build](https://github.com/nzbgetcom/nzbget/actions/workflows/docker.yml/badge.svg)](https://github.com/nzbgetcom/nzbget/actions/workflows/docker.yml)
[![synology build](https://github.com/nzbgetcom/nzbget/actions/workflows/synology.yml/badge.svg)](https://github.com/nzbgetcom/nzbget/actions/workflows/synology.yml)


![Contributions welcome](https://img.shields.io/badge/contributions-welcome-blue.svg)
Expand Down Expand Up @@ -35,6 +36,8 @@ Please download binaries from our [releases](https://github.com/nzbgetcom/nzbget

We also provide a docker image for popular architectures. [Docker readme](docker/README.md)

Synology DSM 7.x packages also available. [Synology readme](synology/README.md)

## Supported platforms for installers

`Windows`: Windows 7 and later, 32 or 64 Bit.
Expand Down
53 changes: 53 additions & 0 deletions synology/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Synology nzbget packages

## Package versions

We provide native packages for most Synology platforms (DSM 7.x). To select a correct package for yours platform please find Synology model in [Synology NAS list](https://kb.synology.com/en-us/DSM/tutorial/What_kind_of_CPU_does_my_NAS_have) and select package based on `Package Arch` field:

| Package Arch | NZBGet package name
|:---------------|:-
| alpine | nzbget-armv7-*.spk
| alpine4k | nzbget-armv7-*.spk
| apollolake | nzbget-x86_64-*.spk
| armada370 | nzbget-armada370-*.spk
| armada375 | nzbget-armada375-*.spk
| armada37xx | nzbget-armv8-*.spk
| armadaxp | nzbget-armadaxp-*.spk
| avoton | nzbget-x86_64-*.spk
| braswell | nzbget-x86_64-*.spk
| broadwell | nzbget-x86_64-*.spk
| broadwellnk | nzbget-x86_64-*.spk
| broadwellntb | nzbget-x86_64-*.spk
| broadwellntbap | nzbget-x86_64-*.spk
| bromolow | nzbget-x86_64-*.spk
| cedarview | nzbget-x86_64-*.spk
| coffeelake | nzbget-x86_64-*.spk
| comcerto2k | `not supported`
| denverton | nzbget-x86_64-*.spk
| evansport | nzbget-i686-*.spk
| geminilake | nzbget-x86_64-*.spk
| grantley | nzbget-x86_64-*.spk
| kvmx64 | nzbget-x86_64-*.spk
| monaco | nzbget-monaco-*.spk
| purley | nzbget-x86_64-*.spk
| rtd1296 | nzbget-armv8-*.spk
| rtd1619 | nzbget-armv8-*.spk
| skylaked | nzbget-x86_64-*.spk
| v1000 | nzbget-x86_64-*.spk

## Installing / upgrading / uninstalling / reinstalling

To install NZBGet package from Synology Package Center press Manual Install and select downloaded package -> Next -> Agree -> Select shared folder and download directory -> Credentials for web interface -> Done.
After installation NZBGet web interface will be availabe from http://[Synology NAS IP or Hostname]:6789 with provided during installation username/password (nzbget/nzbget by default). Also this link available from package center "Open" button on installed NZBGet package icon.

To upgrade nzbget package - do the same thing with new package. NZBGet settings will be keeped.

Uninstall - from Package center select NZBGet package and hit uninstall in action combo box. You can keep existing config files or cleanup all package data. If you keep existing config files, all settings selected in next package installations will be ignored, old config files settings will be preferred.

## Shared folders permissions and nzbget

When installed, the package adds all the necessary permissions for the selected Shared folder to work correcty. If you want to change the download path to another shared folder, you must manually add permissions for the nzbget user. For example - you changed MainDir to /volume2/some_shared_folder/some_download_directory. You must add r/w permission to `nzbget` user via Control Panel -> Shared Folder -> Select `some_shared_folder` -> Edit -> Permissions tab -> select from combobox `System internal user` -> nzbget -> Read/Write -> Save.

## Extensions

You can put custom extension in `ScriptDir` directory. During installation this directory appears in `selected_shared_folder\selected_download_directory\scripts` and populates with default scripts (Email and Logger). Synology DSM 7.x bundled with python 3.8, so you must make sure that the script you are installing supports it. Our forks of VideoSort/FailureLink/FakeDetector are tested and working.
44 changes: 44 additions & 0 deletions synology/build-info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# About

"build-nzbget.sh" is a bash script which is used to build nzbget Synology packages.

# Prerequisites

## Synology toolkit and environments

Basic setup (assuming have Debian/Ubuntu host):

1. Install Synology toolkit (reference - https://help.synology.com/developer-guide/getting_started/prepare_environment.html)
```
sudo apt-get install git cifs-utils python3 python3-pip
sudo mkdir -p /toolkit
sudo chmod 777 /toolkit
cd /toolkit
git clone https://github.com/SynologyOpenSource/pkgscripts-ng
cd /toolkit/pkgscripts-ng/
git checkout DSM7.0
```

2. Install needed environments (please note - user must have sudo access)

- according to https://help.synology.com/developer-guide/appendix/platarchs.html - one per architecture, and specific separately
- we exclude `comcerto2k` - toolchain for this platform does not support C++14

```
cd /toolkit/pkgscripts-ng/
for PLATFORM in alpine armada370 armada375 armada37xx armada38x armadaxp avoton evansport monaco; do sudo ./EnvDeploy -v 7.0 -p $PLATFORM; done
```


## Building NZBGet

From cloned repository run
```
sudo bash synology/build-nzbget.sh [platform]
```
Please note - user must have sudo access. Synology toolkit requires root access to build packages.


## Output files

- /toolkit/result_spk/nzbget/*.spk - one file per platform
52 changes: 52 additions & 0 deletions synology/build-nzbget.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

# synology toolkit path
TOOLKIT=/toolkit

# parameter can be build platform
BUILD_PLATFORM=$1
if [ ! -z "$BUILD_PLATFORM" ]; then BUILD_PARAM="-p $BUILD_PLATFORM"; fi

# clean up
rm -rf $TOOLKIT/source/nzbget
rm -rf $TOOLKIT/result_spk/
if [ ! -z "$BUILD_PLATFORM" ]; then
PLATFORMS=$BUILD_PLATFORM
else
PLATFORMS="alpine armada370 armada375 armada37xx armada38x armadaxp avoton evansport monaco"
fi
for PLATFORM in $PLATFORMS; do
echo "Cleanup $PLATFORM environment ..."
rm -rf $TOOLKIT/build_env/ds.$PLATFORM-7.0/image/packages
done

# copy source and prepare package structure
mkdir -p $TOOLKIT/source/nzbget
cp -r . $TOOLKIT/source/nzbget
cp -r synology/package/* $TOOLKIT/source/nzbget/
cd $TOOLKIT/source/nzbget/
chmod +x scripts/*
chmod -x scripts/vars
chmod +x SynoBuildConf/*
chmod -x SynoBuildConf/depends
chmod +x INFO.sh

# correct build version in INFO.sh
VERSION=$(grep "AC_INIT(nzbget, " configure.ac | cut -d "," -f 2 | xargs)
SPK_VERSION=$(date '+%Y%m%d')-${VERSION//./}
# if running from CI/CD, add testing to builds from non-main branch
if [ -n "$GITHUB_REF_NAME" ]; then
if [ "$GITHUB_REF_NAME" != "main" ]; then
NEW_VERSION="$VERSION-testing-$(date '+%Y%m%d')"
sed -e "s|AC_INIT(nzbget.*|AC_INIT(nzbget, $NEW_VERSION, https://github.com/nzbgetcom/nzbget/issues)|g" -i configure.ac
fi
fi
sed -e "s|version=.*$|version=\"$SPK_VERSION\"|g" -i INFO.sh

# build
$TOOLKIT/pkgscripts-ng/PkgCreate.py -v 7.0 -c -P 2 nzbget $BUILD_PARAM

# remove debug packages and set user perms on packages
mv $TOOLKIT/result_spk/nzbget-$SPK_VERSION/ $TOOLKIT/result_spk/nzbget/
rm $TOOLKIT/result_spk/nzbget/*_debug.spk
chmod 666 $TOOLKIT/result_spk/nzbget/*
22 changes: 22 additions & 0 deletions synology/package/INFO.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

source /pkgscripts/include/pkg_util.sh

package="nzbget"
version="yyyymmdd-version"
displayname="NZBGet"
os_min_ver="7.0-41201"
maintainer="nzbget@nzbget.com"
adminport="6789"
description="NZBGet is a binary downloader, which downloads files from Usenet based on information given in nzb-files."

# populate arch
BUILD_ARCH="$(pkg_get_platform)"
arch=$BUILD_ARCH
if [ "$BUILD_ARCH" == "alpine" ]; then arch="alpine alpine4k"; fi
if [ "$BUILD_ARCH" == "armada37xx" ]; then arch="armada37xx rtd1296 rtd1619 aarch64"; fi
if [ "$BUILD_ARCH" == "avoton" ]; then arch="apollolake avoton braswell broadwell broadwellnk broadwellntb broadwellntbap bromolow cedarview coffeelake denverton geminilake grantley kvmx64 purley skylaked v1000 x86_64"; fi
if [ "$BUILD_ARCH" == "evansport" ]; then arch="evansport x86 i686"; fi

[ "$(caller)" != "0 NULL" ] && return 0
pkg_dump_info
Binary file added synology/package/PACKAGE_ICON.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added synology/package/PACKAGE_ICON_256.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions synology/package/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# NZBGet Synology Package.

NZBGet by nzbget.com

NZBGet is a binary downloader, which downloads files from Usenet based on information given in nzb-files.

NZBGet is written in C++ and is known for its performance and efficiency.
25 changes: 25 additions & 0 deletions synology/package/SynoBuildConf/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

case ${MakeClean} in
[Yy][Ee][Ss])
make clean
;;
esac

case ${CleanOnly} in
[Yy][Ee][Ss])
return
;;
esac

autoreconf --install

# prefix with /usr/local, all files will be installed into /usr/local
env CC="${CC}" CXX="${CXX}" LD="${LD}" AR=${AR} STRIP=${STRIP} RANLIB=${RANLIB} NM=${NM} \
CFLAGS="${CFLAGS} -Os" CXXFLAGS="${CXXFLAGS}" LDFLAGS="${LDFLAGS}" \
./configure ${ConfigOpt} \
--prefix=/usr/local --program-prefix="" --program-suffix=""

make ${MAKE_FLAGS}

make install
4 changes: 4 additions & 0 deletions synology/package/SynoBuildConf/depends
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[BuildDependent]

[default]
all="7.0"
55 changes: 55 additions & 0 deletions synology/package/SynoBuildConf/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

### Use PKG_DIR as working directory.
PKG_DIR=/tmp/_spk
rm -rf $PKG_DIR
mkdir -p $PKG_DIR

### get spk packing functions
source /pkgscripts/include/pkg_util.sh

create_package_tgz() {

local package_tgz_dir=/tmp/_package_tgz
local binary_dir=$package_tgz_dir/usr/local/bin

### clear destination directory
rm -rf $package_tgz_dir && mkdir -p $package_tgz_dir

### install needed file into PKG_DIR
mkdir -p $binary_dir
cp -av nzbget $binary_dir
cp -av nzbget.sc $binary_dir
curl --insecure -o $binary_dir/cacert.pem https://curl.se/ca/cacert.pem

make install DESTDIR="$package_tgz_dir"

### create package.tgz $1: source_dir $2: dest_dir
pkg_make_package $package_tgz_dir $PKG_DIR
}

create_spk(){

cp -av scripts $PKG_DIR/scripts
rm $PKG_DIR/scripts/*.py
cp -av PACKAGE_ICON*.PNG $PKG_DIR
cp -av WIZARD_UIFILES $PKG_DIR
cp -av conf $PKG_DIR

./INFO.sh > INFO
cp INFO $PKG_DIR/INFO

### Create the final spk.
# pkg_make_spk <source path> <dest path> <spk file name>
# Please put the result spk into /image/packages
# spk name functions: pkg_get_spk_name pkg_get_spk_unified_name pkg_get_spk_family_name
mkdir -p /image/packages
pkg_make_spk $PKG_DIR "/image/packages" $(pkg_get_spk_family_name)
}

main() {
create_package_tgz
create_spk
}

main "$@"
Loading

0 comments on commit 3f8fd6d

Please sign in to comment.