Skip to content

Commit

Permalink
feat: option to specify compression used for pack:deb (#1110) (#1241)
Browse files Browse the repository at this point in the history
* feat: option to specify compression used for pack:deb (#1110)

This enables passing options to override what dpkg-deb uses by default,
which is zstd on newer versions of Debian/Ubuntu and xz on older
versions. Debian 11 can't read zstd so when building on newer Debian
base for older, specifying may be necessary.

This should aid in the resolution of heroku/cli#2240.

Co-authored-by: Mike Donnalley <mdonnalley@salesforce.com>

* fix: use Flags.option

* test: gzip test for pack deb

* fix: no -Z option

* test: debugging

* test: debugging

* test: debugging

---------

Co-authored-by: Colin Dean <colindean@users.noreply.github.com>
  • Loading branch information
mdonnalley and colindean committed Jan 10, 2024
1 parent e781906 commit 03619e4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -232,6 +232,8 @@ USAGE
FLAGS
-r, --root=<value> (required) [default: .] path to oclif CLI root
-t, --tarball=<value> optionally specify a path to a tarball already generated by NPM
-Z, --compression=<value> optionally override compression, see output of
'dpkg-deb --help' in the -Z description for valid options.
DESCRIPTION
pack CLI into debian package
Expand Down
17 changes: 13 additions & 4 deletions src/commands/pack/deb.ts
Expand Up @@ -52,13 +52,21 @@ APT::FTPArchive::Release {
}

export default class PackDeb extends Command {
static description = 'pack CLI into debian package'
static description = 'Pack CLI into debian package.'

static flags = {
root: Flags.string({char: 'r', default: '.', description: 'path to oclif CLI root', required: true}),
compression: Flags.option({
options: ['gzip', 'none', 'xz', 'zstd'] as const,
})({
char: 'z',
description:
'For more details see the `-Zcompress-type` section at https://man7.org/linux/man-pages/man1/dpkg-deb.1.html',
summary: 'Override the default compression used by dpkg-deb.',
}),
root: Flags.string({char: 'r', default: '.', description: 'Path to oclif CLI root.', required: true}),
tarball: Flags.string({
char: 't',
description: 'optionally specify a path to a tarball already generated by NPM',
description: 'Optionally specify a path to a tarball already generated by NPM.',
required: false,
}),
}
Expand Down Expand Up @@ -107,7 +115,8 @@ export default class PackDeb extends Command {
)
await exec(`sudo chown -R root "${workspace}"`)
await exec(`sudo chgrp -R root "${workspace}"`)
await exec(`dpkg --build "${workspace}" "${path.join(dist, versionedDebBase)}"`)
const dpkgDeb = flags.compression ? `dpkg-deb --build "-Z${flags.compression}"` : 'dpkg-deb --build'
await exec(`${dpkgDeb} "${workspace}" "${path.join(dist, versionedDebBase)}"`)
this.log(`finished building debian / ${arch}`)
}

Expand Down

0 comments on commit 03619e4

Please sign in to comment.