import type { BundleManifest } from "../contracts/core.js"; import { type PlatformSpec } from "./platform.js"; export interface InstallCheck { name: string; ok: boolean; detail: string; remedy?: string; } export interface InstallSource { /** مجلد حزمة مفكوك، أو أرشيف ‎.zip‎. */ path: string; isArchive: boolean; } export declare function classifySource(path: string): InstallSource; /** يقرأ البيان من أرشيف بلا فكّه — نحتاجه للتحقّق من المنصّة قبل أي كتابة. */ export declare function manifestFromArchive(file: string): Promise; /** * AR: منفذ تحتاجه خدمة، وهل هو حرّ. **قائمة لا رقمًا واحدًا**: الجهاز خدمتان، وفحص منفذ النواة وحده * كان يمرّر تثبيتًا يفشل بعد الهجرات عند تشغيل خدمة البثّ — أي بعد الكتابة، فيتراجع كل شيء * برسالة «الخدمات لم تبدأ» لا تسمّي المنفذ المتعارض. الفحص قبل الكتابة يجب أن يشمل ما يُحتاج * فعلًا، لا أشهره. * EN: A port a service needs, and whether it is free. **A list, not a single number**: the appliance * has two services, and checking the core's port alone let an install proceed that then failed * after the migrations, when the live service started — that is, after writing, so everything * rolled back under a "the services did not start" message that named no port. A pre-write check * must cover what is actually needed, not what is best known. */ export interface RequiredPort { label: string; port: number; free: boolean; /** العَلَم الذي يغيّر هذا المنفذ. يُذكَر في العلاج فيعرف القارئ ماذا يكتب لا أن «يحرّر منفذًا». */ flag: string; } export interface PreInstallInput { source: InstallSource; root: string; ports: RequiredPort[]; /** هل تعمل هذه العملية بصلاحيات مسؤول؟ يقرّر إن كان ‎PATH‎ سيُسجَّل أصلًا. */ elevated: boolean; expectedSha256?: string; } /** * AR: هل نملك صلاحيات المسؤول؟ الدليل عمليّ لا نظريّ: نحاول فتح مفتاح سِجل لا يُفتَح للكتابة إلّا * بها. سؤال ويندوز عن «الدور» يكذب تحت UAC، والمحاولة تصدق. * EN: Do we hold administrator rights? The evidence is practical rather than declared: we try to open * a registry key that only opens for writing with them. Asking Windows about the "role" lies under * UAC; attempting the thing tells the truth. */ export declare function hasAdminRights(): Promise; /** * الفحوص قبل الكتابة. تُعيد قائمة، والأمر يرفض إن كان فيها فشل واحد. */ export declare function preInstallChecks(input: PreInstallInput): Promise; /** يفكّ أرشيف حزمة إلى الجذر، رافضًا أي مدخل يخرج منه. */ export declare function extractBundle(archive: string, root: string): Promise; /** * AR: ينسخ مجلد حزمة مفكوك، **مُكوِّنًا مُكوِّنًا لا شجرةً واحدة**، و‎data/‎ لا يُنسَخ إطلاقًا. * * كان هذا نداءً واحدًا على الجذر كلّه. وقد فشل فشلًا صامتًا حين تكون الوجهة تحوي ‎data/‎ عامرًا: * العملية تموت بلا استثناء يُلتقَط وبلا سطر في السجلّ، ولا يُنسَخ بايت — بينما النسخ إلى مجلد * فارغ ينجح، والنسخ مُكوِّنًا مُكوِّنًا إلى الوجهة **نفسها** ينجح. (قِيس على ويندوز أثناء ٠١٨؛ * السبب الجذري لم يُحسَم — عملية النسخ الضخمة قد تكون أوقفها دفاعٌ على الجهاز — لكن الشكل الذي * يعمل معلوم ومُثبَت.) * * وللشكل الجديد فائدتان تتجاوزان تفادي العطب: * ١ — **‎data/‎ يُستثنى صراحةً** بدل الاتّكال على أن دمج مجلد فارغ فوق مكتبة العميل غير مؤذٍ. * القاعدة الرابعة تصير سطرًا في الشيفرة لا نتيجةً عرَضية. * ٢ — الفشل يُنسَب إلى مكوّنه، فيقول الخطأ **أيّ** جزء تعذّر بدل «تعذّر النسخ». * EN: Copies an extracted bundle directory, **component by component rather than as one tree**, and * `data/` is never copied at all. * * This used to be a single call on the whole root. It failed silently when the destination held a * populated `data/`: the process died with no catchable exception and no log line, and not one * byte was copied — while copying into an empty directory succeeded, and copying component by * component into the **same** destination succeeded. (Measured on Windows during 018; the root * cause is unresolved — a security product may have stopped the bulk write — but the shape that * works is known and proven.) * * The new shape earns two things beyond avoiding the fault: * 1 — **`data/` is excluded explicitly** rather than relying on merging an empty directory over a * customer's library being harmless. Rule IV becomes a line of code, not an incidental * outcome. * 2 — A failure names its component, so the error says **which** part could not be copied instead * of "the copy failed". */ export declare function copyBundle(source: string, root: string): void; /** * AR: ما الذي ينقص شجرةً كي تُعدّ حزمةً مكتملة؟ **سؤال المُثبِّت، فانتقل معه** (٠٢٦). * * كانت هذه القائمة في خطّ الإنتاج (‎packaging/pipeline.ts‎) لأن الباني كان يقرأها ليتحقّق ممّا * أنتج. وقد افترق المستودعان: الباني في مستودع المنتج، والمُثبِّت هنا. وموضعها الصحيح **حيث * يُقرأ الجواب لا حيث يُكتب**: الحزمة تُبنى مرّةً وتُقرأ على أجهزةٍ كثيرة لسنوات. * * وتُفحَص بعد الفكّ وقبل تشغيل أيّ خدمة، فأرشيفٌ وصل ناقصًا يُوقف التثبيت ويُتراجَع عنه بدل * أن يُنتج جهازًا نصف مركَّب يفشل عند أول مشاهد. * EN: What must a tree contain before it counts as a complete bundle? **The installer's question, so * it travelled with the installer** (026). * * This list used to live in the production pipeline (`packaging/pipeline.ts`), because the * builder read it to verify what it had produced. The repositories have since separated: the * builder lives in the product repository and the installer here. Its right home is **where the * answer is read, not where it is written**: a bundle is built once and read on many machines * for years. * * It runs after extraction and before any service starts, so an archive that arrived incomplete * stops the install and is rolled back, rather than producing a half-assembled appliance that * fails in front of the first viewer. */ /** * AR: **يمنح بتّ التنفيذ لما لا يعمل بدونه — بعد كل فكّ، على المنصّات التي تعرف البتّ.** * * الأرشيف لا يحمله إلينا، وهذا مقيس لا مفترَض: كل مدخل في ‎Fantastic-0.27.0-win-x64.zip‎ * يسجّل الوضع ‎0o666‎ لأن ‎archiver‎ ينسخ ما يقوله ويندوز، و‎yauzl‎ الذي نفكّ به لا يطبّق * الأوضاع أصلًا. فحتى أرشيفٌ بُني على لينكس بأوضاعٍ صحيحة يصل مفكوكًا بلا بتّ. * * **وبدونه لا رسالة مفهومة.** ‎runtime/node‎ بلا بتّ تنفيذ يعطي ‎EACCES: permission denied‎ * عند أوّل ‎spawn‎ — خطأٌ يقرؤه الفنّي «ليست لي صلاحية» فيعيد بـ‎sudo‎ ويحصل على الشيء نفسه، * ولا شيء يقول إن المشكلة في وضع ملفّ. * * والقائمة من جدول المنصّات لا من مسحٍ للشجرة: ما يُنفَّذ معروفٌ بالاسم، ومنحُ ‎0755‎ لكل ما * في الحزمة توسيعٌ لصلاحيات ‎24‎ ألف ملفّ مقابل ستّة. * EN: **Grants the executable bit to what does not work without it — after every extraction, on the * platforms that have such a bit.** * * The archive does not carry it to us, and that is measured rather than assumed: every entry in * `Fantastic-0.27.0-win-x64.zip` records mode `0o666`, because `archiver` copies what Windows * reports, and `yauzl`, which we extract with, applies no modes at all. So even an archive built * on Linux with correct modes arrives extracted without the bit. * * **And without it there is no intelligible message.** A `runtime/node` with no executable bit * gives `EACCES: permission denied` at the first `spawn` — an error the technician reads as "I * lack rights", retries under `sudo`, and gets the same thing, with nothing saying the problem is * a file's mode. * * The list comes from the platform table rather than a sweep of the tree: what executes is known * by name, and granting `0755` to everything in the bundle would widen permissions on 24,000 * files to reach six. */ export declare function applyExecutableBits(root: string, spec?: PlatformSpec): string[]; export declare function verifyInstalled(root: string, spec?: PlatformSpec): string[]; /** ما لا تعمل الشجرة بدونه، نسبةً إلى الجذر. **قائمةٌ واحدة** لفحص المركَّب وفحص المُجهَّز. */ export declare function requiredFiles(spec?: PlatformSpec): string[]; /** * AR: يفحص الشجرة **كما ستصير بعد التبديل، قبل أن يقع** — وقبل أن تُوقَف خدمة. * * كل مطلوبٍ يقع تحت مُدخَلٍ سيُستبدَل يُطلَب من المجهَّز، وما عداه من الجذر القائم. بدون هذا كان * أرشيفٌ لا يحمل ‎supervisor/‎ — حزمةٌ منشورةٌ قديمة يختارها الرجوع — يُنزَّل ويُفكّ، **ثم تُوقَف * الخدمات ويُبدَّل**، ثم يسقط عند ‎verifyInstalled‎ فيتراجع كلّ شيء: جهازٌ كان يعمل أُطفئ * دقائق من أجل حزمةٍ لا تُركَّب. والقاعدة المكتوبة في ‎update.ts‎: التحقّق يسبق الإيقاف. * EN: Checks the tree **as it will be after the swap, before it happens** — and before a service is * stopped. * * Every required file under an entry that will be replaced is asked of the staged tree, and the * rest of the root as it stands. Without this, an archive carrying no `supervisor/` — an old * published bundle a rollback picks — was downloaded and unpacked, **then the services stopped * and the swap done**, then failed at `verifyInstalled` and rolled everything back: a working * appliance down for minutes for a bundle that cannot be installed. The rule written in * `update.ts`: verification precedes the stop. */ export declare function verifyStaged(staging: string, root: string, replaced: readonly string[], spec?: PlatformSpec): string[]; /** * التراجع: يزيل ما كُتب ويترك ‎data/‎ كما كان. * * يُستدعى عند أي فشل **قبل** بدء الخدمات، فتعود الآلة إلى حالتها السابقة بدل أن تبقى نصف مثبَّتة. */ /** * AR: **التراجع لا يُفشِل نفسه، ولا يحجب سبب الفشل الذي استدعاه.** * * كان يرمي عند أوّل ملفّ متعذّر، وهو يجري داخل ‎catch‎ الأصلي — فيحلّ خطؤه محلّ الخطأ الحقيقي: * يقرأ الفنّي «‎EBUSY … fantastic.db‎» ولا يعرف شيئًا عمّا فشل أصلًا. والأسوأ أن الحلقة تتوقّف * عند ذلك الملفّ، فتبقى الشجرة **نصف محذوفة**: بعض المكوّنات ذهب وبعضها بقي — وهي الحالة التي * وُجد التراجع ليمنعها. * وسبب ‎EBUSY‎ معروف ومتوقَّع: عملية بدأت للتوّ ثم تعثّر إقلاعها ما تزال تمسك قاعدة البيانات * لحظاتٍ بعد قتلها. إعادة المحاولة تكفي، وما يبقى متعذّرًا يُبلَّغ عنه ولا يُخفى. * EN: **The rollback neither fails itself nor hides the failure that summoned it.** * * It used to throw on the first stubborn file, and it runs inside the original `catch` — so its * error replaced the real one: the technician reads "EBUSY … fantastic.db" and learns nothing * about what actually failed. Worse, the loop stopped at that file, leaving the tree **half * deleted**: some components gone, others left — precisely the state a rollback exists to prevent. * And the cause of that EBUSY is known and expected: a process that had just started and then * failed to come up still holds the database for a moment after being killed. Retrying is enough, * and whatever remains is reported rather than concealed. */ export declare function rollbackInstall(root: string, dataExistedBefore: boolean): string[]; export interface RemovalPlan { removed: string[]; kept: string[]; } /** ما تُزيله الإزالة وما تُبقيه. ‎data/‎ يبقى ما لم يُطلَب حذفه صراحةً. */ export declare function planRemoval(root: string, purge: boolean): RemovalPlan; /** * AR: ينفّذ الخطة ويعيد ما تعذّر حذفه. **لا يتوقّف عند أول عثرة**: التوقّف يترك الشجرة نصف محذوفة — * الشيمة والواجهة ذهبتا والخدمات باقية — وهي حالة لا يستطيع الفنّي أن يصلحها بأمر، لأن الأمر * الذي يصلحها هو ما حُذف للتوّ. يُحذَف ما يمكن، ويُسمَّى ما بقي، فيبقى القرار بيد قارئٍ يعرف. * EN: Applies the plan and returns whatever could not be deleted. **It does not stop at the first * stumble**: stopping leaves the tree half removed — the shim and the CLI gone, the services still * there — a state the technician cannot repair with a command, because the command that would * repair it is the one just deleted. What can go, goes; what remains is named, leaving the * decision with a reader who knows. */ export declare function applyRemoval(root: string, plan: RemovalPlan): string[]; /** حجم شجرة للتقرير. */ export declare function sizeOf(root: string): number; //# sourceMappingURL=install.d.ts.map