deboa 1.0.0
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/LICENSE +21 -0
- package/README.md +178 -0
- package/dist/cjs/classes/Deboa.js +490 -0
- package/dist/cjs/classes/DeboaFromFile.js +66 -0
- package/dist/cjs/index.js +28 -0
- package/dist/cjs/types/IAddTarEntriesParams.js +4 -0
- package/dist/cjs/types/IControlFileOptions.js +4 -0
- package/dist/cjs/types/IDeboa.js +4 -0
- package/dist/cjs/types/IDeboaFromFile.js +4 -0
- package/dist/cjs/types/INormalizeOptionsLength.js +4 -0
- package/dist/cjs/types/IWriteFileFromLinesArgs.js +4 -0
- package/dist/cjs/types/IWriteToArchive.js +4 -0
- package/dist/cjs/types/MaintainerScript.js +4 -0
- package/dist/cjs/types/Priority.js +4 -0
- package/dist/cjs/types/Section.js +4 -0
- package/dist/cjs/types/classes/Deboa.d.ts +44 -0
- package/dist/cjs/types/classes/DeboaFromFile.d.ts +23 -0
- package/dist/cjs/types/index.d.ts +4 -0
- package/dist/cjs/types/index.js +25 -0
- package/dist/cjs/types/types/IAddTarEntriesParams.d.ts +5 -0
- package/dist/cjs/types/types/IControlFileOptions.d.ts +130 -0
- package/dist/cjs/types/types/IDeboa.d.ts +123 -0
- package/dist/cjs/types/types/IDeboaFromFile.d.ts +8 -0
- package/dist/cjs/types/types/INormalizeOptionsLength.d.ts +8 -0
- package/dist/cjs/types/types/IWriteFileFromLinesArgs.d.ts +10 -0
- package/dist/cjs/types/types/IWriteToArchive.d.ts +19 -0
- package/dist/cjs/types/types/MaintainerScript.d.ts +1 -0
- package/dist/cjs/types/types/Priority.d.ts +1 -0
- package/dist/cjs/types/types/Section.d.ts +1 -0
- package/dist/cjs/types/types/index.d.ts +10 -0
- package/dist/cjs/types/utils/addTarEntries.d.ts +5 -0
- package/dist/cjs/types/utils/createFileHeader.d.ts +2 -0
- package/dist/cjs/types/utils/writeFileFromLines.d.ts +5 -0
- package/dist/cjs/types/utils/writeToArchive.d.ts +5 -0
- package/dist/cjs/utils/addTarEntries.js +25 -0
- package/dist/cjs/utils/createFileHeader.js +61 -0
- package/dist/cjs/utils/writeFileFromLines.js +13 -0
- package/dist/cjs/utils/writeToArchive.js +78 -0
- package/dist/esm/classes/Deboa.js +439 -0
- package/dist/esm/classes/DeboaFromFile.js +55 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/types/IAddTarEntriesParams.js +1 -0
- package/dist/esm/types/IControlFileOptions.js +1 -0
- package/dist/esm/types/IDeboa.js +1 -0
- package/dist/esm/types/IDeboaFromFile.js +1 -0
- package/dist/esm/types/INormalizeOptionsLength.js +1 -0
- package/dist/esm/types/IWriteFileFromLinesArgs.js +4 -0
- package/dist/esm/types/IWriteToArchive.js +1 -0
- package/dist/esm/types/MaintainerScript.js +1 -0
- package/dist/esm/types/Priority.js +1 -0
- package/dist/esm/types/Section.js +1 -0
- package/dist/esm/types/classes/Deboa.d.ts +44 -0
- package/dist/esm/types/classes/DeboaFromFile.d.ts +23 -0
- package/dist/esm/types/index.d.ts +4 -0
- package/dist/esm/types/index.js +10 -0
- package/dist/esm/types/types/IAddTarEntriesParams.d.ts +5 -0
- package/dist/esm/types/types/IControlFileOptions.d.ts +130 -0
- package/dist/esm/types/types/IDeboa.d.ts +123 -0
- package/dist/esm/types/types/IDeboaFromFile.d.ts +8 -0
- package/dist/esm/types/types/INormalizeOptionsLength.d.ts +8 -0
- package/dist/esm/types/types/IWriteFileFromLinesArgs.d.ts +10 -0
- package/dist/esm/types/types/IWriteToArchive.d.ts +19 -0
- package/dist/esm/types/types/MaintainerScript.d.ts +1 -0
- package/dist/esm/types/types/Priority.d.ts +1 -0
- package/dist/esm/types/types/Section.d.ts +1 -0
- package/dist/esm/types/types/index.d.ts +10 -0
- package/dist/esm/types/utils/addTarEntries.d.ts +5 -0
- package/dist/esm/types/utils/createFileHeader.d.ts +2 -0
- package/dist/esm/types/utils/writeFileFromLines.d.ts +5 -0
- package/dist/esm/types/utils/writeToArchive.d.ts +5 -0
- package/dist/esm/utils/addTarEntries.js +19 -0
- package/dist/esm/utils/createFileHeader.js +53 -0
- package/dist/esm/utils/writeFileFromLines.js +7 -0
- package/dist/esm/utils/writeToArchive.js +72 -0
- package/package.json +57 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Some useful references:
|
|
3
|
+
*
|
|
4
|
+
* https://radagast.ca/linux/anatomy_of_a_deb_file.html
|
|
5
|
+
* https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ar.html
|
|
6
|
+
* https://www.unix.com/man-page/opensolaris/3head/ar.h/
|
|
7
|
+
*/
|
|
8
|
+
import type { IDeboa } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* @return IDeboa
|
|
11
|
+
*/
|
|
12
|
+
declare class Deboa implements IDeboa {
|
|
13
|
+
#private;
|
|
14
|
+
/** See {@link IDeboa.additionalTarEntries} */
|
|
15
|
+
additionalTarEntries: IDeboa['additionalTarEntries'];
|
|
16
|
+
/** See {@link IDeboa.beforeCreateDesktopEntry} */
|
|
17
|
+
beforeCreateDesktopEntry: IDeboa['beforeCreateDesktopEntry'];
|
|
18
|
+
/** See {@link IDeboa.beforePackage} */
|
|
19
|
+
beforePackage: IDeboa['beforePackage'];
|
|
20
|
+
/** See {@link IDeboa.controlFileOptions} */
|
|
21
|
+
controlFileOptions: IDeboa['controlFileOptions'];
|
|
22
|
+
/** See {@link IDeboa.icon} */
|
|
23
|
+
icon: IDeboa['icon'];
|
|
24
|
+
/** See {@link IDeboa.modifyTarHeader} */
|
|
25
|
+
modifyTarHeader: IDeboa['modifyTarHeader'];
|
|
26
|
+
/** See {@link IDeboa.sourceDir} */
|
|
27
|
+
sourceDir: IDeboa['sourceDir'];
|
|
28
|
+
/** See {@link IDeboa.tarballFormat} */
|
|
29
|
+
tarballFormat: IDeboa['tarballFormat'];
|
|
30
|
+
/** See {@link IDeboa.targetDir} */
|
|
31
|
+
targetDir: IDeboa['targetDir'];
|
|
32
|
+
constructor(options: IDeboa);
|
|
33
|
+
/**
|
|
34
|
+
* Creates the .deb file.
|
|
35
|
+
* @return {Promise<string>} outputFile - Absolute path to the generated .deb
|
|
36
|
+
*/
|
|
37
|
+
package(): Promise<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Checks if the values provided to the hook options are file paths
|
|
40
|
+
* and imports the actual functions from them if necessary.
|
|
41
|
+
*/
|
|
42
|
+
loadHooks(): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
export { Deboa };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { ReadStream } from 'fs';
|
|
3
|
+
import type { IWriteToArchive, IDeboaFromFile } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* @return IDeboaFromFile
|
|
6
|
+
*/
|
|
7
|
+
export declare class DeboaFromFile implements IDeboaFromFile {
|
|
8
|
+
#private;
|
|
9
|
+
isARFile: IDeboaFromFile['isARFile'];
|
|
10
|
+
outputFile: IDeboaFromFile['outputFile'];
|
|
11
|
+
writeStream: IWriteToArchive['writeStream'];
|
|
12
|
+
constructor(options: IDeboaFromFile);
|
|
13
|
+
/**
|
|
14
|
+
* Creates a ReadStream from the input file.
|
|
15
|
+
* Useful if you need access to the underlying stream.
|
|
16
|
+
*/
|
|
17
|
+
createReadStream(inputFile: string): Promise<ReadStream>;
|
|
18
|
+
writeFromStream(readStream: ReadStream): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Writes the input file to the .deb.
|
|
21
|
+
*/
|
|
22
|
+
writeFromFile(inputFile: string): Promise<void>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './IAddTarEntriesParams';
|
|
2
|
+
export * from './IControlFileOptions';
|
|
3
|
+
export * from './IDeboa';
|
|
4
|
+
export * from './IDeboaFromFile';
|
|
5
|
+
export * from './INormalizeOptionsLength';
|
|
6
|
+
export * from './IWriteFileFromLinesArgs';
|
|
7
|
+
export * from './IWriteToArchive';
|
|
8
|
+
export * from './MaintainerScript';
|
|
9
|
+
export * from './Priority';
|
|
10
|
+
export * from './Section';
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { MaintainerScript } from './MaintainerScript';
|
|
2
|
+
import { Priority } from './Priority';
|
|
3
|
+
import { Section } from './Section';
|
|
4
|
+
/**
|
|
5
|
+
* The descriptions are mostly just shameless copies from the following docs:
|
|
6
|
+
*
|
|
7
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-controlfields.html}
|
|
8
|
+
*
|
|
9
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html}
|
|
10
|
+
*
|
|
11
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-relationships.html}
|
|
12
|
+
*/
|
|
13
|
+
export interface IControlFileOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Target architecture. Defaults to the current system's architecture.
|
|
16
|
+
*
|
|
17
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-architecture}
|
|
18
|
+
*/
|
|
19
|
+
architecture?: string;
|
|
20
|
+
/**
|
|
21
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-relationships.html#s-built-using}
|
|
22
|
+
*/
|
|
23
|
+
builtUsing?: string;
|
|
24
|
+
/**
|
|
25
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-relationships.html}
|
|
26
|
+
*/
|
|
27
|
+
conflicts?: string[];
|
|
28
|
+
/**
|
|
29
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-relationships.html}
|
|
30
|
+
*/
|
|
31
|
+
depends?: string[];
|
|
32
|
+
/**
|
|
33
|
+
* If set to `yes`, then the package management system will refuse to
|
|
34
|
+
* remove
|
|
35
|
+
* the package (upgrading and replacing it is still possible). The other
|
|
36
|
+
* possible value is `no`, which is the same as not having the field at
|
|
37
|
+
* all.
|
|
38
|
+
*
|
|
39
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-essential}
|
|
40
|
+
*/
|
|
41
|
+
essential?: 'yes' | 'no';
|
|
42
|
+
/**
|
|
43
|
+
* Extended description for the package. Defaults to the value provided for
|
|
44
|
+
* the `shortDescription` option.
|
|
45
|
+
*
|
|
46
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-description}
|
|
47
|
+
*/
|
|
48
|
+
extendedDescription?: string;
|
|
49
|
+
/**
|
|
50
|
+
* URL for this package.
|
|
51
|
+
*
|
|
52
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-homepage}
|
|
53
|
+
*/
|
|
54
|
+
homepage?: string;
|
|
55
|
+
/**
|
|
56
|
+
* The package maintainer's name and email address. The name must come
|
|
57
|
+
* first, then the email address inside angle brackets. **This field is
|
|
58
|
+
* mandatory.**
|
|
59
|
+
*
|
|
60
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-maintainer}
|
|
61
|
+
*/
|
|
62
|
+
maintainer: string;
|
|
63
|
+
/**
|
|
64
|
+
* Path to the scripts you want to execute before/after the system
|
|
65
|
+
* installs/upgrades/removes your package. There are quite a few rules
|
|
66
|
+
* here,
|
|
67
|
+
* so please check
|
|
68
|
+
* {@link
|
|
69
|
+
* https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html} for
|
|
70
|
+
* details.
|
|
71
|
+
*/
|
|
72
|
+
maintainerScripts?: Partial<Record<MaintainerScript, string>>;
|
|
73
|
+
/**
|
|
74
|
+
* Binary package name. Must be at least two characters long and must start
|
|
75
|
+
* with an alphanumeric character. Only lower case letters (a-z), digits
|
|
76
|
+
* (0-9), plus (+) and minus (-) signs, and periods (.) are allowed. **This
|
|
77
|
+
* field is mandatory.**
|
|
78
|
+
*
|
|
79
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-source}
|
|
80
|
+
*/
|
|
81
|
+
packageName: string;
|
|
82
|
+
/**
|
|
83
|
+
* See {@link
|
|
84
|
+
* https://www.debian.org/doc/debian-policy/ch-relationships.html} for
|
|
85
|
+
* details.
|
|
86
|
+
*/
|
|
87
|
+
preDepends?: string[];
|
|
88
|
+
/**
|
|
89
|
+
* This field represents how important it is that the user have the package
|
|
90
|
+
* installed. Defaults to `optional`.
|
|
91
|
+
*
|
|
92
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-priority}
|
|
93
|
+
*/
|
|
94
|
+
priority?: Priority;
|
|
95
|
+
/**
|
|
96
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-relationships.html}
|
|
97
|
+
*/
|
|
98
|
+
recommends?: string[];
|
|
99
|
+
/**
|
|
100
|
+
* This field specifies an application area into which the package has been
|
|
101
|
+
* classified. This is a recommended field.
|
|
102
|
+
*
|
|
103
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-section}
|
|
104
|
+
*/
|
|
105
|
+
section?: Section;
|
|
106
|
+
/**
|
|
107
|
+
* Short, single-line synopsys for the package. Usually ~80 characters.
|
|
108
|
+
* **This field is mandatory.**
|
|
109
|
+
*
|
|
110
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-description}
|
|
111
|
+
*/
|
|
112
|
+
shortDescription: string;
|
|
113
|
+
/**
|
|
114
|
+
* Source package name.
|
|
115
|
+
*
|
|
116
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-source}
|
|
117
|
+
*/
|
|
118
|
+
source?: string;
|
|
119
|
+
/**
|
|
120
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-relationships.html}
|
|
121
|
+
*/
|
|
122
|
+
suggests?: string[];
|
|
123
|
+
/**
|
|
124
|
+
* Version number of the package in the
|
|
125
|
+
* `[epoch:]upstream_version[-debian_revision]` format. See
|
|
126
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-version}
|
|
127
|
+
* for details. **This field is mandatory.**
|
|
128
|
+
*/
|
|
129
|
+
version: string;
|
|
130
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { Headers as TarFSHeader } from 'tar-fs';
|
|
2
|
+
import type { Headers as TarStreamHeader } from 'tar-stream';
|
|
3
|
+
import { IControlFileOptions } from './IControlFileOptions';
|
|
4
|
+
/**
|
|
5
|
+
* @property {IDeboa["additionalTarEntries"]} [additionalTarEntries] -
|
|
6
|
+
* Additional entries to be added to the .tar archive. This is useful for
|
|
7
|
+
* creating symlinks on Windows. See the [Headers]{@link TarStreamHeader}
|
|
8
|
+
* interface from tar-stream for more details. Optional.
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* @property {IDeboa["beforeCreateDesktopEntry"]} [beforeCreateDesktopEntry] -
|
|
12
|
+
* Runs before the desktop entry file is created, allowing you to add more
|
|
13
|
+
* entries or modify the default entries if necessary. This can be a function
|
|
14
|
+
* or a path to a file that has a function as its default export. Check
|
|
15
|
+
* {@link https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html}
|
|
16
|
+
* for more details. Optional.
|
|
17
|
+
*
|
|
18
|
+
*
|
|
19
|
+
* @property {IDeboa["beforePackage"]} [beforePackage] -
|
|
20
|
+
* Runs after the control file, maintainer scripts and sourceDir contents
|
|
21
|
+
* are copied to the temporary directory and before they're packaged. Receives
|
|
22
|
+
* the temporary directory path as an argument. This can be a function or a
|
|
23
|
+
* path to a file that has a function as its default export. Optional.
|
|
24
|
+
*
|
|
25
|
+
*
|
|
26
|
+
* @property {IDeboa["controlFileOptions"]} controlFileOptions -
|
|
27
|
+
* Control file fields.
|
|
28
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-controlfields.html}
|
|
29
|
+
*
|
|
30
|
+
*
|
|
31
|
+
* @property {IDeboa["icon"]} [icon] -
|
|
32
|
+
* Path to the image you want to use as your app icon. It is copied to
|
|
33
|
+
* /usr/share/pixmaps. Optional.
|
|
34
|
+
*
|
|
35
|
+
*
|
|
36
|
+
* @property {IDeboa["modifyTarHeader"]} [modifyTarHeader] -
|
|
37
|
+
* This callback makes it possible to modify file headers before they're
|
|
38
|
+
* written to the .tar archive, which is useful for setting permissions.
|
|
39
|
+
* This can be a function or a path to a file that has a function as its
|
|
40
|
+
* default export. See the [Headers]{@link TarFSHeader} interface from tar-fs
|
|
41
|
+
* and {@link https://github.com/mafintosh/tar-fs/blob/7ec11cb27f93948193770f32b4d820e2e7195715/README.md}
|
|
42
|
+
* for more details. Optional.
|
|
43
|
+
*
|
|
44
|
+
*
|
|
45
|
+
* @property {IDeboa["sourceDir"]} sourceDir -
|
|
46
|
+
* Location of the files you want to package. **This field is mandatory.**
|
|
47
|
+
*
|
|
48
|
+
*
|
|
49
|
+
* @property {IDeboa["tarballFormat"]} [tarballFormat] -
|
|
50
|
+
* Sets the format used for storing the files. This impacts the build time
|
|
51
|
+
* and .deb output size. Defaults to `tar.gz`.
|
|
52
|
+
*
|
|
53
|
+
* As a rule of thumb, you can expect the following from each format:
|
|
54
|
+
* - `tar` (no compression): lowest resources usage, faster build time, largest .deb size
|
|
55
|
+
* - `tar.gz` (gzip compression using zlib): low resources usage, good build time, good .deb size
|
|
56
|
+
* - `tar.xz` (xz compression using lzma-native): high resources usage, slowest build time, smallest .deb size
|
|
57
|
+
*
|
|
58
|
+
*
|
|
59
|
+
* @property {IDeboa["targetDir"]} targetDir -
|
|
60
|
+
* Directory where your .deb file will be copied to.
|
|
61
|
+
* **This field is mandatory.**
|
|
62
|
+
*/
|
|
63
|
+
export interface IDeboa {
|
|
64
|
+
/**
|
|
65
|
+
* Additional entries to be added to the .tar archive. This is useful for
|
|
66
|
+
* creating symlinks on Windows. See the [Headers]{@link TarStreamHeader}
|
|
67
|
+
* interface from tar-stream for more details. Optional.
|
|
68
|
+
*/
|
|
69
|
+
additionalTarEntries?: TarStreamHeader[];
|
|
70
|
+
/**
|
|
71
|
+
* Runs before the desktop entry file is created, allowing you to add more
|
|
72
|
+
* entries or modify the default entries if necessary. This can be a function
|
|
73
|
+
* or a path to a file that has a function as its default export. Check
|
|
74
|
+
* {@link https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html}
|
|
75
|
+
* for more details. Optional.
|
|
76
|
+
*/
|
|
77
|
+
beforeCreateDesktopEntry?: string | (<T extends Record<string, string>>(desktopEntries: T) => Promise<T> | T);
|
|
78
|
+
/**
|
|
79
|
+
* Runs after the control file, maintainer scripts and sourceDir contents
|
|
80
|
+
* are copied to the temporary directory and before they're packaged. Receives
|
|
81
|
+
* the temporary directory path as an argument. This can be a function or a
|
|
82
|
+
* path to a file that has a function as its default export. Optional.
|
|
83
|
+
*/
|
|
84
|
+
beforePackage?: string | ((tempDir: string) => Promise<void> | void);
|
|
85
|
+
/**
|
|
86
|
+
* Control file fields.
|
|
87
|
+
* {@link https://www.debian.org/doc/debian-policy/ch-controlfields.html}
|
|
88
|
+
*/
|
|
89
|
+
controlFileOptions: IControlFileOptions;
|
|
90
|
+
/**
|
|
91
|
+
* Path to the image you want to use as your app icon. It is copied to
|
|
92
|
+
* /usr/share/pixmaps. Optional.
|
|
93
|
+
*/
|
|
94
|
+
icon?: string;
|
|
95
|
+
/**
|
|
96
|
+
* This callback makes it possible to modify file headers before they're
|
|
97
|
+
* written to the .tar archive, which is useful for setting permissions.
|
|
98
|
+
* This can be a function or a path to a file that has a function as its
|
|
99
|
+
* default export. See the [Headers]{@link TarFSHeader} interface from tar-fs
|
|
100
|
+
* and {@link https://github.com/mafintosh/tar-fs/blob/7ec11cb27f93948193770f32b4d820e2e7195715/README.md}
|
|
101
|
+
* for more details. Optional.
|
|
102
|
+
*/
|
|
103
|
+
modifyTarHeader?: string | ((header: TarFSHeader) => TarFSHeader);
|
|
104
|
+
/**
|
|
105
|
+
* Location of the files you want to package. **This field is mandatory.**
|
|
106
|
+
*/
|
|
107
|
+
sourceDir: string;
|
|
108
|
+
/**
|
|
109
|
+
* Sets the format used for storing the files. This impacts the build time
|
|
110
|
+
* and .deb output size. Defaults to `tar.gz`.
|
|
111
|
+
*
|
|
112
|
+
* As a rule of thumb, you can expect the following from each format:
|
|
113
|
+
* - `tar` (no compression): lowest resources usage, faster build time, largest .deb size
|
|
114
|
+
* - `tar.gz` (gzip compression using zlib): low resources usage, good build time, good .deb size
|
|
115
|
+
* - `tar.xz` (xz compression using lzma-native): high resources usage, slowest build time, smallest .deb size
|
|
116
|
+
*/
|
|
117
|
+
tarballFormat?: 'tar' | 'tar.gz' | 'tar.xz';
|
|
118
|
+
/**
|
|
119
|
+
* Directory where your .deb file will be copied to.
|
|
120
|
+
* **This field is mandatory.**
|
|
121
|
+
*/
|
|
122
|
+
targetDir: string;
|
|
123
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @property {string} filePath - Path to the output file.
|
|
3
|
+
* @property {string[]} lines - Lines to be written.
|
|
4
|
+
*/
|
|
5
|
+
export interface IWriteFileFromLinesArgs {
|
|
6
|
+
/** Path to the output file. */
|
|
7
|
+
filePath: string;
|
|
8
|
+
/** Lines to be written. */
|
|
9
|
+
lines: string[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import type { ReadStream, WriteStream } from 'fs';
|
|
4
|
+
/**
|
|
5
|
+
* @property {Buffer} header - AR header.
|
|
6
|
+
* @property {boolean} [isARFile] - If true, the .deb-specific sections won't be added to the file.
|
|
7
|
+
* @property {readStream} readStream - ReadStream from the input file.
|
|
8
|
+
* @property {WriteStream} writeStream - WriteStream to the output file.
|
|
9
|
+
*/
|
|
10
|
+
export interface IWriteToArchive {
|
|
11
|
+
/** AR header. */
|
|
12
|
+
header: Buffer;
|
|
13
|
+
/** If true, the .deb-specific sections won't be added to the file. */
|
|
14
|
+
isARFile?: boolean;
|
|
15
|
+
/** ReadStream from the input file. */
|
|
16
|
+
readStream: ReadStream;
|
|
17
|
+
/** WriteStream to the output file. */
|
|
18
|
+
writeStream: WriteStream;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type MaintainerScript = 'preinst' | 'postinst' | 'prerm' | 'postrm';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type Priority = 'required' | 'important' | 'standard' | 'optional';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type Section = 'admin' | 'cli-mono' | 'comm' | 'database' | 'debug' | 'devel' | 'doc' | 'editors' | 'education' | 'electronics' | 'embedded' | 'fonts' | 'games' | 'gnome' | 'gnu-r' | 'gnustep' | 'graphics' | 'hamradio' | 'haskell' | 'httpd' | 'interpreters' | 'introspection' | 'java' | 'javascript' | 'kde' | 'kernel' | 'libdevel' | 'libs' | 'lisp' | 'localization' | 'mail' | 'math' | 'metapackages' | 'misc' | 'net' | 'news' | 'ocaml' | 'oldlibs' | 'otherosfs' | 'perl' | 'php' | 'python' | 'ruby' | 'rust' | 'science' | 'shells' | 'sound' | 'tasks' | 'tex' | 'text' | 'utils' | 'vcs' | 'video' | 'web' | 'x11' | 'xfce' | 'zope' | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './IAddTarEntriesParams';
|
|
2
|
+
export * from './IControlFileOptions';
|
|
3
|
+
export * from './IDeboa';
|
|
4
|
+
export * from './IDeboaFromFile';
|
|
5
|
+
export * from './INormalizeOptionsLength';
|
|
6
|
+
export * from './IWriteFileFromLinesArgs';
|
|
7
|
+
export * from './IWriteToArchive';
|
|
8
|
+
export * from './MaintainerScript';
|
|
9
|
+
export * from './Priority';
|
|
10
|
+
export * from './Section';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds entries to the .tar archive after all the files are packed.
|
|
3
|
+
*/ export async function addTarEntries({ entries , pack }) {
|
|
4
|
+
const entriesCopy = entries.slice();
|
|
5
|
+
return new Promise((resolve, reject)=>{
|
|
6
|
+
function packEntry(err) {
|
|
7
|
+
if (err) {
|
|
8
|
+
reject(err);
|
|
9
|
+
}
|
|
10
|
+
if (entriesCopy.length === 0) {
|
|
11
|
+
return resolve();
|
|
12
|
+
}
|
|
13
|
+
const entry = entriesCopy.shift();
|
|
14
|
+
pack.entry(entry, packEntry);
|
|
15
|
+
}
|
|
16
|
+
packEntry();
|
|
17
|
+
pack.on('error', reject);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export function createFileHeader(options) {
|
|
2
|
+
const { fileName , ...numericOptions } = options;
|
|
3
|
+
const { timestamp =String(Math.trunc(new Date().getTime() / 1000)) , ownerID ='0' , groupID ='0' , fileMode ='100644' , fileSize , } = numericOptions;
|
|
4
|
+
if (!fileName) {
|
|
5
|
+
throw new Error('filename is required');
|
|
6
|
+
}
|
|
7
|
+
const maxLengthMap = {
|
|
8
|
+
fileName: {
|
|
9
|
+
maxLength: 16,
|
|
10
|
+
value: fileName
|
|
11
|
+
},
|
|
12
|
+
timestamp: {
|
|
13
|
+
maxLength: 12,
|
|
14
|
+
value: String(timestamp)
|
|
15
|
+
},
|
|
16
|
+
ownerID: {
|
|
17
|
+
maxLength: 6,
|
|
18
|
+
value: String(ownerID)
|
|
19
|
+
},
|
|
20
|
+
groupID: {
|
|
21
|
+
maxLength: 6,
|
|
22
|
+
value: String(groupID)
|
|
23
|
+
},
|
|
24
|
+
fileMode: {
|
|
25
|
+
maxLength: 8,
|
|
26
|
+
value: String(fileMode)
|
|
27
|
+
},
|
|
28
|
+
fileSize: {
|
|
29
|
+
maxLength: 10,
|
|
30
|
+
value: String(fileSize)
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const paddedFields = Object.entries(maxLengthMap).map(([optionName, { maxLength , value }])=>{
|
|
34
|
+
// checks if the numeric options are correct
|
|
35
|
+
if (optionName in numericOptions) {
|
|
36
|
+
const asNumber = +value;
|
|
37
|
+
if (Number.isNaN(asNumber)) {
|
|
38
|
+
throw new Error(`The \`${optionName}\` option must be a numeric value`);
|
|
39
|
+
}
|
|
40
|
+
if (!Number.isInteger(asNumber)) {
|
|
41
|
+
throw new Error(`The \`${optionName}\` option must be a integer`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// checks if the option length is correct
|
|
45
|
+
if (value.length > maxLength) {
|
|
46
|
+
throw new Error(`The \`${optionName}\` option must be at most ${maxLength} characters`);
|
|
47
|
+
}
|
|
48
|
+
return value.padEnd(maxLength);
|
|
49
|
+
});
|
|
50
|
+
// ending sequence
|
|
51
|
+
paddedFields.push('`\n');
|
|
52
|
+
return paddedFields.join('');
|
|
53
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { createFileHeader } from './createFileHeader';
|
|
2
|
+
/**
|
|
3
|
+
* Writes the .ar archive signature. If it's a .deb file,
|
|
4
|
+
* also writes the `debian-control` file and its header.
|
|
5
|
+
*/ async function writeArchiveHeader({ writeStream , isARFile =false }) {
|
|
6
|
+
return new Promise((resolve, reject)=>{
|
|
7
|
+
const arArchiveSignature = '!<arch>\n';
|
|
8
|
+
const header = [
|
|
9
|
+
arArchiveSignature
|
|
10
|
+
];
|
|
11
|
+
// this part is .deb-specific, so we don't need it in plain .ar files
|
|
12
|
+
if (!isARFile) {
|
|
13
|
+
const debianBinaryFile = '2.0\n';
|
|
14
|
+
const debianBinaryIdentifier = createFileHeader({
|
|
15
|
+
fileName: 'debian-binary',
|
|
16
|
+
fileSize: debianBinaryFile.length
|
|
17
|
+
});
|
|
18
|
+
header.push(debianBinaryIdentifier, debianBinaryFile);
|
|
19
|
+
}
|
|
20
|
+
writeStream.write(Buffer.concat(header.map(Buffer.from)), (headerErr)=>{
|
|
21
|
+
if (headerErr) {
|
|
22
|
+
reject(`Error writing the archive header: ${headerErr}`);
|
|
23
|
+
}
|
|
24
|
+
resolve();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
*/ export async function writeToArchive({ header , isARFile =false , readStream , writeStream }) {
|
|
31
|
+
const shouldWriteArchiveHeader = writeStream.bytesWritten === 0;
|
|
32
|
+
if (shouldWriteArchiveHeader) {
|
|
33
|
+
console.log('Writing the archive header...\n');
|
|
34
|
+
await writeArchiveHeader({
|
|
35
|
+
writeStream,
|
|
36
|
+
isARFile
|
|
37
|
+
});
|
|
38
|
+
console.log('Archive header successfully written\n');
|
|
39
|
+
}
|
|
40
|
+
return new Promise((resolve, reject)=>{
|
|
41
|
+
const fileNameIdentifier = header.toString('utf-8').slice(0, 16).trim();
|
|
42
|
+
writeStream.write(header, (identifierErr)=>{
|
|
43
|
+
console.log(`Writing the identifier header for ${fileNameIdentifier}...\n`);
|
|
44
|
+
if (identifierErr) {
|
|
45
|
+
reject(`Error writing the identifier header for ${fileNameIdentifier}: ${identifierErr}`);
|
|
46
|
+
}
|
|
47
|
+
console.log(`Identifier header for ${fileNameIdentifier} successfully written\n`);
|
|
48
|
+
const initialBytesWritten = writeStream.bytesWritten;
|
|
49
|
+
console.log(`Writing file ${fileNameIdentifier}...\n`);
|
|
50
|
+
readStream.on('error', (fileError)=>reject(`Error writing file ${fileNameIdentifier}: ${fileError}`));
|
|
51
|
+
readStream.pipe(writeStream, {
|
|
52
|
+
end: false
|
|
53
|
+
});
|
|
54
|
+
readStream.on('end', ()=>{
|
|
55
|
+
const readStreamSize = writeStream.bytesWritten - initialBytesWritten;
|
|
56
|
+
const shouldWritePaddingByte = readStreamSize % 2 !== 0;
|
|
57
|
+
if (!shouldWritePaddingByte) {
|
|
58
|
+
console.log(`File ${fileNameIdentifier} successfully written\n`);
|
|
59
|
+
return resolve();
|
|
60
|
+
}
|
|
61
|
+
console.log(`Writing padding byte for ${fileNameIdentifier}...\n`);
|
|
62
|
+
writeStream.write(Buffer.from('\n'), (paddingError)=>{
|
|
63
|
+
if (paddingError) {
|
|
64
|
+
reject(`Error writing padding byte for ${fileNameIdentifier}: ${identifierErr}`);
|
|
65
|
+
}
|
|
66
|
+
console.log(`File ${fileNameIdentifier} successfully written\n`);
|
|
67
|
+
return resolve();
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|