@synopackageland/cli 0.52.13 → 0.52.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/assets/folder-picker.js +96 -0
- package/dist/build-spk/folder-picker.d.ts +7 -0
- package/dist/build-spk/folder-picker.js +70 -0
- package/dist/deploy/native-install-values.js +11 -1
- package/dist/native-http-schema/source.json +1 -1
- package/dist/runtime/sdk-source.d.ts +1 -1
- package/dist/runtime/sdk-source.js +1 -1
- package/dist/standalone/compose.js +5 -0
- package/dist/standalone/inspect-spk.js +3 -2
- package/dist/standalone/lifecycle.js +3 -1
- package/dist/standalone/manifest.js +2 -0
- package/dist/standalone/shared-folder.d.ts +1 -0
- package/dist/standalone/shared-folder.js +39 -6
- package/dist/standalone/spk.js +6 -3
- package/docs/shared-folders.md +83 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.52.14
|
|
4
|
+
|
|
5
|
+
- Add an opt-in folder picker to native Compose installation selections with SDK 0.53.22.
|
|
6
|
+
- Emit the DSM folder chooser on DSM 7.2.2 and later; use standard share and relative-path fields on older DSM releases from the same SPK.
|
|
7
|
+
- Preserve paired upgrade selections; validate metadata in preinst and package access after DSM grants it, without failing installation for pending access.
|
|
8
|
+
- Reuse the existing startup permission Dialog and Retry for precise child-folder repair; pin CLI planning to SDK 0.53.22.
|
|
9
|
+
|
|
3
10
|
## 0.52.13
|
|
4
11
|
|
|
5
12
|
- Add `install.min_memory_mb` for dynamic physical RAM admission on install and upgrade, independent of NAS model
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/* Package Center's public ExamplePackages JSONP contract (Vue 2.7).
|
|
2
|
+
* This component owns selection only. DSM data-share owns the share grant. */
|
|
3
|
+
(function (options) {
|
|
4
|
+
var hook = SYNO.SDS.PkgManApp.Custom.useHook;
|
|
5
|
+
var component = {
|
|
6
|
+
props: Object.assign({}, hook.props),
|
|
7
|
+
setup: function (props) {
|
|
8
|
+
function request(url, options) {
|
|
9
|
+
var controller = new AbortController();
|
|
10
|
+
var timer = setTimeout(function () { controller.abort(); }, 10000);
|
|
11
|
+
return fetch(url, Object.assign({}, options, { signal: controller.signal }))
|
|
12
|
+
.finally(function () { clearTimeout(timer); });
|
|
13
|
+
}
|
|
14
|
+
var api = function (name, method, version, params) {
|
|
15
|
+
return request('/webman/login.cgi?enable_syno_token=yes', { credentials: 'same-origin' })
|
|
16
|
+
.then(function (r) { if (!r.ok) throw Error(options.unavailable); return r.json(); })
|
|
17
|
+
.then(function (login) {
|
|
18
|
+
if (!login.SynoToken) throw Error(options.unavailable);
|
|
19
|
+
var body = new URLSearchParams(Object.assign({ api: name, method: method, version: version }, params));
|
|
20
|
+
return request('/webapi/entry.cgi', { method: 'POST', credentials: 'same-origin', headers: { 'X-SYNO-TOKEN': login.SynoToken }, body: body });
|
|
21
|
+
}).then(function (r) { if (!r.ok) throw Error(options.unavailable); return r.json(); })
|
|
22
|
+
.then(function (j) { if (j.success !== true) throw Error(options.unavailable); return j.data; });
|
|
23
|
+
};
|
|
24
|
+
var value = Vue.ref(options.share ? '/' + options.share + (options.subpath ? '/' + options.subpath : '') : '');
|
|
25
|
+
var error = Vue.ref('');
|
|
26
|
+
var busy = Vue.ref(false);
|
|
27
|
+
var valid = false, sequence = 0, chooser;
|
|
28
|
+
var hooks = hook(props);
|
|
29
|
+
function owner() { return props.getWizard ? props.getWizard() : props.getOwner(); }
|
|
30
|
+
function disable(state) {
|
|
31
|
+
var wizard = owner();
|
|
32
|
+
if (wizard.setNextStepDisable) wizard.setNextStepDisable(state);
|
|
33
|
+
else wizard.getButton('next').setDisabled(state);
|
|
34
|
+
}
|
|
35
|
+
function checkState() { disable(!valid || busy.value); return false; }
|
|
36
|
+
function check() {
|
|
37
|
+
var current = ++sequence;
|
|
38
|
+
valid = false; busy.value = true; error.value = ''; checkState();
|
|
39
|
+
var path = value.value;
|
|
40
|
+
var parts = path.split('/'), share = parts[1];
|
|
41
|
+
if (!/^\/[^/]+(?:\/[^/]+)*$/.test(path) || path.length > 1024 || /[\\"\x00-\x1f\x7f]/.test(path) || parts.slice(1).some(function (p) { return p === '.' || p === '..'; })) {
|
|
42
|
+
busy.value = false; error.value = options.invalid; checkState(); return Promise.resolve(false);
|
|
43
|
+
}
|
|
44
|
+
return api('SYNO.Core.Share', 'get', 1, { name: share, additional: JSON.stringify(['encryption','is_aclmode','is_force_readonly','is_share_moving','is_missing_share','is_offline_share','is_c2_share','load_worm_attr','load_tiering_attr','is_tiering_bucket','is_cluster_share','is_cold_storage_share']) })
|
|
45
|
+
.then(function (s) {
|
|
46
|
+
if (!s || s.name !== share || !/^\/volume[0-9]+$/.test(s.vol_path) || ![0,1,2].includes(s.encryption)) throw Error(options.unavailable);
|
|
47
|
+
if (/^(homes?|users|ftp|root|admin|guest|system|volume[0-9]*|(usb|sata|sd)share[0-9]*|ActiveBackupforBusiness|surveillance|docker|web_packages)$/i.test(share) || /^[.@]/.test(share) || share.indexOf('..') !== -1 || share.length > 32 || s.is_aclmode !== true || s.encryption === 2 || s.is_remote_share || s.is_cluster_share || s.is_cold_storage_share || s.is_usb_share || s.is_force_readonly || s.is_share_moving || s.is_missing_share || s.is_offline_share || s.is_c2_share || s.is_worm_share || s.worm_state || s.is_tiering_bucket || (s.worm_subvol_mode && s.worm_subvol_mode !== 'normal')) throw Error(options.unsupported);
|
|
48
|
+
return api('SYNO.FileStation.List','getinfo',2,{ path: JSON.stringify([path]), additional: JSON.stringify(['real_path','perm','mount_point_type']) }).then(function (d) {
|
|
49
|
+
var f = d && d.files && d.files[0];
|
|
50
|
+
if (!f || f.path !== path || !f.isdir || f.code || f.additional?.real_path !== s.vol_path + path || f.additional?.mount_point_type && f.additional.mount_point_type !== 'local') throw Error(options.unavailable);
|
|
51
|
+
if (current === sequence) valid = true;
|
|
52
|
+
});
|
|
53
|
+
}).catch(function (e) { if (current === sequence) error.value = e.message || options.unavailable; })
|
|
54
|
+
.then(function () { if (current === sequence) { busy.value = false; checkState(); } return valid; });
|
|
55
|
+
}
|
|
56
|
+
function browse() {
|
|
57
|
+
function show() {
|
|
58
|
+
if (!SYNO.SDS.Utils.FileChooser?.Chooser) throw Error(options.unavailable);
|
|
59
|
+
chooser = new SYNO.SDS.Utils.FileChooser.Chooser({ owner: owner(), title: options.label,
|
|
60
|
+
usage: { type: 'chooseDir', multiple: false }, needrw: false, superuser: false,
|
|
61
|
+
hideFavorites: true, enumRecycle: false, folderToolbar: false, gotoPath: value.value,
|
|
62
|
+
listeners: { choose: function (dialog, selection) {
|
|
63
|
+
value.value = selection.path || ''; dialog.close(); chooser = undefined; check();
|
|
64
|
+
}}
|
|
65
|
+
});
|
|
66
|
+
chooser.show();
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
if (SYNO.SDS.Utils.FileChooser?.Chooser) show();
|
|
70
|
+
else SYNO.SDS.JSLoadPromise('SYNO.SDS.Utils.FileChooser').then(show).catch(function () { error.value = options.unavailable; });
|
|
71
|
+
} catch (e) { error.value = options.unavailable; }
|
|
72
|
+
}
|
|
73
|
+
Vue.onMounted(function () { if (value.value) check(); else checkState(); });
|
|
74
|
+
Vue.onBeforeUnmount(function () { sequence++; if (chooser) chooser.close(); });
|
|
75
|
+
return { headline: options.title, getNext: function () { return valid && !busy.value ? hooks.getNext() : false; }, checkState: checkState,
|
|
76
|
+
getValues: function () {
|
|
77
|
+
if (!valid || busy.value) return {};
|
|
78
|
+
var parts = value.value.split('/'), values = {};
|
|
79
|
+
values[options.key] = parts[1]; values[options.key + '_subpath'] = parts.slice(2).join('/');
|
|
80
|
+
return values;
|
|
81
|
+
}, value: value, error: error, busy: busy, browse: browse, intro: options.intro,
|
|
82
|
+
label: options.label, browseLabel: options.browse, checking: options.checking };
|
|
83
|
+
},
|
|
84
|
+
render: function (h) {
|
|
85
|
+
return h('pkg-center-step-content', [
|
|
86
|
+
h('p', { style: { marginBottom: '20px' } }, this.intro),
|
|
87
|
+
h('v-form', [h('v-form-item', { props: { label: this.label, controlFlex: '440px' } }, [
|
|
88
|
+
h('v-input', { props: { value: this.value, readonly: true } }),
|
|
89
|
+
h('v-button', { style: { marginTop: '8px' }, props: { disabled: this.busy }, on: { click: this.browse } }, this.browseLabel)
|
|
90
|
+
])]),
|
|
91
|
+
h('p', { attrs: { role: 'status', 'aria-live': 'polite' } }, this.busy ? this.checking : this.error)
|
|
92
|
+
]);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
SYNO.SDS.PkgManApp.Custom.JsonpLoader.load({ default: { name: options.name, render: component } });
|
|
96
|
+
})(__SYNOPKGLAND_FOLDER_OPTIONS__);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SharedFolder } from '../standalone/shared-folder.js';
|
|
2
|
+
import type { Translate } from './wizard-i18n.js';
|
|
3
|
+
export declare function validFolderSubpath(path: string): boolean;
|
|
4
|
+
export declare function folderSubpathItem(t: Translate, key: string): Record<string, unknown>;
|
|
5
|
+
/** Static files remain legacy compatible. Only the NAS-side script emits custom JS. */
|
|
6
|
+
export declare function folderPickerWizardFiles(pkg: string, folder: SharedFolder | undefined, files: Record<string, string>): Record<string, string>;
|
|
7
|
+
export declare function folderUpgradeScript(pkg: string, key: string, json: string): string;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
export function validFolderSubpath(path) {
|
|
3
|
+
return path.length <= 1024 && !/[\\"\x00-\x1f\x7f]/.test(path) &&
|
|
4
|
+
(path === '' || path.split('/').every(p => p !== '' && p !== '.' && p !== '..'));
|
|
5
|
+
}
|
|
6
|
+
export function folderSubpathItem(t, key) {
|
|
7
|
+
const invalid = JSON.stringify(t('nativeShare.selectionInvalid'));
|
|
8
|
+
const unavailable = JSON.stringify(t('nativeShare.selectionUnavailable'));
|
|
9
|
+
return { type: 'textfield', desc: 'Folder path within the shared folder (leave empty for the root)', subitems: [{
|
|
10
|
+
key: key + '_subpath', desc: '', defaultValue: '', validator: { allowBlank: true, maxLength: 1024,
|
|
11
|
+
fn: `{var path=arguments[0];if(path&&(/^[\\/]|[\\/]$|[\\\\"\\x00-\\x1f\\x7f]/.test(path)||path.split('/').some(function(p){return !p||p==='.'||p==='..'})))return ${invalid};try{var field=arguments[1],panel=field.findParentBy(function(p){return typeof p.getForm==='function'}),share=panel.getForm().findField(${JSON.stringify(key)}).getValue();if(!share)return ${unavailable};var login=new XMLHttpRequest();login.open('GET','/webman/login.cgi?enable_syno_token=yes',false);login.send();var token=JSON.parse(login.responseText).SynoToken;if(!token)return ${unavailable};var x=new XMLHttpRequest();x.open('POST','/webapi/entry.cgi',false);x.setRequestHeader('Content-Type','application/x-www-form-urlencoded');x.setRequestHeader('X-SYNO-TOKEN',token);var full='/'+share+(path?'/'+path:'');x.send('api=SYNO.FileStation.List&method=getinfo&version=2&path='+encodeURIComponent(JSON.stringify([full]))+'&additional='+encodeURIComponent(JSON.stringify(['real_path','mount_point_type'])));var j=JSON.parse(x.responseText),f=j.data&&j.data.files&&j.data.files[0];return x.status===200&&j.success===true&&f&&f.isdir&&f.path===full&&!f.code?true:${unavailable}}catch(e){return ${unavailable}}}`,
|
|
12
|
+
},
|
|
13
|
+
}] };
|
|
14
|
+
}
|
|
15
|
+
/** Static files remain legacy compatible. Only the NAS-side script emits custom JS. */
|
|
16
|
+
export function folderPickerWizardFiles(pkg, folder, files) {
|
|
17
|
+
if (folder?.picker !== 'folder')
|
|
18
|
+
return files;
|
|
19
|
+
const result = { ...files };
|
|
20
|
+
for (const [name, content] of Object.entries(files)) {
|
|
21
|
+
if (!/^(install|upgrade)_uifile.*\.sh$/.test(name))
|
|
22
|
+
continue;
|
|
23
|
+
const script = content.replace(/(cat <<'SYNOPKGLAND_WIZARD'[^\n]*\n)([\s\S]*?)(\nSYNOPKGLAND_WIZARD)/g, (_, head, json, tail) => {
|
|
24
|
+
const steps = JSON.parse(json);
|
|
25
|
+
const modern = steps.map(step => {
|
|
26
|
+
const box = step.items?.find((i) => i.type === 'combobox' && i.subitems?.[0]?.key === folder.key);
|
|
27
|
+
if (!box)
|
|
28
|
+
return step;
|
|
29
|
+
const subpath = step.items.find((i) => i.subitems?.[0]?.key === folder.key + '_subpath');
|
|
30
|
+
const options = {
|
|
31
|
+
name: `synopkgland_folder_${pkg}_${folder.key}`, key: folder.key, title: step.step_title,
|
|
32
|
+
share: box.subitems[0].defaultValue ?? '', subpath: subpath?.subitems[0].defaultValue ?? '',
|
|
33
|
+
intro: step.items.filter((i) => !i.type).map((i) => i.desc).join(' '),
|
|
34
|
+
label: 'Folder', browse: 'Browse', checking: 'Checking folder',
|
|
35
|
+
invalid: 'Choose a valid folder path', unavailable: 'Folder unavailable or access denied. Choose an existing local folder.',
|
|
36
|
+
unsupported: 'This shared folder type is not supported. Choose a mounted local ACL shared folder.',
|
|
37
|
+
};
|
|
38
|
+
const asset = readFileSync(new URL('../../assets/folder-picker.js', import.meta.url), 'utf8');
|
|
39
|
+
return { step_title: step.step_title, custom_render_name: options.name,
|
|
40
|
+
custom_render_fn: asset.replace('__SYNOPKGLAND_FOLDER_OPTIONS__', () => JSON.stringify(options)) };
|
|
41
|
+
});
|
|
42
|
+
return `if [ "$synopkgland_folder_modern" = 1 ]; then\n${head}${JSON.stringify(modern, null, 2)}${tail}\nelse\n${head}${json}${tail}\nfi`;
|
|
43
|
+
});
|
|
44
|
+
// Source only DSM's trusted version file. Unknown versions use standard controls.
|
|
45
|
+
result[name] = script.replace('#!/bin/sh\n', '#!/bin/sh\nsynopkgland_folder_modern=0\nif [ -r /etc/VERSION ]; then\n . /etc/VERSION\n if [ "${majorversion:-0}" -gt 7 ] || { [ "${majorversion:-0}" -eq 7 ] && { [ "${minorversion:-0}" -gt 2 ] || { [ "${minorversion:-0}" -eq 2 ] && [ "${micro:-0}" -ge 2 ]; }; }; }; then synopkgland_folder_modern=1; fi\nfi\n');
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
export function folderUpgradeScript(pkg, key, json) {
|
|
50
|
+
return `#!/bin/sh
|
|
51
|
+
set -eu
|
|
52
|
+
config="\${SYNOPKG_PKGVAR:-/var/packages/${pkg}/var}/config.json"
|
|
53
|
+
[ -z "\${SYNOPKG_TEMP_LOGFILE:-}" ] || exec > "$SYNOPKG_TEMP_LOGFILE"
|
|
54
|
+
share=''
|
|
55
|
+
subpath=''
|
|
56
|
+
if [ -f "$config" ]; then
|
|
57
|
+
valid=$(sed -n 's/^{"schema":1,"shared_folders":{"${key}":"[^"\\\\]*"},"shared_folder_paths":{"${key}":"[^"\\\\]*"}}$/yes/p' "$config")
|
|
58
|
+
share=$(sed -n 's/^.*"shared_folders":{"${key}":"\\([^"\\\\]*\\)"}.*$/\\1/p' "$config")
|
|
59
|
+
subpath=$(sed -n 's/^.*"shared_folder_paths":{"${key}":"\\([^"\\\\]*\\)"}.*$/\\1/p' "$config")
|
|
60
|
+
if [ "$valid" != yes ]; then share=''; subpath=''; fi
|
|
61
|
+
fi
|
|
62
|
+
case "$share" in *'"'*|*'\\'*|*'/'*|*[[:cntrl:]]*) share='' ;; esac
|
|
63
|
+
case "$subpath" in *'"'*|*'\\'*|*[[:cntrl:]]*) subpath='' ;; esac
|
|
64
|
+
share=$(printf '%s' "$share" | sed 's/[&|]/\\\\&/g')
|
|
65
|
+
subpath=$(printf '%s' "$subpath" | sed 's/[&|]/\\\\&/g')
|
|
66
|
+
cat <<'SYNOPKGLAND_WIZARD' | sed "s|__FOLDER_SHARE__|$share|g;s|__FOLDER_SUBPATH__|$subpath|g"
|
|
67
|
+
${json}
|
|
68
|
+
SYNOPKGLAND_WIZARD
|
|
69
|
+
`;
|
|
70
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { validFolderSubpath } from '../build-spk/folder-picker.js';
|
|
1
2
|
import { portDefaults } from "../standalone/install-ports.js";
|
|
2
3
|
const USAGE = "synopkgland deploy --param delegate_share=<shared folder>, or --param delegate_home=true";
|
|
3
4
|
/** Mirrors the preinst draft check in build-spk/delegate-scope.ts. */
|
|
@@ -22,7 +23,7 @@ export function resolveNativeInstallValues(manifest, provided, state) {
|
|
|
22
23
|
const names = Object.keys(provided);
|
|
23
24
|
if (!selected && !folder && !settingNames.length && !portNames.length && names.length)
|
|
24
25
|
return fail("DEPLOY_PARAM_UNDECLARED", `${manifest.package} has no install wizard values; remove --param ${names[0]}.`);
|
|
25
|
-
const unknown = names.find((name) => !(selected && (name === "delegate_share" || name === "delegate_home")) && name !== key && name !== changeKey && !settingNames.includes(name) && !portNames.includes(name));
|
|
26
|
+
const unknown = names.find((name) => !(selected && (name === "delegate_share" || name === "delegate_home")) && name !== key && !(folder?.picker === "folder" && name === key + "_subpath") && name !== changeKey && !settingNames.includes(name) && !portNames.includes(name));
|
|
26
27
|
if (unknown)
|
|
27
28
|
return fail("DEPLOY_PARAM_UNDECLARED", `--param ${unknown} is not an install wizard value. Use: ${folder ? `--param ${folder.key}=<shared folder>` : USAGE}.`);
|
|
28
29
|
if (key && changeKey) {
|
|
@@ -36,6 +37,15 @@ export function resolveNativeInstallValues(manifest, provided, state) {
|
|
|
36
37
|
if (state.installed && name !== undefined && change !== "true")
|
|
37
38
|
return fail("DEPLOY_PARAM_REQUIRED", `Changing the selected folder requires --param ${changeKey}=true and --param ${key}=<shared folder>.`);
|
|
38
39
|
}
|
|
40
|
+
if (folder?.picker === 'folder' && key) {
|
|
41
|
+
const path = provided[key + '_subpath'];
|
|
42
|
+
if (path !== undefined && !validFolderSubpath(path))
|
|
43
|
+
return fail('DEPLOY_PARAM_TYPE_INVALID', 'Folder subpath must be relative, without traversal, empty components, quotes, backslashes or control characters.');
|
|
44
|
+
if ((!state.installed || provided[changeKey] === 'true') && path === undefined)
|
|
45
|
+
return fail('DEPLOY_PARAM_REQUIRED', `Supply --param ${key}_subpath=<relative path>; an explicit empty value selects the share root.`);
|
|
46
|
+
if (state.installed && path !== undefined && (provided[key] === undefined || provided[changeKey] !== 'true'))
|
|
47
|
+
return fail('DEPLOY_PARAM_REQUIRED', 'Changing a folder requires the share, subpath and CHANGE flag together.');
|
|
48
|
+
}
|
|
39
49
|
for (const name of portNames) {
|
|
40
50
|
const raw = provided[name];
|
|
41
51
|
if (raw === undefined)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"module":"github.com/synopackageland/syno-pkg-land-sdk","version":"
|
|
1
|
+
{"module":"github.com/synopackageland/syno-pkg-land-sdk","version":"development","local":true}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { goPrivateCovers } from './go-env.js';
|
|
2
2
|
import { type ExecutorManifest } from './sdk-executor-manifest.js';
|
|
3
3
|
/** Pinned SDK for CLI-owned controllers and Compose planning; App pins take precedence. */
|
|
4
|
-
export declare const DEFAULT_SDK_VERSION = "0.53.
|
|
4
|
+
export declare const DEFAULT_SDK_VERSION = "0.53.22";
|
|
5
5
|
export declare const SDK_PACKAGE = "@synopackageland/sdk";
|
|
6
6
|
export declare const SDK_MODULE = "github.com/synopackageland/syno-pkg-land-sdk";
|
|
7
7
|
export declare const EXECUTOR_MODULE = "github.com/synopackageland/syno-pkg-land-sdk/executor";
|
|
@@ -5,7 +5,7 @@ import { tmpdir } from 'node:os';
|
|
|
5
5
|
import { join } from 'node:path';
|
|
6
6
|
import { readExecutorManifest, predatesExecutorManifest } from './sdk-executor-manifest.js';
|
|
7
7
|
/** Pinned SDK for CLI-owned controllers and Compose planning; App pins take precedence. */
|
|
8
|
-
export const DEFAULT_SDK_VERSION = '0.53.
|
|
8
|
+
export const DEFAULT_SDK_VERSION = '0.53.22';
|
|
9
9
|
export const SDK_PACKAGE = '@synopackageland/sdk';
|
|
10
10
|
export const SDK_MODULE = 'github.com/synopackageland/syno-pkg-land-sdk';
|
|
11
11
|
export const EXECUTOR_MODULE = `${SDK_MODULE}/executor`;
|
|
@@ -107,6 +107,11 @@ export function readComposeApp(value, root, arches, fail, context = {}) {
|
|
|
107
107
|
hostUdp = [...value.host_udp].map(l => ({ port: l.port, purpose: l.purpose })).sort((a, b) => a.port - b.port);
|
|
108
108
|
}
|
|
109
109
|
const sdk = typeof value.sdk === "string" ? value.sdk : (context.sdk ?? DEFAULT_SDK_VERSION);
|
|
110
|
+
if (context.sharedFolder?.picker === "folder") {
|
|
111
|
+
const [major, minor, patch] = sdk.split('.').map(Number);
|
|
112
|
+
if (major === 0 && (minor < 53 || minor === 53 && patch < 22))
|
|
113
|
+
return invalid('Folder selection requires SDK 0.53.22 or later.', 'SDK_COMPOSE_UNSUPPORTED');
|
|
114
|
+
}
|
|
110
115
|
let targets = {};
|
|
111
116
|
if (value.helpers !== undefined) {
|
|
112
117
|
const d = readDaemon({ exec: "_sso/gateway", targets: value.helpers }, root, arches, fail, context.package);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { folderPickerWizardFiles } from '../build-spk/folder-picker.js';
|
|
1
2
|
import { parseDsmStrings } from "./dsm-texts.js";
|
|
2
3
|
import { readTCPListeners } from "./tcp-listeners.js";
|
|
3
4
|
import { inspectMobileFiles, mobileRecordProblem } from './mobile.js';
|
|
@@ -1666,11 +1667,11 @@ function expectedWizardFiles(pkg, folder, selected = false, portal, installSetti
|
|
|
1666
1667
|
? sharedFolderInstallSteps(pkg, folder)
|
|
1667
1668
|
: renderNativeInstallWizard;
|
|
1668
1669
|
const install = renderInstallWizardFiles(pkg, t => [...steps(t), ...portInstallSteps({ package: pkg, ...(Object.keys(installPortDefinitions).length ? { installPorts: true } : {}) }, installPortDefinitions)(t), ...settingsInstallSteps(installSettings, settingsPort, Object.keys(installPortDefinitions).length ? pkg : undefined)(t), ...(portal ? [renderPortalWizardStep(t, portal.alias)] : []), ...integrationWizardSteps(t, integrations)], minMemoryMb);
|
|
1669
|
-
return {
|
|
1670
|
+
return folderPickerWizardFiles(pkg, folder, {
|
|
1670
1671
|
...install.static,
|
|
1671
1672
|
...install.dynamic,
|
|
1672
1673
|
...renderUpgradeWizardFiles(pkg, folder, integrations, minMemoryMb),
|
|
1673
|
-
};
|
|
1674
|
+
});
|
|
1674
1675
|
}
|
|
1675
1676
|
function portalManifest(portal) {
|
|
1676
1677
|
return portal
|
|
@@ -77,7 +77,9 @@ function renderStandaloneScriptInternal(name, manifest) {
|
|
|
77
77
|
const paths = `"\${SYNOPKG_PKGDEST:-/var/packages/${manifest.package}/target}" "\${SYNOPKG_PKGVAR:-/var/packages/${manifest.package}/var}"`;
|
|
78
78
|
const preflight = name === "start-stop-status"
|
|
79
79
|
? (!manifest.identityGateway ? `if [ "$1" = restart ]; then\n "$0" stop || exit $?\n exec "$0" start\nfi\n` : "") +
|
|
80
|
-
|
|
80
|
+
(manifest.sharedFolder?.picker === "folder" ?
|
|
81
|
+
`case "$1" in prestart|start|restart)\n synopkgland_preflight=0\n "\${SYNOPKG_PKGDEST:-/var/packages/${manifest.package}/target}/compose/control" preflight || synopkgland_preflight=$?\n if [ "$synopkgland_preflight" != 0 ]; then\n case "\${SYNOPKG_PKG_STATUS:-}:$synopkgland_preflight" in INSTALL:2|UPGRADE:2) exit 0 ;; esac\n exit "$synopkgland_preflight"\n fi ;;\nesac\n` :
|
|
82
|
+
`case "$1" in prestart|start|restart)\n "\${SYNOPKG_PKGDEST:-/var/packages/${manifest.package}/target}/compose/control" preflight || exit $? ;;\nesac\n`) +
|
|
81
83
|
(!manifest.identityGateway ? `case "$1" in prestart|prestop) exit 0 ;; esac\n` : "")
|
|
82
84
|
: "";
|
|
83
85
|
const remember = name === "postinst" &&
|
|
@@ -304,6 +304,8 @@ function readManifest(raw, c) {
|
|
|
304
304
|
const sharedFolder = raw.install === undefined
|
|
305
305
|
? undefined
|
|
306
306
|
: readSharedFolder(raw.install, (e) => c.fail(e.code, e.message));
|
|
307
|
+
if (sharedFolder?.picker === "folder" && raw.compose === undefined)
|
|
308
|
+
c.fail("STANDALONE_SHARED_FOLDER_INVALID", "picker: folder requires a Compose App.");
|
|
307
309
|
const installPorts = isRecord(raw.install) && raw.install.ports === true ? true : undefined;
|
|
308
310
|
const minMemoryMb = readMinMemoryMb(isRecord(raw.install) ? raw.install.min_memory_mb : undefined, e => c.fail(e.code, e.message));
|
|
309
311
|
if (isRecord(raw.install) && raw.install.ports !== undefined && raw.install.ports !== true)
|
|
@@ -17,6 +17,7 @@ export interface SharedFolder {
|
|
|
17
17
|
/** Dedicated or fixed Shared Folder created by DSM data-share. */
|
|
18
18
|
name?: string;
|
|
19
19
|
permission: "ro" | "rw";
|
|
20
|
+
picker?: "folder";
|
|
20
21
|
}
|
|
21
22
|
export declare function readSharedFolder(value: unknown, fail: (error: StandaloneError) => void): SharedFolder | undefined;
|
|
22
23
|
/** The first line `inspect` looks for to recover the declaration from an SPK. */
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { folderSubpathItem, folderUpgradeScript } from '../build-spk/folder-picker.js';
|
|
1
2
|
import { DSM_LANGS, LOCALES } from "./i18n.js";
|
|
2
3
|
import { existingShareValidator } from "../build-spk/share-validation.js";
|
|
3
4
|
import { sharedFolderActivation, sharedFolderCombobox } from "../build-spk/share-combobox.js";
|
|
4
5
|
import { renderWizardFiles, translator } from "../build-spk/wizard-i18n.js";
|
|
5
6
|
import { integrationWizardSteps, renderMemoryWizardCheck } from "../build-spk/install-wizard.js";
|
|
6
|
-
const FIELDS = new Set(["mode", "key", "name", "permission"]);
|
|
7
|
+
const FIELDS = new Set(["mode", "key", "name", "permission", "picker"]);
|
|
7
8
|
const KEY = /^[a-z][a-z0-9_]{0,31}$/;
|
|
8
9
|
const RESERVED_KEY = /^(pkgwizard_|synopkg|change_)/;
|
|
9
10
|
const SHARE_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]{0,31}$/;
|
|
@@ -23,9 +24,11 @@ export function readSharedFolder(value, fail) {
|
|
|
23
24
|
return undefined;
|
|
24
25
|
const folder = value.sharedFolder;
|
|
25
26
|
if (!isRecord(folder) || Object.keys(folder).some((key) => !FIELDS.has(key))) {
|
|
26
|
-
return refuse(" accepts only mode, key, name and
|
|
27
|
+
return refuse(" accepts only mode, key, name, permission and picker.");
|
|
27
28
|
}
|
|
28
|
-
const { mode, key, name, permission } = folder;
|
|
29
|
+
const { mode, key, name, permission, picker } = folder;
|
|
30
|
+
if (picker !== undefined && (picker !== "folder" || mode !== "select"))
|
|
31
|
+
return refuse("picker: folder requires mode: select.");
|
|
29
32
|
if (mode !== "select" && mode !== "create" && mode !== "dedicated")
|
|
30
33
|
return refuse(" mode must be dedicated, select or create.");
|
|
31
34
|
if (permission !== "ro" && permission !== "rw")
|
|
@@ -34,7 +37,7 @@ export function readSharedFolder(value, fail) {
|
|
|
34
37
|
return refuse(" key must start with a lowercase letter, contain only lowercase alphanumerics and underscores (at most 32 characters), and must not start with pkgwizard_, synopkg or change_.");
|
|
35
38
|
}
|
|
36
39
|
if (mode === "select") {
|
|
37
|
-
return name === undefined ? { mode, key, permission } : refuse(" name applies only to create; select is chosen by the install wizard.");
|
|
40
|
+
return name === undefined ? { mode, key, permission, ...(picker ? { picker: "folder" } : {}) } : refuse(" name applies only to create; select is chosen by the install wizard.");
|
|
38
41
|
}
|
|
39
42
|
if (typeof name !== "string" || !SHARE_NAME.test(name) || SYSTEM_SHARE.test(name)) {
|
|
40
43
|
return refuse("create needs name: start with an alphanumeric, contain only alphanumerics, underscores and hyphens (at most 32 characters), and not be a DSM system shared folder name.");
|
|
@@ -50,6 +53,30 @@ export const SHARED_FOLDER_MARKER = "# synopkgland:install.sharedFolder ";
|
|
|
50
53
|
*/
|
|
51
54
|
export function renderSharedFolderScript(pkg, folder) {
|
|
52
55
|
const { key } = folder;
|
|
56
|
+
if (folder.picker === "folder")
|
|
57
|
+
return `#!/bin/sh
|
|
58
|
+
${SHARED_FOLDER_MARKER}${JSON.stringify(folder)}
|
|
59
|
+
set -eu
|
|
60
|
+
PKGVAR="\${SYNOPKG_PKGVAR:-/var/packages/${pkg}/var}"
|
|
61
|
+
synopkgland_folder_check() {
|
|
62
|
+
"\${SYNOPKG_PKGDEST:-/var/packages/${pkg}/target}/compose/control" share-check || :
|
|
63
|
+
}
|
|
64
|
+
if [ "\${SYNOPKG_PKG_STATUS:-}" = UPGRADE ] && [ "\${${key}+x}" != x ]; then synopkgland_folder_check; exit 0; fi
|
|
65
|
+
name="\${${key}:?missing shared folder}"
|
|
66
|
+
[ "\${${key}_subpath+x}" = x ] || { echo "missing folder subpath answer" >&2; exit 1; }
|
|
67
|
+
# Empty subpath selects the root; presence is mandatory, content may be empty.
|
|
68
|
+
subpath="\${${key}_subpath-}"
|
|
69
|
+
case "$name$subpath" in *'"'*|*'\\'*|*[[:cntrl:]]*) echo "[COMPOSE_SHARE_INVALID] invalid folder selection" >&2; exit 1 ;; esac
|
|
70
|
+
umask 077
|
|
71
|
+
mkdir -p "$PKGVAR"
|
|
72
|
+
tmp="$PKGVAR/config.json.tmp.$$"
|
|
73
|
+
printf '{"schema":1,"shared_folders":{"${key}":"%s"},"shared_folder_paths":{"${key}":"%s"}}\\n' "$name" "$subpath" > "$tmp"
|
|
74
|
+
mv "$tmp" "$PKGVAR/config.json"
|
|
75
|
+
# DSM data-share has acquired before postinst. Report recoverable access status
|
|
76
|
+
# without turning a successful installation or upgrade into a failed install.
|
|
77
|
+
synopkgland_folder_check
|
|
78
|
+
exit 0
|
|
79
|
+
`;
|
|
53
80
|
const pick = folder.mode === "create"
|
|
54
81
|
? `name='${folder.name}'`
|
|
55
82
|
: `name=""
|
|
@@ -113,7 +140,7 @@ function installItems(t, pkg, folder) {
|
|
|
113
140
|
field.validator = { allowBlank: false, fn: existingShareValidator(validationMessages(t), false, folder.name) };
|
|
114
141
|
if (folder.mode === "dedicated")
|
|
115
142
|
picker.desc = t("nativeShare.optionalExisting", { name: folder.name });
|
|
116
|
-
return [intro(t, pkg, folder), picker];
|
|
143
|
+
return [intro(t, pkg, folder), picker, ...(folder.picker === "folder" ? [folderSubpathItem(t, folder.key)] : [])];
|
|
117
144
|
}
|
|
118
145
|
/** Upgrade always submits the displayed selection, prefilled from config.json.
|
|
119
146
|
* A raw unconfirmed picker value must never diverge from the DSM resource grant. */
|
|
@@ -169,7 +196,13 @@ export function renderUpgradeWizardFiles(pkg, folder, integrations = [], minMemo
|
|
|
169
196
|
const retained = JSON.stringify(steps, null, 2);
|
|
170
197
|
const fresh = JSON.stringify([sharedFolderStep(t("upgrade.step"), installItems(t, pkg, folder), folder), ...integrationWizardSteps(t, integrations)], null, 2);
|
|
171
198
|
const name = locale === "en" ? "upgrade_uifile.sh" : `upgrade_uifile_${DSM_LANGS[locale]}.sh`;
|
|
172
|
-
|
|
199
|
+
if (folder.picker === "folder") {
|
|
200
|
+
field.defaultValue = "__FOLDER_SHARE__";
|
|
201
|
+
steps[0].items[2].subitems[0].defaultValue = "__FOLDER_SUBPATH__";
|
|
202
|
+
files[name] = folderUpgradeScript(pkg, folder.key, JSON.stringify(steps, null, 2));
|
|
203
|
+
}
|
|
204
|
+
else
|
|
205
|
+
files[name] = sharedFolderUpgradeScript(pkg, folder.key, retained, fresh, invalid);
|
|
173
206
|
}
|
|
174
207
|
}
|
|
175
208
|
if (minMemoryMb !== undefined) {
|
package/dist/standalone/spk.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { folderPickerWizardFiles } from '../build-spk/folder-picker.js';
|
|
1
2
|
import { validateNativeArtifacts, digest } from '../ctl/native-metadata.js';
|
|
2
3
|
import { gatewayEntryPolicyDigest } from './identity-gateway.js';
|
|
3
4
|
import { renderMobileAssets } from './mobile.js';
|
|
@@ -377,9 +378,11 @@ export async function assembleStandaloneSpk(options) {
|
|
|
377
378
|
: renderNativeInstallWizard;
|
|
378
379
|
const install = renderInstallWizardFiles(manifest.package, (t) => [...steps(t), ...portInstallSteps(manifest)(t), ...settingsInstallSteps(manifest.installSettings, manifest.identityGateway?.listen.https, manifest.installPorts ? manifest.package : undefined)(t), ...(portal ? [renderPortalWizardStep(t, portal.alias)] : []), ...integrationWizardSteps(t, manifest.integrations)], manifest.minMemoryMb);
|
|
379
380
|
writeWizardUiFiles(staging, {
|
|
380
|
-
...
|
|
381
|
-
|
|
382
|
-
|
|
381
|
+
...folderPickerWizardFiles(manifest.package, folder, {
|
|
382
|
+
...install.static,
|
|
383
|
+
...install.dynamic,
|
|
384
|
+
...renderUpgradeWizardFiles(manifest.package, folder, manifest.integrations, manifest.minMemoryMb),
|
|
385
|
+
}),
|
|
383
386
|
...renderUninstallWizardFiles(manifest.package, "native", {
|
|
384
387
|
composeData: manifest.compose?.plan.app_data,
|
|
385
388
|
executor: Boolean(options.executor),
|
package/docs/shared-folders.md
CHANGED
|
@@ -87,3 +87,86 @@ and the official developer guide's Data from Wizard section for `{{key}}`
|
|
|
87
87
|
substitution. Device acceptance additionally verified first-install grants,
|
|
88
88
|
upgrade switching, same-version reinstallation after revocation and retained
|
|
89
89
|
files/ACLs after uninstall.
|
|
90
|
+
|
|
91
|
+
## Select an existing child folder (prototype)
|
|
92
|
+
|
|
93
|
+
Use a matching SDK release that includes installer folder selection (see the
|
|
94
|
+
changelog for the first supported release), then opt in on both declarations:
|
|
95
|
+
|
|
96
|
+
```yaml
|
|
97
|
+
install:
|
|
98
|
+
sharedFolder: {mode: select, key: media, permission: rw, picker: folder}
|
|
99
|
+
capabilities: {composeMounts: true}
|
|
100
|
+
compose:
|
|
101
|
+
sdk: <sdk-version>
|
|
102
|
+
files: [compose.yaml]
|
|
103
|
+
shares:
|
|
104
|
+
media:
|
|
105
|
+
select: install
|
|
106
|
+
picker: folder
|
|
107
|
+
permission: rw
|
|
108
|
+
mounts: [{service: web, target: /media}]
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
This reuses the current single native install share contract. `picker: folder`
|
|
112
|
+
is available only with `mode: select` and `select: install`; container-root
|
|
113
|
+
services still cannot bind shared folders. Other share modes keep their existing
|
|
114
|
+
behavior. It does not require an SDK frontend dependency in the application.
|
|
115
|
+
|
|
116
|
+
The same SPK checks `/etc/VERSION` in its dynamic install and upgrade wizards.
|
|
117
|
+
DSM 7.2.2 and newer receive a Vue custom page that opens DSM's native directory
|
|
118
|
+
chooser. DSM 7.1, DSM 7.2.1 and unknown versions receive a standard share combobox and a
|
|
119
|
+
relative folder-path text field. The static wizard is also the standard version;
|
|
120
|
+
older Package Center parsers never need to parse a custom page from this SPK.
|
|
121
|
+
The custom page follows the public
|
|
122
|
+
[ExamplePackages wizard contract](https://github.com/SynologyOpenSource/ExamplePackages/tree/main/ExamplePackage/WIZARD_UIFILES).
|
|
123
|
+
|
|
124
|
+
The wizard submits `media=Media` and `media_subpath=Projects/Level two/Deep`.
|
|
125
|
+
An explicitly empty `media_subpath` selects the share root. Paths can have
|
|
126
|
+
arbitrary depth within a supported mounted local ACL share. Absolute paths,
|
|
127
|
+
empty path components, `.`/`..`, double quotes, backslashes, control characters,
|
|
128
|
+
non-directories and symlink components are rejected. This prototype excludes
|
|
129
|
+
home/homes and the special share types listed above. Browse visibility follows
|
|
130
|
+
the logged-in administrator's effective DSM permissions; built-in administrator
|
|
131
|
+
access can differ from a normal user's ACL behavior.
|
|
132
|
+
|
|
133
|
+
`data-share` grants the whole **share**, not only the selected subtree. Mounting
|
|
134
|
+
one subtree does not narrow the package account's share grant. Directory-level
|
|
135
|
+
ACLs can still deny the account access. Preinst checks selection syntax, known
|
|
136
|
+
storage restrictions and available existence/type metadata. It does not require
|
|
137
|
+
package-account RO/RW before DSM data-share acquisition. A descendant that cannot
|
|
138
|
+
be inspected before that grant is deferred rather than called missing.
|
|
139
|
+
|
|
140
|
+
After acquisition, postinst records a read-only package-account check without
|
|
141
|
+
failing installation or upgrade. Startup repeats the actual RO/RW check. A
|
|
142
|
+
pending folder prevents App startup and uses the SDK's existing startup permission
|
|
143
|
+
Dialog, including the share/subfolder, missing permission, the exact **File Station
|
|
144
|
+
> folder > Properties > Permission > system internal user** recovery instructions,
|
|
145
|
+
and **Retry**. The stopped gateway's DSM entry can show this same Dialog. Retry
|
|
146
|
+
rechecks current access; the existing ready message directs the user to start the
|
|
147
|
+
App in Package Center. No ACL write, root App, or automatic privileged retry is
|
|
148
|
+
introduced. Upgrades follow the same sequence.
|
|
149
|
+
|
|
150
|
+
The saved record keeps the share name and relative folder path separately.
|
|
151
|
+
Upgrade displays both and can change the selection. Deletion, rename, or
|
|
152
|
+
revoked access blocks startup with a recovery message. A share moved to another
|
|
153
|
+
volume is resolved again; if the materialized container source differs, repair
|
|
154
|
+
or upgrade to regenerate it. The package never creates a missing selected folder
|
|
155
|
+
or moves existing files. Directory checks do not prove every child's ACL or
|
|
156
|
+
eliminate changes made after validation.
|
|
157
|
+
|
|
158
|
+
For CLI deployment, supply both answers:
|
|
159
|
+
`--param media=Media --param media_subpath='Projects/Level two/Deep'`.
|
|
160
|
+
Upgrade additionally needs `--param CHANGE_media=true`; omitting all answers
|
|
161
|
+
retains the installed selection. Until a matching SDK release is published, this feature
|
|
162
|
+
requires matching development SDK sources and is not available from a released
|
|
163
|
+
SDK pin.
|
|
164
|
+
|
|
165
|
+
Known storage limits: chooser metadata rejects home/homes, unmounted encryption,
|
|
166
|
+
USB/SATA, remote/cluster/C2/cold-storage, WORM, offline/moving and forced-read-only
|
|
167
|
+
shares. Backend mount metadata additionally rejects known network filesystems and
|
|
168
|
+
read-only mounts. This is not a complete DSM storage-type inventory: encryption
|
|
169
|
+
lock and WORM metadata do not have a package-readable filesystem equivalent, and
|
|
170
|
+
these special types have no complete device acceptance matrix. DSM 7.1/7.2.1
|
|
171
|
+
fallback coverage is unit/render coverage; it does not claim old-parser device
|
|
172
|
+
acceptance.
|