File tree Expand file tree Collapse file tree 16 files changed +568
-0
lines changed
Expand file tree Collapse file tree 16 files changed +568
-0
lines changed Original file line number Diff line number Diff line change 1+ # ** ` apk ` Module**
2+
3+ The ` apk ` module offers pseudo-declarative package and repository management using [ ` apk ` ] ( https://github.com/alpinelinux/apk-tools ) .
4+
5+ ## Features
6+
7+ This module is capable of:
8+
9+ - Package Management
10+ - Installing packages
11+ - Removing packages
12+
13+ ## Package Management
14+
15+ ### Installing
16+
17+ ``` yaml
18+ type : apk
19+ install :
20+ packages :
21+ - package-1
22+ - package-2
23+ ` ` `
24+
25+ ### Removing Packages
26+
27+ ` ` ` yaml
28+ type : apk
29+ remove :
30+ packages :
31+ - package-1
32+ - package-2
33+ ` ` `
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env nu
2+
3+ # Remove packages.
4+ def remove_pkgs [remove : record ]: nothing -> nothing {
5+ let remove = $remove
6+ | default [] packages
7+
8+ let remove_list = $remove.packages
9+ | str trim
10+
11+ if ($remove.packages | is-not-empty ) {
12+ print $' (ansi green )Removing packages:(ansi reset )'
13+ $remove_list
14+ | each {
15+ print $' - (ansi cyan )($in )(ansi reset )'
16+ }
17+
18+ try {
19+ ^ apk remove ... ($remove_list )
20+ } catch {|err |
21+ return (error make {
22+ msg : $" Failed to remove packages\n ($err.msg )"
23+ })
24+ }
25+ }
26+ }
27+
28+ # Install packages.
29+ #
30+ # You can specify a list of packages to install, and you can
31+ # specify a list of packages for a specific repo to install.
32+ def install_pkgs [install : record ]: nothing -> nothing {
33+ let install = $install
34+ | default [] packages
35+
36+ # Gather lists of the various ways a package is installed
37+ # to report back to the user.
38+ let install_list = $install.packages
39+ | str trim
40+
41+ if ($install_list | is-not-empty ) {
42+ print $' (ansi green )Installing packages:(ansi reset )'
43+ $install_list
44+ | each {
45+ print $' - (ansi cyan )($in )(ansi reset )'
46+ }
47+ try {
48+ ^ apk add ... ($install_list )
49+ } catch {|err |
50+ return (error make {
51+ msg : $" Failed to install packages\n ($err.msg )"
52+ })
53+ }
54+ }
55+ }
56+
57+ def main [config : string ]: nothing -> nothing {
58+ let config = $config
59+ | from json
60+ | default {} remove
61+ | default {} install
62+
63+ remove_pkgs $config.remove
64+ install_pkgs $config.install
65+ }
Original file line number Diff line number Diff line change 1+ import "@typespec/json-schema" ;
2+ using TypeSpec .JsonSchema ;
3+
4+ @ jsonSchema ("/modules/apk-latest.json" )
5+ model ApkModuleLatest {
6+ ... ApkModuleV1 ;
7+ }
8+
9+ @ jsonSchema ("/modules/apk-v1.json" )
10+ model ApkModuleV1 {
11+ /**
12+ * The apk module offers pseudo-declarative package and repository management using apk.
13+ * https://blue-build.org/reference/modules/apk/
14+ */
15+ type : "apk" | "apk@v1" | "apk@latest" ;
16+
17+ /** Configuration of packages removal. */
18+ remove ? : Remove ;
19+
20+ /** Configuration of packages install. */
21+ install ? : Install ;
22+ }
23+
24+ model Install {
25+ /** List of packages to install. */
26+ packages : Array <string >;
27+ }
28+
29+ model Remove {
30+ /** List of packages to remove. */
31+ packages : Array <string >;
32+ }
Original file line number Diff line number Diff line change 1+ name : apk
2+ shortdesc : The apk module offers pseudo-declarative package and repository management using apt.
3+ example : |
4+ type: apk
5+ install:
6+ packages:
7+ - git
8+ remove:
9+ packages:
10+ - firefox
11+ - firefox-langpacks
Original file line number Diff line number Diff line change 1+ # ** ` apt ` Module**
2+
3+ The ` apt ` module offers pseudo-declarative package and repository management using [ ` apt ` ] ( https://salsa.debian.org/apt-team/apt ) .
4+
5+ ## Features
6+
7+ This module is capable of:
8+
9+ - Package Management
10+ - Installing packages
11+ - Removing packages
12+
13+ ## Package Management
14+
15+ ### Installing
16+
17+ ``` yaml
18+ type : apt
19+ install :
20+ packages :
21+ - package-1
22+ - package-2
23+ ` ` `
24+
25+ ### Removing Packages
26+
27+ ` ` ` yaml
28+ type : apt
29+ remove :
30+ packages :
31+ - package-1
32+ - package-2
33+ ` ` `
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env nu
2+
3+ # Remove packages.
4+ def remove_pkgs [remove : record ]: nothing -> nothing {
5+ let remove = $remove
6+ | default [] packages
7+
8+ let remove_list = $remove.packages
9+ | str trim
10+
11+ if ($remove.packages | is-not-empty ) {
12+ print $' (ansi green )Removing packages:(ansi reset )'
13+ $remove_list
14+ | each {
15+ print $' - (ansi cyan )($in )(ansi reset )'
16+ }
17+
18+ try {
19+ ^ apt-get - y remove ... ($remove_list )
20+ } catch {|err |
21+ return (error make {
22+ msg : $" Failed to remove packages\n ($err.msg )"
23+ })
24+ }
25+ }
26+ }
27+
28+ # Install packages.
29+ #
30+ # You can specify a list of packages to install, and you can
31+ # specify a list of packages for a specific repo to install.
32+ def install_pkgs [install : record ]: nothing -> nothing {
33+ let install = $install
34+ | default [] packages
35+
36+ # Gather lists of the various ways a package is installed
37+ # to report back to the user.
38+ let install_list = $install.packages
39+ | str trim
40+
41+ if ($install_list | is-not-empty ) {
42+ print $' (ansi green )Installing packages:(ansi reset )'
43+ $install_list
44+ | each {
45+ print $' - (ansi cyan )($in )(ansi reset )'
46+ }
47+ try {
48+ ^ apt-get - y install ... ($install_list )
49+ } catch {|err |
50+ return (error make {
51+ msg : $" Failed to install packages\n ($err.msg )"
52+ })
53+ }
54+ }
55+ }
56+
57+ def main [config : string ]: nothing -> nothing {
58+ let config = $config
59+ | from json
60+ | default {} remove
61+ | default {} install
62+
63+ $env .DEBIAN_FRONTEND = ' noninteractive'
64+
65+ ^ apt-get update
66+
67+ remove_pkgs $config.remove
68+ install_pkgs $config.install
69+ }
Original file line number Diff line number Diff line change 1+ import "@typespec/json-schema" ;
2+ using TypeSpec .JsonSchema ;
3+
4+ @ jsonSchema ("/modules/apt-latest.json" )
5+ model AptModuleLatest {
6+ ... AptModuleV1 ;
7+ }
8+
9+ @ jsonSchema ("/modules/apt-v1.json" )
10+ model AptModuleV1 {
11+ /**
12+ * The apt module offers pseudo-declarative package and repository management using apt.
13+ * https://blue-build.org/reference/modules/apt/
14+ */
15+ type : "apt" | "apt@v1" | "apt@latest" ;
16+
17+ /** Configuration of packages removal. */
18+ remove ? : Remove ;
19+
20+ /** Configuration of packages install. */
21+ install ? : Install ;
22+ }
23+
24+ model Install {
25+ /** List of packages to install. */
26+ packages : Array <string >;
27+ }
28+
29+ model Remove {
30+ /** List of packages to remove. */
31+ packages : Array <string >;
32+ }
Original file line number Diff line number Diff line change 1+ name : apt
2+ shortdesc : The apt module offers pseudo-declarative package and repository management using apt.
3+ example : |
4+ type: apt
5+ install:
6+ packages:
7+ - git
8+ remove:
9+ packages:
10+ - firefox
11+ - firefox-langpacks
Original file line number Diff line number Diff line change 1+ # ** ` pacman ` Module**
2+
3+ The ` pacman ` module offers pseudo-declarative package and repository management using [ ` pacman ` ] ( https://gitlab.archlinux.org/pacman/pacman/ ) .
4+
5+ ## Features
6+
7+ This module is capable of:
8+
9+ - Package Management
10+ - Installing packages
11+ - Removing packages
12+
13+ ## Package Management
14+
15+ ### Installing
16+
17+ ``` yaml
18+ type : pacman
19+ install :
20+ packages :
21+ - package-1
22+ - package-2
23+ ` ` `
24+
25+ ### Removing Packages
26+
27+ ` ` ` yaml
28+ type : pacman
29+ remove :
30+ packages :
31+ - package-1
32+ - package-2
33+ ` ` `
Original file line number Diff line number Diff line change 1+ name : pacman
2+ shortdesc : The pacman module offers pseudo-declarative package and repository management using apt.
3+ example : |
4+ type: pacman
5+ install:
6+ packages:
7+ - git
8+ remove:
9+ packages:
10+ - firefox
11+ - firefox-langpacks
You can’t perform that action at this time.
0 commit comments