@synopackageland/cli 0.52.11 → 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 CHANGED
@@ -1,5 +1,19 @@
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
+
10
+ ## 0.52.13
11
+
12
+ - Add `install.min_memory_mb` for dynamic physical RAM admission on install and upgrade, independent of NAS model
13
+ - Integrate localized low-memory pages with the existing install and upgrade wizards and repeat the check in package-account preinst
14
+ - Warn and allow installation when MemTotal cannot be read; keep runtime/start behavior unchanged
15
+ - Inspect packaged requirements, wizard files and preinst checks against the same declaration
16
+
3
17
  ## 0.52.11
4
18
 
5
19
  - Bridge `window-activated` from the injected DSM AppWindow, including switching
@@ -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,9 +1,11 @@
1
+ import { type Locale } from "../standalone/i18n.js";
1
2
  import { type Translate } from "./wizard-i18n.js";
2
3
  /** One step of a DSM install wizard; `items` are rendered verbatim as JSON. */
3
4
  export interface InstallWizardStep {
4
5
  step_title: string;
5
6
  items: Array<Record<string, unknown>>;
6
7
  activeate?: string;
8
+ invalid_next_disabled_v2?: boolean;
7
9
  }
8
10
  /** The static JSON wizard per locale, and the dynamic script per locale. */
