Skip to content

Commit

Permalink
Merge pull request #4 from isbm/isbm-profiles
Browse files Browse the repository at this point in the history
Add profiles
  • Loading branch information
isbm authored Sep 11, 2023
2 parents fb2cb96 + f28a0c9 commit da19718
Show file tree
Hide file tree
Showing 14 changed files with 591 additions and 39 deletions.
108 changes: 107 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ clap = { version = "4.3.24", features = [
"unstable-styles",
] }
colored = "2.0.4"
exitcode = "1.1.2"
log = "0.4.20"
serde = { version = "1.0.188", features = ["derive", "alloc"] }
serde_yaml = "0.9.25"
time = "0.3.28"

[profile.release]
strip = true
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ build:
cargo build

man:
pandoc --standalone --to man doc/mezzotint.8.md -o doc/mezzotint.8
pandoc --standalone --to man doc/manpages/mezzotint.8.md -o doc/manpages/mezzotint.8
44 changes: 44 additions & 0 deletions doc/example-profile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# List of binary targets those are used
# as entry points for the bundle apps.
targets:
- /usr/bin/bash
- /usr/bin/apt

# List of preserved packages.
packages:
- bash
- apt

# Profile config
config:
# List of applied filters. Filter is active
# if present in this list.
#
# NOTE: Filters are used to the data what is still left after
# the automatic examination.
filters:
# Matches localisation data
- l10n

# Matches internationalisation data
- i18n

# Matches all possible documentation, licenses, howtos etc
- doc

# Matches manpages
- man

# Matches everything related to the logging
- log

# Matches empty directories or directories with emnpty subdirectories
- dir

- junk

# Specific paths that were not automatically detected
# as not needed. Unix glob is used to be more specific, if needed.
prune:
- /usr/share/bug/*
- /usr/share/lintian/*
File renamed without changes.
File renamed without changes.
51 changes: 51 additions & 0 deletions doc/profiles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Mazzotint Profile

Profiles are used to describe software or a group of software components and their
presense on the system.

## Structure

```yaml
# List of binary targets those are used
# as entry points for the bundle apps.
targets:
- /usr/bin/bash
- /usr/bin/apt

# List of preserved packages.
packages:
- bash
- apt

# Profile config
config:
# List of applied filters. Filter is active
# if present in this list.
#
# NOTE: Filters are used to the data what is still left after
# the automatic examination.
filters:
# Matches localisation data
- l10n

# Matches internationalisation data
- i18n

# Matches all possible documentation, licenses, howtos etc
- doc

# Matches manpages
- man

# Matches everything related to the logging
- log

# Matches empty directories or directories with emnpty subdirectories
- dir

# Specific paths that were not automatically detected
# as not needed. Unix glob is used to be more specific, if needed.
prune:
- /usr/share/bug/*
- /usr/share/lintian/*
```
File renamed without changes.
49 changes: 48 additions & 1 deletion src/clidef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,81 @@ pub fn cli(version: &'static str) -> Command {
Command::new("mezzotint")
.version(version)
.about(format!("{}{} - {}", "mezzo".bold().underline(), "tint", "is a tool to turn your container into an App Bundle"))
.override_usage(format!("{} {} {}", "mezzotint".bright_cyan(), "[OPTIONS]".cyan(), "[FILTERS]".cyan()))
// Config
.arg(
Arg::new("exe")
.short('x')
.long("exe")
.conflicts_with("profile")
.help("Specify path to an executable which needs to be preserved.")
)
.arg(
Arg::new("profile")
.short('p')
.long("profile")
.help("Profile, describing whole setup"),
.conflicts_with("exe")
.help("Profile, describing whole setup")
)
.arg(
Arg::new("invert-filters")
.short('i')
.long("invert")
.action(clap::ArgAction::SetTrue)
.help("Invert filters behaviour")
)

// Filters
.next_help_heading("Filters")
/*
f_prune: Vec<String>
packages: Vec<String>
targets: Vec<String>
*/
.arg(
Arg::new("f_l10n").long("l10n").action(clap::ArgAction::SetTrue).help("Leave localisation data")
)
.arg(
Arg::new("f_i18n").long("i18n").action(clap::ArgAction::SetTrue).help("Leave internationalisation data")
)
.arg(
Arg::new("f_doc").long("doc").action(clap::ArgAction::SetTrue).help("Leave documents, texts, licences etc")
)
.arg(
Arg::new("f_man").long("man").action(clap::ArgAction::SetTrue).help("Leave manpages")
)
.arg(
Arg::new("f_dir").long("dirs").action(clap::ArgAction::SetTrue).help("Leave empty directories (except required)")
)
.arg(
Arg::new("f_log").long("logs").action(clap::ArgAction::SetTrue).help("Leave any kind of logs")
)

// Other
.next_help_heading("Other")
.arg(
Arg::new("debug")
.short('d')
.long("debug")
.action(ArgAction::SetTrue)
.help("Set debug mode for more verbose output."),
)
.arg(
Arg::new("help")
.short('h')
.long("help")
.action(ArgAction::SetTrue)
.help("Display help"),
)
.arg(
Arg::new("version")
.short('v')
.long("version")
.action(ArgAction::SetTrue)
.help("Get current version."),
)
.disable_help_flag(true) // Otherwise it is displayed in a wrong position
.disable_version_flag(true)
.disable_colored_help(false)
.styles(styles)
Expand Down
Loading

0 comments on commit da19718

Please sign in to comment.