Skip to content

Commit 0b1b987

Browse files
publicarrayhgy59root
authored
Framework: Add DSM 7 Support (SynoCommunity#4395)
* prepare for dsm7 * Add 7.0 toolchain for testing * Add x64-7.0 to CI * start on dsm7 install/service script * fix DSM_APP_NAME in dsm7 * remove tools that require root permissions: (synouser, synogroup, synoshare) * remove tool that fail to modify permissions (synoacltool) * remove tool that fail to apply configuration (servicetool) servicetool, synouser, synogroup and synoshare have alternative ways to do the same thing using resource configuration * fix username, keep DSM6 name convention sc-packagename * Issue user facing warning on unsupported functions * change package icon size - change icon size from 72x72 to 64x64 for DSM 7 * cleanup * Store log files, pid and other files in permanent storage fixes missing log entries on reinstall * Migrate some JSON processing to jq TODO add moreutils package, use sponge to prevent overriding file with 0 content - 1<> $@ + | sponge $@ * fix adding GROUPs DSM7 * join-pkg-groupnames Creates group but is different from the groups the user can create, they are invisible in the UI an are only useful to access another packages permissions (ffmpeg comes to mind) For DSM7 I recommend setting permissions for individual packages (System Internal User) or use the shared folder resource worker to add permissions. We can ask the user from the wizard the folder name "join-groupname": "http" is for system groups, mainly for the web service ("root" don't work but "system" does) * DSM6->DSM7 move target/var to var/ * Added dsm7 preview toolchain for syno-armada38x-7.0 * Add DSM7.0 toolchains * Add v1000 to generic x64-7.0 * Add evansport DSM 7.0 Toolkit * fix builds for dsm versions < 7 * DSM7 Log install script to /var/log/packages/{package}.log Remove some more statements that modify files in places where we don't have permissions or is just unnecessary in DSM7 * add back firewall install/removal * Acquire Shared folder resource/permissions set using SERVICE_WIZARD_SHARE only disadvantage is that this does not support sub-folders currently * Only migrate /var directory to permanent storage when destination is empty * set SYNOPKG_PKGVAR for DSM versions less than 7.0 * Add uninstaller that can optionally remove all package files Includes files in the new permanent storage (/var) and home folder * uninstaller: also remove /etc * fix noarch in dsm7 simple hack to set os_min_ver to 7.0-4000 build using: make noarch-7.0 or make noarch-6.1 build must be clean between builds SynoCommunity#4215 (comment) * fix missing files on clean install Copy config files on first install from "target/var" to "/var" * Error on dropped support for busybox start-stop-daemon aka SERVICE_EXE * fix don't override old configurations * Add ability for packages to join a SYSTEM_GROUP and cleanup Available options are: http and system * fix DSM6 regression and code review * fix regression: backwards compatibility with DSM6 * for DSM6 don't set "groupname". fixes permission issues with sc-{groups} Add SPK_GROUP variable to override "groupname", default is sc-{packagename} * fix noarch for dsm7 - use noarch-dsm7 to distinguish from noach-all - use different work dirs for all and dsm7 - incorporate SynoCommunity#4392 - followup of 05c2383 to avoid to clean between builds * update github action to build noarch-7.0 packages * fix github build action for noarch-7.0 * another fix for noarch build action * fix DSM7 running with su command: SynoCommunity#4395 (comment) * Toolchains: Update DSM7 hashes and fix typos * Add supported DSM 7 archs to CI/GH Actions * fix os_min_vers for DSM 7 noarch - update min. build from 4000 to 40000 * regenerated digests of dsm7 toolchains * Add sha256 digest to evansport toolkit * fix TC_BUILD for DSM7.0 * Apply new version comparison function Fixes wrong comparisons e.g. where 3.10 was erroneously less than 3.2 Thanks @th0ma7 * framework, resource: simplify jq command * framework: code review * Add linking support for /usr/local/lib and /usr/local/etc depreciate SPK_LINKS and add new make variable: SPK_USR_LOCAL_LINKS * fix SPK_USR_LOCAL_LINKS * Fix comments being output to command line * Framework: DSM7 Make sure folder exists before migrating files * Framework: Fix unable to override uninstall wizard * Update mk/spksrc.service.start-stop-status Co-authored-by: hgy59 <[email protected]> * Fraework: avoid creating wizard folder when it's not needed Co-authored-by: hgy59 <[email protected]> Co-authored-by: hgy59 <[email protected]> Co-authored-by: root <[email protected]>
1 parent 9e973af commit 0b1b987

File tree

66 files changed

+859
-47
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+859
-47
lines changed

.github/actions/build.sh

+8-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ echo "===> ARCH packages: ${arch_packages}"
9191
echo "===> NOARCH packages: ${noarch_packages}"
9292
echo "::endgroup::"
9393

94-
if [ "${GH_ARCH}" = "noarch" ]; then
94+
if [ "${GH_ARCH%%-*}" = "noarch" ]; then
9595
build_packages=${noarch_packages}
9696
else
9797
build_packages=${arch_packages}
@@ -112,11 +112,16 @@ for package in ${build_packages}
112112
do
113113
echo "::group:: ---- build ${package}"
114114

115-
if [ "${GH_ARCH}" != "noarch" ]; then
115+
if [ "${GH_ARCH%%-*}" != "noarch" ]; then
116116
# use TCVERSION and ARCH to get real exit codes.
117117
make TCVERSION=${GH_ARCH##*-} ARCH=${GH_ARCH%%-*} -C ./spk/${package}
118118
else
119-
make -C ./spk/${package}
119+
if [ "${GH_ARCH}" = "noarch" ]; then
120+
TCVERSION=
121+
else
122+
TCVERSION=${GH_ARCH##*-}
123+
fi
124+
make TCVERSION=${TCVERSION} ARCH= -C ./spk/${package}
120125
fi
121126
result=$?
122127

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
matrix:
2626
# x64=x86_64, evansport=i686, aarch64=armv8, armv7, hi3535=armv7l, 88f6281=armv5, qoriq=ppc
2727
# https://github.com/SynoCommunity/spksrc/wiki/Synology-and-SynoCommunity-Package-Architectures
28-
arch: [noarch, x64-6.1, evansport-6.1, aarch64-6.1, armv7-6.1, hi3535-6.1, 88f6281-6.1, qoriq-6.1]
28+
arch: [noarch, noarch-7.0, x64-6.1, x64-7.0, evansport-6.1, evansport-7.0, aarch64-6.1, aarch64-7.0, armv7-6.1, armv7-7.0, hi3535-6.1, 88f6281-6.1, qoriq-6.1]
2929

3030
steps:
3131
- name: Cache toolchains

mk/spksrc.common.mk

+5
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ COMPILE_MAKE_OPTIONS += -j$(NCPUS)
7070
endif
7171
endif
7272

73+
# Terminal colors
74+
RED=`tput setaf 1`
75+
GREEN=`tput setaf 2`
76+
NC=`tput sgr0`
77+
7378
# Version Comparison
7479
version_le = $(shell if printf '%s\n' "$(1)" "$(2)" | sort -VC ; then echo 1; fi)
7580
version_ge = $(shell if printf '%s\n' "$(1)" "$(2)" | sort -VCr ; then echo 1; fi)

mk/spksrc.directories.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# * all goes in $(WORK_DIR) : work-arch, or simple work, in the current directory
1+
# * all goes in $(WORK_DIR) : work-arch (for noarch: work-all or work-dsm7), in the current directory
22
# * it will be installed in $(INSTALL_PREFIX) on the target system (/usr/local/transmission)
33
# * each source package is unpacked in $(WORK_DIR)
44
# * the install target installs files in $(WORK_DIR)/install/, known as $(INSTALL_DIR)

mk/spksrc.service.installer

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ INST_LOG="/tmp/${SYNOPKG_PKGNAME}_install.log"
88
INST_ETC="/var/packages/${SYNOPKG_PKGNAME}/etc"
99
INST_VARIABLES="${INST_ETC}/installer-variables"
1010
INST_VAR="${SYNOPKG_PKGDEST}/var"
11+
SYNOPKG_PKGVAR="${SYNOPKG_PKGDEST}/var" # backwards compatibility
1112

1213
# Optional FWPORTS file
1314
FWPORTS_FILE="/var/packages/${SYNOPKG_PKGNAME}/conf/${SYNOPKG_PKGNAME}.sc"

mk/spksrc.service.installer.dsm7

+229
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
#!/bin/sh
2+
3+
# DSM 5 -> 7 upgrade path:
4+
# Not supported
5+
# DSM 6 -> 7 upgrade path:
6+
# files are migrated from ${SYNOPKG_PKGDEST}/var to ${SYNOPKG_PKGVAR}
7+
# Not supported (yet)
8+
9+
INST_ETC="/var/packages/${SYNOPKG_PKGNAME}/etc"
10+
INST_VARIABLES="${INST_ETC}/installer-variables"
11+
INST_VAR="${SYNOPKG_PKGVAR}"
12+
13+
# Optional FWPORTS file
14+
FWPORTS_FILE="/var/packages/${SYNOPKG_PKGNAME}/conf/${SYNOPKG_PKGNAME}.sc"
15+
16+
TMP_DIR="${SYNOPKG_TEMP_UPGRADE_FOLDER}/var"
17+
18+
# Source package specific variable and functions
19+
SVC_SETUP=`dirname $0`"/service-setup"
20+
if [ -r "${SVC_SETUP}" ]; then
21+
. "${SVC_SETUP}"
22+
fi
23+
24+
# Reload wizard variables stored by postinst
25+
if [ -r "${INST_VARIABLES}" ]; then
26+
. "${INST_VARIABLES}"
27+
fi
28+
29+
# Expect user to be set from package specific variables
30+
if [ -n "${USER}" -a -z "${USER_DESC}" ]; then
31+
USER_DESC="User running $SYNOPKG_PKGNAME"
32+
fi
33+
34+
# Default description if group name provided by UI
35+
if [ -n "${GROUP}" -a -z "${GROUP_DESC}" ]; then
36+
GROUP_DESC="SynoCommunity Package Group"
37+
fi
38+
39+
# Extract share volume and share name from download location if provided
40+
if [ -n "${SHARE_PATH}" ]; then
41+
SHARE_VOLUME=$(echo "${SHARE_PATH}" | awk -F/ '{print "/"$2}')
42+
SHARE_NAME=$(echo "${SHARE_PATH}" | awk -F/ '{print $3}')
43+
fi
44+
45+
# Tools shortcuts
46+
MV="/bin/mv -f"
47+
RM="/bin/rm -rf"
48+
CP="/bin/cp -rfp"
49+
MKDIR="/bin/mkdir -p"
50+
LN="/bin/ln -nsf"
51+
TEE="/usr/bin/tee -a"
52+
53+
### Functions library
54+
55+
log ()
56+
{
57+
echo "$1" 1>&2 # /var/log/packages/{package}.log
58+
}
59+
60+
61+
log_step ()
62+
{
63+
log $(date)
64+
log "===> Step $1. USER=$USER GROUP=$GROUP SHARE_PATH=${SHARE_PATH}"
65+
}
66+
67+
save_wizard_variables ()
68+
{
69+
if [ -e "${INST_VARIABLES}" ]; then
70+
$RM "${INST_VARIABLES}"
71+
fi
72+
if [ -n "${GROUP}" ]; then
73+
echo "GROUP=${GROUP}" >> ${INST_VARIABLES}
74+
fi
75+
if [ -n "${SHARE_PATH}" ]; then
76+
echo "SHARE_PATH=${SHARE_PATH}" >> ${INST_VARIABLES}
77+
fi
78+
}
79+
80+
set_unix_permissions ()
81+
{
82+
log "${SYNOPKG_PKGNAME} has not been updated to DSM7 yet. set_unix_permissions() is no longer supported."
83+
}
84+
85+
syno_remove_user ()
86+
{
87+
log "${SYNOPKG_PKGNAME} has not been updated to DSM7 yet. syno_remove_user() is no longer supported."
88+
}
89+
90+
syno_group_create ()
91+
{
92+
log "${SYNOPKG_PKGNAME} has not been updated to DSM7 yet. syno_group_create() is no longer supported."
93+
}
94+
95+
syno_group_remove ()
96+
{
97+
log "${SYNOPKG_PKGNAME} has not been updated to DSM7 yet. syno_group_remove() is no longer supported."
98+
}
99+
100+
syno_user_add_to_group ()
101+
{
102+
log "${SYNOPKG_PKGNAME} has not been updated to DSM7 yet. syno_user_add_to_group() is no longer supported."
103+
}
104+
105+
set_syno_permissions ()
106+
{
107+
log "${SYNOPKG_PKGNAME} has not been updated to DSM7 yet. set_syno_permissions() is no longer supported."
108+
}
109+
110+
syno_user_add_to_legacy_group () {
111+
log "${SYNOPKG_PKGNAME} has not been updated to DSM7 yet. syno_user_add_to_legacy_group() is no longer supported."
112+
}
113+
114+
115+
### Generic package behaviors
116+
117+
preinst ()
118+
{
119+
log_step "preinst"
120+
call_func "service_preinst"
121+
122+
# Check volume exists
123+
if [ -n "${SHARE_PATH}" ]; then
124+
if [ ! -d "${SHARE_VOLUME}" ]; then
125+
echo "Volume ${SHARE_VOLUME} does not exist." | $TEE 1>&2
126+
exit 1
127+
fi
128+
fi
129+
130+
exit 0
131+
}
132+
133+
postinst ()
134+
{
135+
log_step "postinst"
136+
save_wizard_variables
137+
138+
# copy target/var data to permanent storage
139+
# and don't override old configurations
140+
if [ -d ${SYNOPKG_PKGDEST}/var ] && [ "$(find ${SYNOPKG_PKGVAR} -mindepth 1 -not -name '*.log' -print)" = "" ]; then
141+
$CP -RT ${SYNOPKG_PKGDEST}/var/. ${SYNOPKG_PKGVAR}
142+
fi
143+
144+
if [ "${SYNOPKG_PKG_STATUS}" == "INSTALL" ]; then
145+
# Add firewall config
146+
if [ -r "${FWPORTS_FILE}" ]; then
147+
echo "Installing service configuration ${FWPORTS_FILE}" >> ${INST_LOG}
148+
servicetool --install-configure-file --package "${FWPORTS_FILE}" >> ${INST_LOG} 2>&1
149+
fi
150+
fi
151+
152+
call_func "service_postinst"
153+
call_func "service_create_links"
154+
155+
exit 0
156+
}
157+
158+
preuninst ()
159+
{
160+
log_step "preuninst"
161+
162+
if [ "${SYNOPKG_PKG_STATUS}" == "UNINSTALL" ]; then
163+
# Remove firewall config
164+
if [ -r "${FWPORTS_FILE}" ]; then
165+
echo "Removing service configuration ${SYNOPKG_PKGNAME}.sc" >> ${INST_LOG}
166+
servicetool --remove-configure-file --package "${SYNOPKG_PKGNAME}.sc" >> ${INST_LOG} 2>&1
167+
fi
168+
fi
169+
170+
call_func "service_preuninst"
171+
exit 0
172+
}
173+
174+
postuninst ()
175+
{
176+
log_step "postuninst"
177+
178+
call_func "service_postuninst"
179+
call_func "service_remove_links"
180+
181+
if [ "$wizard_delete_data" = "true" ]; then
182+
183+
if [ "$(ls -A ${SYNOPKG_PKGHOME})" != "" ]; then
184+
rm -rf ${SYNOPKG_PKGHOME}/
185+
fi
186+
187+
if [ "$(ls -A ${SYNOPKG_PKGVAR})" != "" ]; then
188+
rm -rf ${SYNOPKG_PKGVAR}/
189+
fi
190+
191+
if [ "$(ls -A /var/packages/${SYNOPKG_PKGNAME}/etc)" != "" ]; then
192+
rm -rf /var/packages/${SYNOPKG_PKGNAME}/etc/
193+
fi
194+
195+
if ["$(ls -A ${SYNOPKG_PKGTMP})" != "" ]; then
196+
rm -rf ${SYNOPKG_PKGTMP}/
197+
fi
198+
fi
199+
exit 0
200+
}
201+
202+
preupgrade ()
203+
{
204+
log_step "preupgrade"
205+
206+
# dsm6 -> dsm7
207+
# Migrate data to permanent storage
208+
if [ ! "$(ls -A ${SYNOPKG_PKGVAR})" ]; then
209+
# only migrate when destination is empty
210+
$CP -RT ${SYNOPKG_PKGDEST}/var/. ${SYNOPKG_PKGVAR}
211+
fi
212+
213+
call_func "service_preupgrade"
214+
215+
call_func "service_save"
216+
217+
exit 0
218+
}
219+
220+
postupgrade ()
221+
{
222+
log_step "postupgrade"
223+
224+
call_func "service_restore"
225+
226+
call_func "service_postupgrade"
227+
228+
exit 0
229+
}

0 commit comments

Comments
 (0)