9
11
  export interface InstallWizardFiles {
@@ -16,7 +18,9 @@ export interface InstallWizardFiles {
16
18
  * versions and flows that do not run the dynamic script; both carry the same
17
19
  * items, and only the dynamic one adds the reuse notice when data exists.
18
20
  */
19
- export declare function renderInstallWizardFiles(packageName: string, render: (t: Translate) => InstallWizardStep[]): InstallWizardFiles;
21
+ export declare function renderInstallWizardFiles(packageName: string, render: (t: Translate) => InstallWizardStep[], minMemoryMb?: number): InstallWizardFiles;
22
+ /** Prepend to an existing dynamic wizard; retain its normal pages when memory is sufficient. */
23
+ export declare function renderMemoryWizardCheck(minMemoryMb: number | undefined, locale: Locale): string;
20
24
  /** Lists the App's unauthenticated service callbacks for the administrator. */
21
25
  export declare function integrationWizardSteps(t: Translate, methods?: readonly string[]): InstallWizardStep[];
22
26
  /** The native-go install step: no parameters, only the app-space consent. */
@@ -1,5 +1,6 @@
1
1
  import { DSM_LANGS, LOCALES } from "../standalone/i18n.js";
2
2
  import { renderWizardFiles, translator } from "./wizard-i18n.js";
3
+ import { memoryReason, renderMemoryProbe } from "../standalone/install-memory.js";
3
4
  const BASE = "install_uifile";
4
5
  function shellQuote(value) {
5
6
  return `'${value.replaceAll("'", "'\\''")}'`;
@@ -26,11 +27,11 @@ function withReuseNotice(steps, packageName, t) {
26
27
  * is chosen after the wizard on some flows). The wizard JSON is written to
27
28
  * `SYNOPKG_TEMP_LOGFILE`, DSM's documented channel, or stdout without it.
28
29
  */
29
- function renderDynamicScript(packageName, withData, withoutData) {
30
+ function renderDynamicScript(packageName, withData, withoutData, memoryCheck = "") {
30
31
  return `#!/bin/sh
31
32
  # Generated by synopkgland. Read-only: it checks whether this package already
32
33
  # has App Data on a volume, then prints the install wizard for this language.
33
- pkg=${shellQuote(packageName)}
34
+ ${memoryCheck}pkg=${shellQuote(packageName)}
34
35
  existing=
35
36
  for root in \${SYNOPKG_PKGDEST_VOL:-} /volume*; do
36
37
  if [ -n "$root" ] && [ -d "$root/@appdata/$pkg" ]; then
@@ -58,7 +59,7 @@ fi
58
59
  * versions and flows that do not run the dynamic script; both carry the same
59
60
  * items, and only the dynamic one adds the reuse notice when data exists.
60
61
  */
61
- export function renderInstallWizardFiles(packageName, render) {
62
+ export function renderInstallWizardFiles(packageName, render, minMemoryMb) {
62
63
  const staticFiles = renderWizardFiles(BASE, render);
63
64
  const dynamic = {};
64
65
  for (const locale of LOCALES) {
@@ -66,10 +67,36 @@ export function renderInstallWizardFiles(packageName, render) {
66
67
  const steps = render(t);
67
68
  const withData = JSON.stringify(withReuseNotice(steps, packageName, t), null, 2);
68
69
  const withoutData = JSON.stringify(steps, null, 2);
69
- dynamic[localeName(locale, ".sh")] = renderDynamicScript(packageName, withData, withoutData);
70
+ dynamic[localeName(locale, ".sh")] = renderDynamicScript(packageName, withData, withoutData, renderMemoryWizardCheck(minMemoryMb, locale));
70
71
  }
71
72
  return { static: staticFiles, dynamic };
72
73
  }
74
+ /** Prepend to an existing dynamic wizard; retain its normal pages when memory is sufficient. */
75
+ export function renderMemoryWizardCheck(minMemoryMb, locale) {
76
+ if (minMemoryMb === undefined)
77
+ return "";
78
+ const reason = memoryReason(minMemoryMb, locale, "__SYNOPKGLAND_MEMORY_GB__");
79
+ const page = [{
80
+ step_title: translator(locale)("memory.title"),
81
+ invalid_next_disabled_v2: true,
82
+ items: [{ type: "textfield", desc: reason, subitems: [{
83
+ key: "pkgwizard_memory_requirement", desc: "", defaultValue: "__SYNOPKGLAND_MEMORY_GB__",
84
+ readOnly: true, validator: { allowBlank: false, fn: `{return ${JSON.stringify(reason)}}` },
85
+ }] }],
86
+ }];
87
+ // Only a formatted numeric value enters JSON, never shell or meminfo text.
88
+ const json = JSON.stringify(page, null, 2);
89
+ return `${renderMemoryProbe(minMemoryMb)}if [ -n "$synopkgland_memory_low" ]; then
90
+ if [ -n "\${SYNOPKG_TEMP_LOGFILE:-}" ]; then
91
+ exec > "$SYNOPKG_TEMP_LOGFILE"
92
+ fi
93
+ sed "s/__SYNOPKGLAND_MEMORY_GB__/$synopkgland_memory_gb/g" <<'SYNOPKGLAND_MEMORY_WIZARD'
94
+ ${json}
95
+ SYNOPKGLAND_MEMORY_WIZARD
96
+ exit 0
97
+ fi
98
+ `;
99
+ }
73
100
  /** Lists the App's unauthenticated service callbacks for the administrator. */
74
101
  export function integrationWizardSteps(t, methods = []) {
75
102
  return methods.length ? [{ step_title: t("integration.step"), items: [{ desc: t("integration.notice", { methods: methods.join(", ") }) }] }] : [];
@@ -1,4 +1,26 @@
1
1
  export declare const WIZARD_MESSAGES: {
2
+ "memory.title": {
3
+ en: string;
4
+ "zh-TW": string;
5
+ "zh-CN": string;
6
+ ja: string;
7
+ ko: string;
8
+ de: string;
9
+ fr: string;
10
+ es: string;
11
+ it: string;
12
+ };
13
+ "memory.required": {
14
+ en: string;
15
+ "zh-TW": string;
16
+ "zh-CN": string;
17
+ ja: string;
18
+ ko: string;
19
+ de: string;
20
+ fr: string;
21
+ es: string;
22
+ it: string;
23
+ };
2
24
  "ports.http": {
3
25
  en: string;
4
26
  "zh-TW": string;
@@ -1,4 +1,26 @@
1
1
  export const WIZARD_MESSAGES = {
2
+ "memory.title": {
3
+ "en": "Memory requirement",
4
+ "zh-TW": "記憶體需求",
5
+ "zh-CN": "内存要求",
6
+ "ja": "必要なメモリ",
7
+ "ko": "메모리 요구 사항",
8
+ "de": "Arbeitsspeicheranforderung",
9
+ "fr": "Mémoire requise",
10
+ "es": "Memoria necesaria",
11
+ "it": "Memoria richiesta"
12
+ },
13
+ "memory.required": {
14
+ "en": "This App requires at least {required} GB of RAM; this NAS has {actual} GB",
15
+ "zh-TW": "此應用程式需要至少 {required} GB 記憶體,此 NAS 有 {actual} GB",
16
+ "zh-CN": "此应用程序需要至少 {required} GB 内存,此 NAS 有 {actual} GB",
17
+ "ja": "このアプリには {required} GB 以上の RAM が必要です。この NAS のメモリは {actual} GB です",
18
+ "ko": "이 앱에는 최소 {required} GB의 RAM이 필요합니다. 이 NAS의 메모리는 {actual} GB입니다",
19
+ "de": "Diese App benötigt mindestens {required} GB RAM; dieses NAS verfügt über {actual} GB",
20
+ "fr": "Cette application nécessite au moins {required} Go de RAM ; ce NAS dispose de {actual} Go",
21
+ "es": "Esta aplicación requiere al menos {required} GB de RAM; este NAS tiene {actual} GB",
22
+ "it": "Questa app richiede almeno {required} GB di RAM; questo NAS dispone di {actual} GB"
23
+ },
2
24
  "ports.http": {
3
25
  "en": "HTTP port",
4
26
  "zh-TW": "HTTP 連接埠",
@@ -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)
@@ -50,6 +50,7 @@ export const ERROR_REGISTRY = {
50
50
  DSM_WINDOW_COLOR_SCHEME: { code: 'DSM_WINDOW_COLOR_SCHEME', description: 'A DSM-window Vue component combines OS theme detection with a dynamic color-scheme binding', suggestion: 'Leave color-scheme unset in DSM windows; follow OS preferences only on the App\'s own full page' },
51
51
  STANDALONE_IDENTITY_WITHOUT_PORTAL: { code: 'STANDALONE_IDENTITY_WITHOUT_PORTAL', description: 'Standalone identity is enabled without an Application Portal declaration', suggestion: 'Use HTTPS-only standalone login outside DSM windows; declare portal only when an alias is needed' },
52
52
  INSTALL_SETTINGS_INVALID: { "code": "INSTALL_SETTINGS_INVALID", "description": "The installation setting declaration is invalid.", "suggestion": "Declare 1–32 lowercase identifier keys in install.settings, each with type https-origin, a plain label and an explicit boolean required; omit defaults and values." },
53
+ INSTALL_MIN_MEMORY_INVALID: { code: "INSTALL_MIN_MEMORY_INVALID", description: "The physical memory requirement or its packaged check is invalid.", suggestion: "Set install.min_memory_mb to a positive integer in MiB, at most 2147483647, and rebuild with the generated package-account hooks and wizards." },
53
54
  INSTALL_PORT_INVALID: { code: "INSTALL_PORT_INVALID", description: "The installation port declaration or selected value is invalid", suggestion: "Enable install.ports for a declared identity gateway and choose distinct available non-reserved ports between 1024 and 65535" },
54
55
  SDK_PORT_SETTINGS_UNSUPPORTED: { code: "SDK_PORT_SETTINGS_UNSUPPORTED", description: "The selected SDK does not provide installer-selected ports", suggestion: "Pin SDK 0.38.2 or a matching supported release and rebuild with the matching CLI" },
55
56
  SDK_INSTALL_SETTINGS_UNSUPPORTED: { "code": "SDK_INSTALL_SETTINGS_UNSUPPORTED", "description": "The selected SDK does not provide native installation settings.", "suggestion": "Pin SDK 0.24.0 or a matching supported release with installsettings/cmd/control, then rebuild with the matching CLI." },
@@ -1 +1 @@
1
- {"module":"github.com/synopackageland/syno-pkg-land-sdk","version":"0.53.11","local":false}
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.11";
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.11';
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);
@@ -20,6 +20,7 @@ export interface SpkInspection {
20
20
  tcpListeners?: TCPListeners;
21
21
  dependencies?: PackageDependencies;
22
22
  installSettings?: InstallSettings;
23
+ minMemoryMb?: number;
23
24
  /** Hyper Backup application backup, as sdk-package.json records it. */
24
25
  hyperBackup?: HyperBackup;
25
26
  identityGateway?: GatewayAdmissionReport;
@@ -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';
@@ -5,6 +6,7 @@ import { DAEMON_NOFILE_UNSUPPORTED, DAEMON_NOFILE_ACTIVATION_PROBLEM, readNoFile
5
6
  import { gatewayIngressPathProblem, gatewayIngressOwnershipSupported } from './gateway-ingress.js';
6
7
  import { renderGatewayIngressCheck } from './native-gateway.js';
7
8
  import { portDefaults, portInstallSteps } from "./install-ports.js";
9
+ import { readMinMemoryMb, renderMemoryHook } from "./install-memory.js";
8
10
  import { inspectPackageDependencies, dependencyInfo } from "./package-dependencies.js";
9
11
  import { readInstallSettings, settingsInstallSteps, settingsConfig, renderSettingsHook } from './install-settings.js';
10
12
  import { MODULE_UI_ENTRY, uiTreeDigest } from "./ui-assets.js";
@@ -186,6 +188,7 @@ export async function inspectSpk(spkPath, expectedKind) {
186
188
  findings.push("DAEMON_RESTART_INVALID daemon restart requires a native daemon controller, without Compose supervision");
187
189
  const { identityGateway, gateway } = await inspectGatewayAdmission(dir, paths, metadata.provider_only_oidc, findings);
188
190
  await inspectExternalGateway(dir, paths, payload, metadata.gateway_external, findings);
191
+ const minMemoryMb = inspectMemoryRequirement(dir, metadata.minMemoryMb, findings);
189
192
  const installSettings = await inspectInstallSettings(dir, payload, metadata, findings);
190
193
  const hyperBackup = metadataText === undefined ? undefined : await inspectHyperBackup(dir, async () => {
191
194
  const root = join(dir, "backup-inspection");
@@ -199,12 +202,14 @@ export async function inspectSpk(spkPath, expectedKind) {
199
202
  const integrations = metadata.integrations ?? [];
200
203
  await inspectCtlArtifacts(dir, paths, metadata.ctl, metadata.entry, findings);
201
204
  if (metadata.compose !== undefined) {
202
- const result = await inspectUnifiedCompose(dir, payload, { ...metadata, installSettings }, findings);
205
+ const result = await inspectUnifiedCompose(dir, payload, { ...metadata, installSettings, minMemoryMb }, findings);
203
206
  if (dependencies) {
204
207
  result.dependencies = dependencies;
205
208
  }
206
209
  if (installSettings)
207
210
  result.installSettings = installSettings;
211
+ if (minMemoryMb !== undefined)
212
+ result.minMemoryMb = minMemoryMb;
208
213
  if (hyperBackup)
209
214
  result.hyperBackup = hyperBackup;
210
215
  if (identityGateway)
@@ -346,7 +351,7 @@ export async function inspectSpk(spkPath, expectedKind) {
346
351
  ? await inspectLoginStyle(dir, info.package, Boolean(portal || executor?.policy.portal), findings)
347
352
  : undefined;
348
353
  if (standalone)
349
- checkSharedFolder(dir, findings, info.package, sharedFolder, executor?.policy.scope === "install-selected", portal, hasExecutor, nativeGateway, info.os_min_ver, installSettings, integrations, metadata.installPorts);
354
+ checkSharedFolder(dir, findings, info.package, sharedFolder, executor?.policy.scope === "install-selected", portal, hasExecutor, nativeGateway, info.os_min_ver, installSettings, integrations, metadata.installPorts, minMemoryMb);
350
355
  const icon = inspectPackageIcons(dir, findings);
351
356
  const cgiEntry = payload.find((entry) => entry.path === CGI_PAYLOAD_PATH);
352
357
  if (standalone && !cgiEntry) {
@@ -363,6 +368,7 @@ export async function inspectSpk(spkPath, expectedKind) {
363
368
  ...(identityGateway ? { identityGateway } : {}),
364
369
  ...(gateway ? { gateway } : {}),
365
370
  ...(installSettings ? { installSettings } : {}),
371
+ ...(minMemoryMb !== undefined ? { minMemoryMb } : {}),
366
372
  ...(hyperBackup ? { hyperBackup } : {}),
367
373
  ...(launch ? { launch } : {}),
368
374
  icon,
@@ -854,8 +860,8 @@ async function inspectUnifiedCompose(dir, payload, metadata, findings) {
854
860
  throw new Error("gateway configuration differs from the declared package contract");
855
861
  if (readOptional(join(dir, "conf/privilege")) !== renderNativePrivilege())
856
862
  throw new Error("Compose hooks must run as the package account");
857
- if (manifest.sharedFolder || metadata.installSettings || metadata.installPorts) {
858
- for (const [name, text] of Object.entries(expectedWizardFiles(info.package, manifest.sharedFolder, false, undefined, metadata.installSettings, [], manifest.identityGateway?.listen.https, metadata.installPorts)))
863
+ if (manifest.sharedFolder || metadata.installSettings || metadata.installPorts || metadata.minMemoryMb !== undefined) {
864
+ for (const [name, text] of Object.entries(expectedWizardFiles(info.package, manifest.sharedFolder, false, undefined, metadata.installSettings, [], manifest.identityGateway?.listen.https, metadata.installPorts, metadata.minMemoryMb)))
859
865
  if (readOptional(join(dir, "WIZARD_UIFILES", name)) !== text)
860
866
  throw new Error(`unexpected WIZARD_UIFILES/${name}; native share selection must match the declaration`);
861
867
  }
@@ -1510,7 +1516,7 @@ function checkBackground(dir, info, payload, findings, executor, daemon, bridge
1510
1516
  * declaration (without one, any present file must be the default native
1511
1517
  * install wizard), and no other install/upgrade wizard file may exist.
1512
1518
  */
1513
- function checkSharedFolder(dir, findings, pkg, folder, selected = false, portal, executor = false, nativeGateway, osMinVer, installSettings, integrations = [], installPortDefinitions = {}) {
1519
+ function checkSharedFolder(dir, findings, pkg, folder, selected = false, portal, executor = false, nativeGateway, osMinVer, installSettings, integrations = [], installPortDefinitions = {}, minMemoryMb) {
1514
1520
  const wizardDir = join(dir, "WIZARD_UIFILES");
1515
1521
  const present = (existsSync(wizardDir) ? readdirSync(wizardDir) : [])
1516
1522
  .filter((name) => /^(install|upgrade)_uifile(_|\.|$)/.test(name))
@@ -1537,7 +1543,7 @@ function checkSharedFolder(dir, findings, pkg, folder, selected = false, portal,
1537
1543
  : {}),
1538
1544
  ...portalManifest(portal),
1539
1545
  };
1540
- const wizards = expectedWizardFiles(pkg, folder, selected, portal, installSettings, integrations, nativeGateway?.listen.https, installPortDefinitions);
1546
+ const wizards = expectedWizardFiles(pkg, folder, selected, portal, installSettings, integrations, nativeGateway?.listen.https, installPortDefinitions, minMemoryMb);
1541
1547
  const source = selected
1542
1548
  ? "the install-selected policy"
1543
1549
  : folder
@@ -1548,7 +1554,7 @@ function checkSharedFolder(dir, findings, pkg, folder, selected = false, portal,
1548
1554
  ? "the integrations declaration"
1549
1555
  : "the native-go default install wizard";
1550
1556
  // The default native wizard is optional; a declared shared folder or portal needs all of its files.
1551
- for (const name of folder || selected || portal || installSettings || Object.keys(installPortDefinitions).length || integrations.length
1557
+ for (const name of folder || selected || portal || installSettings || Object.keys(installPortDefinitions).length || integrations.length || minMemoryMb !== undefined
1552
1558
  ? Object.keys(wizards)
1553
1559
  : present.filter((n) => n in wizards)) {
1554
1560
  if (readOptional(join(wizardDir, name)) !== wizards[name])
@@ -1570,6 +1576,28 @@ function checkSharedFolder(dir, findings, pkg, folder, selected = false, portal,
1570
1576
  }
1571
1577
  }
1572
1578
  }
1579
+ /** Verify and peel only the exact memory prefix, within a canonical App wrapper if present. */
1580
+ function inspectMemoryRequirement(dir, value, findings) {
1581
+ const minMemoryMb = readMinMemoryMb(value, e => findings.push(`${e.code} ${e.message}`));
1582
+ const file = join(dir, "scripts/preinst");
1583
+ const text = readOptional(file);
1584
+ if (minMemoryMb === undefined) {
1585
+ if (text?.includes("[INSTALL_MEMORY_READ_WARNING]"))
1586
+ findings.push("INSTALL_MIN_MEMORY_INVALID memory check has no valid declaration");
1587
+ return undefined;
1588
+ }
1589
+ const prefix = renderMemoryHook(minMemoryMb);
1590
+ const sdk = text && sdkScriptOf("preinst", text)?.sdk;
1591
+ if (!text || !sdk?.startsWith("#!/bin/sh\n" + prefix) || text.split(prefix).length !== 2) {
1592
+ findings.push("INSTALL_MIN_MEMORY_INVALID scripts/preinst lacks the exact declared memory check");
1593
+ }
1594
+ else {
1595
+ writeFileSync(file, text.replace(prefix, ""));
1596
+ }
1597
+ if (readOptional(join(dir, "conf/privilege")) !== renderNativePrivilege())
1598
+ findings.push("INSTALL_MIN_MEMORY_INVALID memory check must run as the package account");
1599
+ return minMemoryMb;
1600
+ }
1573
1601
  /** Validate SDK settings inventory and hook prefix before existing backend inspectors.
1574
1602
  * All reads and temporary rewrites are in the extracted inspection directory. */
1575
1603
  async function inspectInstallSettings(dir, payload, metadata, findings) {
@@ -1629,7 +1657,7 @@ async function inspectInstallSettings(dir, payload, metadata, findings) {
1629
1657
  }
1630
1658
  return settings;
1631
1659
  }
1632
- function expectedWizardFiles(pkg, folder, selected = false, portal, installSettings, integrations = [], settingsPort = 0, installPortDefinitions = {}) {
1660
+ function expectedWizardFiles(pkg, folder, selected = false, portal, installSettings, integrations = [], settingsPort = 0, installPortDefinitions = {}, minMemoryMb) {
1633
1661
  const steps = selected
1634
1662
  ? (t) => [
1635
1663
  ...renderDelegateScopeSteps(t),
@@ -1638,12 +1666,12 @@ function expectedWizardFiles(pkg, folder, selected = false, portal, installSetti
1638
1666
  : folder
1639
1667
  ? sharedFolderInstallSteps(pkg, folder)
1640
1668
  : renderNativeInstallWizard;
1641
- 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)]);
1642
- return {
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);
1670
+ return folderPickerWizardFiles(pkg, folder, {
1643
1671
  ...install.static,
1644
1672
  ...install.dynamic,
1645
- ...renderUpgradeWizardFiles(pkg, folder, integrations),
1646
- };
1673
+ ...renderUpgradeWizardFiles(pkg, folder, integrations, minMemoryMb),
1674
+ });
1647
1675
  }
1648
1676
  function portalManifest(portal) {
1649
1677
  return portal
@@ -0,0 +1,9 @@
1
+ import type { StandaloneError } from "./manifest.js";
2
+ import { type Locale } from "./i18n.js";
3
+ /** MiB of physical MemTotal, not free/available memory or a model allowlist. */
4
+ export declare function readMinMemoryMb(value: unknown, fail: (error: StandaloneError) => void): number | undefined;
5
+ /** Shared by wizard and preinst. A missing, malformed or unreadable read allows installation. */
6
+ export declare function renderMemoryProbe(minMemoryMb: number): string;
7
+ export declare function memoryReason(minMemoryMb: number, locale: Locale, actual: string): string;
8
+ /** Runs in preinst for both install and upgrade, before other SDK or App work, as the package account. */
9
+ export declare function renderMemoryHook(minMemoryMb?: number): string;
@@ -0,0 +1,52 @@
1
+ import { DSM_LANGS, LOCALES } from "./i18n.js";
2
+ import { translator } from "../build-spk/wizard-i18n.js";
3
+ const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
4
+ /** MiB of physical MemTotal, not free/available memory or a model allowlist. */
5
+ export function readMinMemoryMb(value, fail) {
6
+ if (value === undefined)
7
+ return undefined;
8
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1 || value > 2147483647) {
9
+ fail({ code: "INSTALL_MIN_MEMORY_INVALID", message: "install.min_memory_mb must be a positive integer in MiB, at most 2147483647" });
10
+ return undefined;
11
+ }
12
+ return value;
13
+ }
14
+ /** Shared by wizard and preinst. A missing, malformed or unreadable read allows installation. */
15
+ export function renderMemoryProbe(minMemoryMb) {
16
+ return `synopkgland_memory_kb=$(LC_ALL=C awk '
17
+ $1 == "MemTotal:" { count++; if (NF == 3 && $2 ~ /^[0-9]+$/ && $2 > 0 && $3 == "kB") total = $2 }
18
+ END { if (count == 1 && total > 0) printf "%.0f", total; else exit 1 }
19
+ ' /proc/meminfo 2>/dev/null) || synopkgland_memory_kb=
20
+ synopkgland_memory_low=
21
+ if [ -n "$synopkgland_memory_kb" ]; then
22
+ synopkgland_memory_gb=$(LC_ALL=C awk -v kb="$synopkgland_memory_kb" 'BEGIN { printf "%.2f", kb / 1048576 }')
23
+ if LC_ALL=C awk -v kb="$synopkgland_memory_kb" 'BEGIN { exit !(kb < ${minMemoryMb * 1024}) }'; then
24
+ synopkgland_memory_low=1
25
+ fi
26
+ else
27
+ printf '%s\\n' '[INSTALL_MEMORY_READ_WARNING] Cannot read physical MemTotal; continuing installation' >&2
28
+ fi
29
+ `;
30
+ }
31
+ export function memoryReason(minMemoryMb, locale, actual) {
32
+ return translator(locale)("memory.required", { required: String(Math.ceil(minMemoryMb / 1024)), actual });
33
+ }
34
+ /** Runs in preinst for both install and upgrade, before other SDK or App work, as the package account. */
35
+ export function renderMemoryHook(minMemoryMb) {
36
+ if (minMemoryMb === undefined)
37
+ return "";
38
+ const cases = LOCALES.map(locale => ` ${locale}|${DSM_LANGS[locale]}) synopkgland_memory_format=${quote(memoryReason(minMemoryMb, locale, "%s"))} ;;`).join("\n");
39
+ return `${renderMemoryProbe(minMemoryMb)}if [ -n "$synopkgland_memory_low" ]; then
40
+ case "\${SYNOPKG_DSM_LANGUAGE:-enu}" in
41
+ ${cases}
42
+ *) synopkgland_memory_format=${quote(memoryReason(minMemoryMb, "en", "%s"))} ;;
43
+ esac
44
+ synopkgland_memory_message=$(printf "$synopkgland_memory_format" "$synopkgland_memory_gb")
45
+ printf '%s\\n' "$synopkgland_memory_message" >&2
46
+ if [ -n "\${SYNOPKG_TEMP_LOGFILE:-}" ]; then
47
+ printf '%s\\n' "$synopkgland_memory_message" > "$SYNOPKG_TEMP_LOGFILE" || :
48
+ fi
49
+ exit 1
50
+ fi
51
+ `;
52
+ }
@@ -1,4 +1,5 @@
1
1
  import { renderGatewayIngressCheck } from './native-gateway.js';
2
+ import { renderMemoryHook } from './install-memory.js';
2
3
  import { renderSettingsHook } from './install-settings.js';
3
4
  import { renderComposeRetainedData } from "../build-spk/compose-retained-data.js";
4
5
  import { renderNativeGatewayDiagnostic, renderNativeGatewayPortWait, renderNativeGatewayPrepare } from './native-gateway.js';
@@ -24,7 +25,7 @@ export function renderStandaloneScript(name, manifest) {
24
25
  }
25
26
  function renderStandaloneScriptPrefix(name, manifest) {
26
27
  const prepared = ['postinst', 'postupgrade'].includes(name) ? renderNativeGatewayPrepare(manifest) : '';
27
- return renderGatewayIngressCheck(manifest, name) + renderNativeGatewayDiagnostic(manifest, name) + renderNativeGatewayPortWait(manifest, name) + renderSettingsHook(name, manifest) + prepared;
28
+ return (name === 'preinst' ? renderMemoryHook(manifest.minMemoryMb) : '') + renderGatewayIngressCheck(manifest, name) + renderNativeGatewayDiagnostic(manifest, name) + renderNativeGatewayPortWait(manifest, name) + renderSettingsHook(name, manifest) + prepared;
28
29
  }
29
30
  /** Settings inspection peels its hook only at the position build's renderer writes.
30
31
  * The backend inspector then replays the entire remaining lifecycle script. */
@@ -76,7 +77,9 @@ function renderStandaloneScriptInternal(name, manifest) {
76
77
  const paths = `"\${SYNOPKG_PKGDEST:-/var/packages/${manifest.package}/target}" "\${SYNOPKG_PKGVAR:-/var/packages/${manifest.package}/var}"`;
77
78
  const preflight = name === "start-stop-status"
78
79
  ? (!manifest.identityGateway ? `if [ "$1" = restart ]; then\n "$0" stop || exit $?\n exec "$0" start\nfi\n` : "") +
79
- `case "$1" in prestart|start|restart)\n "\${SYNOPKG_PKGDEST:-/var/packages/${manifest.package}/target}/compose/control" preflight || exit $? ;;\nesac\n` +
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`) +
80
83
  (!manifest.identityGateway ? `case "$1" in prestart|prestop) exit 0 ;; esac\n` : "")
81
84
  : "";
82
85
  const remember = name === "postinst" &&
@@ -116,6 +116,8 @@ export interface StandaloneManifest {
116
116
  sharedFolder?: SharedFolder;
117
117
  installSettings?: InstallSettings;
118
118
  installPorts?: true;
119
+ /** `install.min_memory_mb`: minimum physical MemTotal in MiB at install and upgrade. */
120
+ minMemoryMb?: number;
119
121
  /** `backup`: Hyper Backup application backup; on by default for native Apps, absent when opted out. */
120
122
  hyperBackup?: HyperBackup;
121
123
  /** Who may use the app at all; absent keeps the route policy alone. */
@@ -9,6 +9,7 @@ import { readRegistry, registryFile } from '../ctl/registry.js';
9
9
  import { gatewayIngressPathProblem, gatewayIngressOwnershipSupported } from './gateway-ingress.js';
10
10
  import { nativeGatewaySdk } from "./native-gateway.js";
11
11
  import { portDefaults } from "./install-ports.js";
12
+ import { readMinMemoryMb } from "./install-memory.js";
12
13
  import { readPackageDependencies, packageDependencies, dependencyError } from "./package-dependencies.js";
13
14
  import { readInstallSettings } from './install-settings.js';
14
15
  import { auditGoRoutes } from './route-audit.js';
@@ -303,7 +304,10 @@ function readManifest(raw, c) {
303
304
  const sharedFolder = raw.install === undefined
304
305
  ? undefined
305
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.");
306
309
  const installPorts = isRecord(raw.install) && raw.install.ports === true ? true : undefined;
310
+ const minMemoryMb = readMinMemoryMb(isRecord(raw.install) ? raw.install.min_memory_mb : undefined, e => c.fail(e.code, e.message));
307
311
  if (isRecord(raw.install) && raw.install.ports !== undefined && raw.install.ports !== true)
308
312
  c.fail("INSTALL_PORT_INVALID", "install.ports must be true when present");
309
313
  const installSettings = readInstallSettings(isRecord(raw.install) ? raw.install.settings : undefined, e => c.fail(e.code, e.message));
@@ -682,6 +686,7 @@ function readManifest(raw, c) {
682
686
  ...(sharedFolder ? { sharedFolder } : {}),
683
687
  ...(installSettings ? { installSettings } : {}),
684
688
  ...(installPorts ? { installPorts } : {}),
689
+ ...(minMemoryMb !== undefined ? { minMemoryMb } : {}),
685
690
  ...(hyperBackup ? { hyperBackup } : {}),
686
691
  ...(entry ? { entry } : {}),
687
692
  ...(integrations?.length ? { integrations } : {}),
@@ -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. */
@@ -39,7 +40,7 @@ export declare function renderSharedFolderUpgradeWizardFiles(pkg: string, folder
39
40
  * The upgrade wizard: the shared folder choice, then the service callbacks an
40
41
  * administrator re-approves on every upgrade. Empty without either.
41
42
  */
42
- export declare function renderUpgradeWizardFiles(pkg: string, folder: SharedFolder | undefined, integrations?: readonly string[]): Record<string, string>;
43
+ export declare function renderUpgradeWizardFiles(pkg: string, folder: SharedFolder | undefined, integrations?: readonly string[], minMemoryMb?: number): Record<string, string>;
43
44
  /** DSM substitutes wizard values and grants only the declared package account.
44
45
  * On upgrade, omitted values reuse DSM's saved installer variables. */
45
46
  export declare function sharedFolderResource(pkg: string, folder: SharedFolder): Record<string, unknown> | undefined;
@@ -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
- import { integrationWizardSteps } from "../build-spk/install-wizard.js";
6
- const FIELDS = new Set(["mode", "key", "name", "permission"]);
6
+ import { integrationWizardSteps, renderMemoryWizardCheck } from "../build-spk/install-wizard.js";
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}$/;
@@ -16,16 +17,18 @@ export function readSharedFolder(value, fail) {
16
17
  fail({ code: "STANDALONE_SHARED_FOLDER_INVALID", message: `install.sharedFolder ${why}` });
17
18
  return undefined;
18
19
  };
19
- if (!isRecord(value) || Object.keys(value).some((key) => key !== "sharedFolder" && key !== "settings" && key !== "ports")) {
20
- return refuse(": only sharedFolder is allowed.");
20
+ if (!isRecord(value) || Object.keys(value).some((key) => !["sharedFolder", "settings", "ports", "min_memory_mb"].includes(key))) {
21
+ return refuse(": only sharedFolder, settings, ports and min_memory_mb are allowed.");
21
22
  }
22
- if (value.sharedFolder === undefined && (value.settings !== undefined || value.ports !== undefined))
23
+ if (value.sharedFolder === undefined && (value.settings !== undefined || value.ports !== undefined || value.min_memory_mb !== undefined))
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 permission.");
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. */
@@ -151,8 +178,8 @@ export function renderSharedFolderUpgradeWizardFiles(pkg, folder) {
151
178
  * The upgrade wizard: the shared folder choice, then the service callbacks an
152
179
  * administrator re-approves on every upgrade. Empty without either.
153
180
  */
154
- export function renderUpgradeWizardFiles(pkg, folder, integrations = []) {
155
- if (!folder && !integrations.length)
181
+ export function renderUpgradeWizardFiles(pkg, folder, integrations = [], minMemoryMb) {
182
+ if (!folder && !integrations.length && minMemoryMb === undefined)
156
183
  return {};
157
184
  const files = renderWizardFiles("upgrade_uifile", t => [
158
185
  ...(folder ? [sharedFolderStep(t("upgrade.step"), upgradeItems(t, pkg, folder), folder)] : []),
@@ -169,7 +196,20 @@ export function renderUpgradeWizardFiles(pkg, folder, integrations = []) {
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
- files[name] = sharedFolderUpgradeScript(pkg, folder.key, retained, fresh, invalid);
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);
206
+ }
207
+ }
208
+ if (minMemoryMb !== undefined) {
209
+ for (const locale of LOCALES) {
210
+ const name = locale === "en" ? "upgrade_uifile" : `upgrade_uifile_${DSM_LANGS[locale]}`;
211
+ const script = files[name + ".sh"] ?? `#!/bin/sh\n[ -z "\${SYNOPKG_TEMP_LOGFILE:-}" ] || exec > "$SYNOPKG_TEMP_LOGFILE"\ncat <<'SYNOPKGLAND_UPGRADE_WIZARD'\n${files[name]}\nSYNOPKGLAND_UPGRADE_WIZARD\n`;
212
+ files[name + ".sh"] = script.replace("#!/bin/sh\n", () => "#!/bin/sh\n" + renderMemoryWizardCheck(minMemoryMb, locale));
173
213
  }
174
214
  }
175
215
  return files;
@@ -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';
@@ -303,6 +304,7 @@ export async function assembleStandaloneSpk(options) {
303
304
  ...(moduleVersion ? { ui_module: moduleVersion } : {}),
304
305
  ...(manifest.installSettings ? { installSettings: manifest.installSettings } : {}),
305
306
  ...(manifest.installPorts ? { installPorts: portDefaults(manifest) } : {}),
307
+ ...(manifest.minMemoryMb !== undefined ? { minMemoryMb: manifest.minMemoryMb } : {}),
306
308
  ...(backup ? { hyperBackup: backupRecord(backup) } : {}),
307
309
  ...(manifest.integrations ? { integrations: manifest.integrations } : {}),
308
310
  ...(manifest.lifecycleTimeouts ? { lifecycleTimeouts: manifest.lifecycleTimeouts } : {}),
@@ -374,11 +376,13 @@ export async function assembleStandaloneSpk(options) {
374
376
  : folder
375
377
  ? sharedFolderInstallSteps(manifest.package, folder)
376
378
  : renderNativeInstallWizard;
377
- 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)]);
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);
378
380
  writeWizardUiFiles(staging, {
379
- ...install.static,
380
- ...install.dynamic,
381
- ...renderUpgradeWizardFiles(manifest.package, folder, manifest.integrations),
381
+ ...folderPickerWizardFiles(manifest.package, folder, {
382
+ ...install.static,
383
+ ...install.dynamic,
384
+ ...renderUpgradeWizardFiles(manifest.package, folder, manifest.integrations, manifest.minMemoryMb),
385
+ }),
382
386
  ...renderUninstallWizardFiles(manifest.package, "native", {
383
387
  composeData: manifest.compose?.plan.app_data,
384
388
  executor: Boolean(options.executor),
@@ -0,0 +1,20 @@
1
+ # Minimum physical memory
2
+
3
+ Declare a physical RAM requirement in `dsm-package.yaml`:
4
+
5
+ ```yaml
6
+ install:
7
+ min_memory_mb: 1700
8
+ ```
9
+
10
+ `min_memory_mb` is a positive integer threshold in **MiB** (1–2147483647), measured against `/proc/meminfo` **MemTotal** on the NAS at installation time. It measures physical memory visible to DSM, independently of free memory, swap, model names and the package server's architecture filters. RAM upgrades are detected automatically.
11
+
12
+ MemTotal excludes firmware and kernel reservations. Set the threshold to approximately **85% of the nominal capacity** when all machines of that capacity should work: use **1700 MiB for 2 GB NAS machines**, rather than 2048 MiB. Check the intended hardware's MemTotal before choosing a threshold. The requirement label rounds the threshold up to a whole GB (1700 MiB displays as 2 GB); the detected capacity uses two decimal places. Both use DSM's 1024-based convention, so displayed GB means 1024 MiB. The exact threshold, rather than the rounded label, controls admission.
13
+
14
+ The existing dynamic install and upgrade wizards read MemTotal on the NAS. Below the threshold they show a localized memory page in every supported wizard language, with a read-only field that always fails validation and `invalid_next_disabled_v2` to disable Next on DSM flows that honor it. Static fallback wizards retain their usual pages because they cannot know the NAS memory. CLI installation, wizard bypasses and DSM flows that do not honor wizard validation remain covered by preinst.
15
+
16
+ The generated **package-account preinst** checks the same threshold before other SDK work and the App's preinst hook, for **both installation and upgrade**. A low-memory result exits nonzero and writes the same localized reason to `SYNOPKG_TEMP_LOGFILE` for Package Center. Upgrade admission uses the incoming package's requirement even if an earlier version installed successfully. No root helper or runtime/start check is added.
17
+
18
+ An unreadable, missing or malformed MemTotal emits `INSTALL_MEMORY_READ_WARNING` to stderr and **allows installation**. This requirement stops clearly undersized machines; it does not reject an unfamiliar memory-reporting environment. Omitting the field preserves the existing installation behavior. `synopkgland inspect <spk> --json` reports `minMemoryMb` and verifies the generated memory check and wizard files against the packaged declaration.
19
+
20
+ See Synology's [wizard contract](https://help.synology.com/developer-guide/synology_package/wizard/WIZARD_UIFILES_v2.html) for dynamic wizard scripts and the `SYNOPKG_TEMP_LOGFILE` output channel.
@@ -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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synopackageland/cli",
3
- "version": "0.52.11",
3
+ "version": "0.52.14",
4
4
  "description": "Syno Package Land Developer Kit CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -22,7 +22,8 @@
22
22
  "skills",
23
23
  "docs/shared-folders.md",
24
24
  "docs/daemon-nofile.md",
25
- "docs/compose-admin.md"
25
+ "docs/compose-admin.md",
26
+ "docs/install-memory.md"
26
27
  ],
27
28
  "scripts": {
28
29
  "check:docs": "node --test scripts/check-doc-versions.test.mjs && node scripts/check-doc-versions.mjs",
@@ -7,6 +7,21 @@
7
7
  "required": ["schema"],
8
8
  "properties": {
9
9
  "schema": {"type": "integer", "const": 2},
10
+ "install": {
11
+ "type": "object",
12
+ "properties": {
13
+ "min_memory_mb": {
14
+ "type": "integer",
15
+ "minimum": 1,
16
+ "maximum": 2147483647,
17
+ "description": "Minimum physical /proc/meminfo MemTotal in MiB, checked dynamically on install and upgrade as the package account. Allow for firmware reservations: use about 85% of nominal RAM (1700 for a 2 GB NAS). Read failures warn and allow installation. No runtime check."
18
+ },
19
+ "sharedFolder": {"type": "object"},
20
+ "settings": {"type": "object"},
21
+ "ports": {"const": true}
22
+ },
23
+ "additionalProperties": false
24
+ },
10
25
  "ui_secret_ignores": {
11
26
  "description": "False-positive exceptions for public UI secret scanning. Exact paths relative to ui/; omit a module snapshot hash (app/help.json). Source maps cannot be ignored.",
12
27
  "type": "array",
package/skills/SKILL.md CHANGED
@@ -40,6 +40,8 @@ Query published releases with `npm view @synopackageland/cli version`,
40
40
  `npm view @synopackageland/templates version` and `npm view @synopackageland/sdk version`;
41
41
  keep the installed dependency tree and generated pins consistent.
42
42
 
43
+ For Apps with a physical RAM requirement, set `install.min_memory_mb` (MemTotal in MiB; use 1700 for 2 GB machines). The generated install/upgrade wizards and package-account preinst check it dynamically; read failures warn and allow installation, with no runtime check. See [minimum physical memory](../docs/install-memory.md).
44
+
43
45
  For Apps with data folders or gateway listeners, read [reference/install.md](reference/install.md). Default to an App-named dedicated DSM data share and installer-selected ports. Existing-folder access, port number format/range and required HTTPS origins use localized wizard validation before Next; detected port conflicts are nonblocking inline warnings, and an unavailable DSM port inventory does not block installation; upgrades retain port selections.
44
46
 
45
47
  For private native `<audio>` / `<video>` playback and seeking, read
@@ -6,6 +6,7 @@ Use matching CLI, SDK/App and templates releases, preserving the pins generated
6
6
 
7
7
  ```yaml
8
8
  install:
9
+ min_memory_mb: 1700
9
10
  ports: true
10
11
  sharedFolder:
11
12
  mode: dedicated
@@ -17,6 +18,8 @@ identity_gateway:
17
18
  listen: {https: 28443}
18
19
  ```
19
20
 
21
+ Use `install.min_memory_mb` for a physical RAM requirement checked dynamically on the NAS during install and upgrade. The value is MemTotal in MiB, so allow for firmware reservations: 1700 MiB admits 2 GB machines. All wizard locales show a low-memory page; package-account preinst enforces the same threshold through Package Center. Unreadable MemTotal warns and allows installation; no runtime check is added. See [minimum physical memory](../../docs/install-memory.md).
22
+
20
23
  For every App needing shared data, name the dedicated share after the package. The wizard defaults to that name, keeps it when the share list loads, and reuses the matching share if it exists. It also accepts a supported existing share. `mode: select` starts empty and requires an explicit choice; `mode: create` has no picker. Selecting a folder authorizes DSM's `data-share` worker to grant the declared RO/RW to the package account on install, upgrade/repair and starts. No pre-existing account or permission grant is required. Validation checks the name, existence and supported local mounted folder type, never package-account access. Local tiered/S2S shares are accepted; remote/C2, tiering buckets, WORM, unmounted, unavailable, moving, external and forced-read-only shares are refused. Runtime kernel checks still report the share, required access and recovery action when permission is revoked. No App root or ACL writer is generated.
21
24
 
22
25
  The upgrade wizard prefills and submits the recorded folder without a separate change checkbox. Keep the dedicated name rather than clearing it. CLI automation uses `--param media=Media` on install and `--param CHANGE_media=true --param media=OtherMedia` to change it on upgrade/repair. Explicitly submit the saved folder when migrating older installations without saved DSM installer values.