Packaging
This extension helps you work with package definition files for
package repositories.
It currently supports only a single type of package repository: the
Arch User Repository (AUR).
Screenshots
PKGBUILD (AUR)
PKGBUILD file without this extension |
PKGBUILD file with this extension |
|
|
ShellCheck findings are mostly irrelevant. |
Only see ShellCheck diagnostics that matter. |
customizepkg
Features
PKGBUILD (AUR) features
The Packaging extension supports user-contributed
PKGBUILD files in the
AUR.
For PKGBUILD
files opened in VS Code, this extension enables
linting through the
ShellCheck
extension.
By default, however, ShellCheck emits a number of unhelpful warnings
that are false alarms in the context of PKGBUILD
files. To remove
those false alarms, this extension configures the ShellCheck
extension in the following ways:
Sets Bash as the shell.
Disables rule SC2034
(“foo appears unused. Verify it or export it.”)
Disables rule SC2154
(“var is referenced but not assigned.”)
Disables rule SC2164
(“Use cd ... || exit
in case cd
fails.”)
Will not affect regular shell scripts, only PKGBUILD
s
Pacman *.install files
The Packaging extension adds syntax highlighting to Pacman *.install
files.
It also sets Bash as the shell, removing an unnecessary Shellcheck
warning.
customizepkg syntax highlighting
The Packaging extension provides syntax highlighting for
customizepkg-git
AUR
patch files.
For details and examples about customizepkg
, see
customizepkg on GitHub.
Prerequisites
This extension depends on the
ShellCheck extension,
maintained by Felipe Santos.
Usually, VS Code will take care of this dependency for you.
When in doubt, you can reinstall the ShellCheck extension to get the
latest version. You should have to do that only once though, if
ever.
FAQ
Q. Why does this extension set Bash as the shell?
A. makepkg
, the program that sources PKGBUILD
s, runs in Bash.
The same goes for Pacman *.install
files.
Q. Why does this extension disable rule SC2164 for PKGBUILD
s?
A. makepkg
first configures shopt -o -s errexit
, which is
roughly equivalent to set -e
, before it calls into
PKGBUILD
’s functions. ShellCheck doesn’t know this, and
still reports SC2164 violations, but those are unhelpful false
alarms in that context.
Q. Why does this extension disable rule SC2034 for PKGBUILD
s?
A. There are
more than a dozen PKGBUILD variables.
ShellCheck emits SC2034
violations for every single one of
them, because it can’t tell that makepkg
will consume those
variables after it sources the PKGBUILD
. So those are
unhelpful false alarms.
Disabling rule SC2034 incurs some collateral damage, but due to
limitations in ShellCheck itself,
this is probably the best we can do for now.
Q. Why does this extension disable rule SC2154 for PKGBUILD
s?
A. Similarly to SC2034, ShellCheck emits SC2154
violations for
variables like srcdir
and pkgdir
, because it can’t tell
that makepkg
always pre-initializes those variables before it
calls into PKGBUILD
functions. Hence, these are false alarms,
too.
Just like SC2034, disabling rule SC2154 will also suppress
some legitimate ShellCheck warnings but we can’t do anything
about it unless someone introduces
the missing feature
to ShellCheck proper.
Acknowledgements
A shout-out to these amazing people:
License
Copyright (c) 2022–2024 Claudia Pellegrino
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
For a copy of the License, see LICENSE.txt.