⚠️ I have since created lstellway/synology-dev-env to provide a local development environment for Synology via containers. There is an included example for buildingvim
.
Let me start by saying: this is not a happy story..
This process was a bit painful, and I definitely stumbled through it.
Would love to hear if I missed anything or if anybody has ideas.
Synology provides a package developer guide. I primariliy referenced the prepare environment and your first package sections.
I decided to run my environment using Docker compose.
Note the synology-dev-data
volume, used to keep working data persistent in the container.
# File: `docker-compose.yml`
version: '3'
services:
synology-dev-env:
command: tail -f /dev/null
container_name: synology-dev-env
image: ubuntu:18.04
privileged: true
restart: unless-stopped
volumes:
- synology-dev-data:/data
- .bash_aliases:/root/.bash_aliases
volumes:
synology-dev-data:
name: synology-dev-data
Note the linked .bash_aliases
file - I used this to create a couple convenience methods (especially for installing dependencies when starting a fresh container):
# File `.bash_aliases`
init() {
apt-get update && apt-get upgrade
apt install -y \
git \
vim \
cifs-utils \
nodejs \
python \
python-pip \
python3 \
python3-pip
}
I also defined a Makefile
to make it easy to manage the development environment:
# File `Makefile`
.PHONY: dev dev-down dev-terminal
# Run Docker compose commands against the development file
dev-compose = docker-compose --file docker-compose.yml $(1)
# Initialize the development environment
dev:
@echo "Starting development environment..."
$(call dev-compose, up -d)
# Stop the development environment
dev-down:
@echo "Stopping development environment..."
$(call dev-compose, down)
# Initialize a terminal session in the development admin container
dev-terminal:
@echo "Initializing terminal session..."
$(call dev-compose, exec -it synology-dev-env /bin/bash)
I followed the directions outlined in the prepare environment doc and cloned the SynologyOpenSource/pkgscripts-ng repository to /data/toolkit/pkgscripts-ng
.
Definitely encourage people to become familiar with the EnvDeploy script, but I created another convenience Makefile
here:
.PHONY: package package-pack platform list-platforms platform-info
include .env
deploy-dsm = ./EnvDeploy -v ${DSM_VERSION} $(1)
package-dsm = ./PkgCreate.py -v ${DSM_VERSION} $(1)
package:
$(call package-dsm, -p ${PLATFORM} -c ${PACKAGE})
package-pack:
$(call package-dsm, -i -p ${PLATFORM} -c ${PACKAGE})
platform:
$(call deploy-dsm, -p ${PLATFORM})
list-platforms:
$(call deploy-dsm, --list)
platform-info:
$(call deploy-dsm, --info ${PLATFORM})
Note the included .env
file - I defined a couple variables there. You would need to tailor them to your DSM version and Synology processor platform.
DSM_VERSION='7.0'
PLATFORM='apollolake'
I ran the command to setup the development environment for my DSM/Synology environment/platform:
make platform
This took about 5
minutes for me..
Then I cloned the VIM source to /data/toolkit/source/vim
as instructed in the docs.
I then checked out the latest tag (v9.0.1276
at the time of writing) and followed the example of the ExamplePackage to create the Synology Package files.
You can see all the files I added in this commit.
At this point, my environment was all setup and ready to compile VIM.
From the /data/toolkit/pkgscripts-ng
directory, I ran the following convenience method to compile the package:
PACKAGE=vim make package
This took somewhere between 5-10
minutes for me.
This seemed to complete the compilation process, but reported having errored (it took a lot of debugging to even get to a complete compile!).
This is where I could no longer follow the package build instructions, and began looking for workarounds.
I ended up finding that the .spk
file lived in my build environment's image
directory:
/data/toolkit/build_env/{platform_build_dir}/image/packages/{package_name}_debug.spk
I copied this file from the container to my local machine and tried uploading it to the DSM package center UI.
That didn't work
Next, I found that the software was indeed successfully compiled to my build environments tmp
directory:
This is where it gets really dirty, but hey.. it worked.
Essentially, I copied everything from the usr/local
directory to my Synology nas.
/data/toolkit/build_env/{platform_build_dir}/tmp/_package_tgz/usr/local/bin/*
/data/toolkit/build_env/{platform_build_dir}/tmp/_package_tgz/usr/local/share/vim
On the NAS side, I copied these to:
/usr/local/bin/
/usr/local/share/
Also had to updates some file permissions so they're accessible for other users:
find /usr/local/share/vim -type d -exec chmod 755 {} \;
find /usr/local/share/vim -type f -exec chmod 644 {} \;
I also updated my path to prefer /usr/local/bin
over /usr/bin
by updating the PATH
variable in /etc/profile
(you can also do this in a local profile file).
Upon trying to run the program, I kept seeing errors of missing shared libraries (.so
files).
Each missing library it complained about, I was able to find and copy over from the container's build environment:
/data/toolkit/build_env/{platform_build_dir}/usr/lib/*
All in all, I believe there were 4
or 5
missing libraries..
But after this, I had an updated version of VIM running on my NAS!