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,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "DeboaFromFile", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>DeboaFromFile
|
|
8
|
+
});
|
|
9
|
+
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
10
|
+
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
11
|
+
const _createFileHeader = require("../utils/createFileHeader");
|
|
12
|
+
const _writeToArchive = require("../utils/writeToArchive");
|
|
13
|
+
function _interopRequireDefault(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
class DeboaFromFile {
|
|
19
|
+
#header = null;
|
|
20
|
+
isARFile = false;
|
|
21
|
+
outputFile = null;
|
|
22
|
+
writeStream = null;
|
|
23
|
+
constructor(options){
|
|
24
|
+
const { outputFile , isARFile } = options;
|
|
25
|
+
this.isARFile = isARFile;
|
|
26
|
+
this.outputFile = outputFile;
|
|
27
|
+
this.writeStream = _fs.default.createWriteStream(outputFile, {
|
|
28
|
+
encoding: 'binary'
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Creates a ReadStream from the input file.
|
|
33
|
+
* Useful if you need access to the underlying stream.
|
|
34
|
+
*/ async createReadStream(inputFile) {
|
|
35
|
+
if (this.#header !== null) {
|
|
36
|
+
throw new Error('You can only have one ReadStream at a time.');
|
|
37
|
+
}
|
|
38
|
+
const readStream = _fs.default.createReadStream(inputFile, {
|
|
39
|
+
encoding: 'binary'
|
|
40
|
+
});
|
|
41
|
+
const stats = await _fs.default.promises.lstat(inputFile);
|
|
42
|
+
this.#header = (0, _createFileHeader.createFileHeader)({
|
|
43
|
+
fileName: _path.default.basename(inputFile),
|
|
44
|
+
fileSize: stats.size
|
|
45
|
+
});
|
|
46
|
+
return readStream;
|
|
47
|
+
}
|
|
48
|
+
async writeFromStream(readStream) {
|
|
49
|
+
if (this.#header === null) {
|
|
50
|
+
throw new Error('Missing header, please create the ReadStream using the `createReadStream` method.');
|
|
51
|
+
}
|
|
52
|
+
await (0, _writeToArchive.writeToArchive)({
|
|
53
|
+
header: Buffer.from(this.#header),
|
|
54
|
+
isARFile: this.isARFile,
|
|
55
|
+
readStream,
|
|
56
|
+
writeStream: this.writeStream
|
|
57
|
+
});
|
|
58
|
+
this.#header = null;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Writes the input file to the .deb.
|
|
62
|
+
*/ async writeFromFile(inputFile) {
|
|
63
|
+
const readStream = await this.createReadStream(inputFile);
|
|
64
|
+
return this.writeFromStream(readStream);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
Deboa: ()=>_deboa.Deboa,
|
|
13
|
+
DeboaFromFile: ()=>_deboaFromFile.DeboaFromFile
|
|
14
|
+
});
|
|
15
|
+
const _deboa = require("./classes/Deboa");
|
|
16
|
+
const _deboaFromFile = require("./classes/DeboaFromFile");
|
|
17
|
+
_exportStar(require("./types"), exports);
|
|
18
|
+
function _exportStar(from, to) {
|
|
19
|
+
Object.keys(from).forEach(function(k) {
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function() {
|
|
23
|
+
return from[k];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return from;
|
|
28
|
+
}
|
|
@@ -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,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_exportStar(require("./IAddTarEntriesParams"), exports);
|
|
6
|
+
_exportStar(require("./IControlFileOptions"), exports);
|
|
7
|
+
_exportStar(require("./IDeboa"), exports);
|
|
8
|
+
_exportStar(require("./IDeboaFromFile"), exports);
|
|
9
|
+
_exportStar(require("./INormalizeOptionsLength"), exports);
|
|
10
|
+
_exportStar(require("./IWriteFileFromLinesArgs"), exports);
|
|
11
|
+
_exportStar(require("./IWriteToArchive"), exports);
|
|
12
|
+
_exportStar(require("./MaintainerScript"), exports);
|
|
13
|
+
_exportStar(require("./Priority"), exports);
|
|
14
|
+
_exportStar(require("./Section"), exports);
|
|
15
|
+
function _exportStar(from, to) {
|
|
16
|
+
Object.keys(from).forEach(function(k) {
|
|
17
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return from[k];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
return from;
|
|
25
|
+
}
|
|
@@ -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,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "addTarEntries", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>addTarEntries
|
|
8
|
+
});
|
|
9
|
+
async function addTarEntries({ entries , pack }) {
|
|
10
|
+
const entriesCopy = entries.slice();
|
|
11
|
+
return new Promise((resolve, reject)=>{
|
|
12
|
+
function packEntry(err) {
|
|
13
|
+
if (err) {
|
|
14
|
+
reject(err);
|
|
15
|
+
}
|
|
16
|
+
if (entriesCopy.length === 0) {
|
|
17
|
+
return resolve();
|
|
18
|
+
}
|
|
19
|
+
const entry = entriesCopy.shift();
|
|
20
|
+
pack.entry(entry, packEntry);
|
|
21
|
+
}
|
|
22
|
+
packEntry();
|
|
23
|
+
pack.on('error', reject);
|
|
24
|
+
});
|
|
25
|
+
}
|