Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aerc: 0.4.0 -> 0.5.2 #103472

Closed
wants to merge 1 commit into from
Closed

aerc: 0.4.0 -> 0.5.2 #103472

wants to merge 1 commit into from

Conversation

jshholland
Copy link
Contributor

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

I had to remake the runtime-sharedir patch as it no longer applied cleanly.

@jshholland
Copy link
Contributor Author

0.5.2 came out yesterday, I have updated this PR (and rebased)

@jshholland jshholland changed the title aerc: 0.4.0 -> 0.5.1 aerc: 0.4.0 -> 0.5.2 Nov 15, 2020
@wizeman
Copy link
Member

wizeman commented Nov 15, 2020

I tested this PR and it seems to work for me because I already have an aerc configuration, but if I delete it (i.e. if I do rm .config/aerc/*) then it doesn't work anymore. Instead, it shows this error:

$ aerc
Failed to load config: Unable to load default styleset: Can't find styleset "default" in any of [@SHAREDIR@/stylesets/]

@siraben
Copy link
Member

siraben commented Nov 18, 2020

Built on macOS. I don't have a aerc config but also getting @wizeman's error.

[nix-shell:~/.../nixpkgs-review/pr-103472-1]$ ./results/aerc/bin/aerc 
Failed to load config: Can't find template "quoted_reply" in any of [/usr/local/share/aerc/templates/] 

Result of nixpkgs-review pr 103472 1

1 package built:
  • aerc

@jshholland
Copy link
Contributor Author

$ aerc
Failed to load config: Unable to load default styleset: Can't find styleset "default" in any of [@SHAREDIR@/stylesets/]

I suspect this is because the patch should also be affecting the stylesets config too. I'm having a look at that now, though I could probably do with some help from @tadeokondrak

@tadeokondrak
Copy link
Member

Not able to test it now, but does

diff --git a/Makefile b/Makefile
index 77f5e61..98cbc11 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@ aerc: $(GOSRC)
 		-o $@
 
 aerc.conf: config/aerc.conf.in
-	sed -e 's:@SHAREDIR@:$(SHAREDIR):g' > $@ < config/aerc.conf.in
+	cat config/aerc.conf.in > $@
 
 debug: $(GOSRC)
 	GOFLAGS="-tags=notmuch" \
diff --git a/config/config.go b/config/config.go
index 51982d2..945c5ef 100644
--- a/config/config.go
+++ b/config/config.go
@@ -549,6 +549,18 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
 		return nil, err
 	}
 
+	for i, filter := range config.Filters {
+		config.Filters[i].Command = strings.ReplaceAll(filter.Command, "@SHAREDIR@", sharedir)
+	}
+
+	for i, templateDir := range config.Templates.TemplateDirs {
+		config.Templates.TemplateDirs[i] = strings.ReplaceAll(templateDir, "@SHAREDIR@", sharedir)
+	}
+
+	for i, styleSetDir := range config.Ui.StyleSetDirs {
+		config.Ui.StyleSetDirs[i] = strings.ReplaceAll(styleSetDir, "@SHAREDIR@", sharedir)
+	}
+
 	if ui, err := file.GetSection("general"); err == nil {
 		if err := ui.MapTo(&config.General); err != nil {
 			return nil, err

work?

@jshholland
Copy link
Contributor Author

Thanks, I think that works as advertised. I have tested with no config and the config I had been using in 0.4.0. I'd appreciate further testing before this is merged though.

@wizeman
Copy link
Member

wizeman commented Nov 19, 2020

With commit 4246904 and an empty config directory I'm still getting:

$ aerc
Failed to load config: Unable to load default styleset: Can't find styleset "default" in any of [@SHAREDIR@/stylesets/]

@eyJhb
Copy link
Member

eyJhb commented Dec 3, 2020

Using nixpkgs-review, I can build it but I get a error with no config when I try to run it.

[nix-shell:~/.cache/nixpkgs-review/pr-103472]$ aerc 
Failed to load config: Unable to load default styleset: Can't find styleset "default" in any of [@SHAREDIR@/stylesets/]

Result of nixpkgs-review pr 103472 1

1 package built:
  • aerc

@eyJhb
Copy link
Member

eyJhb commented Dec 4, 2020

Have it working with the patch below. but I feel like there is a better way of doing it...

diff --git a/Makefile b/Makefile
index 77f5e61..98cbc11 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@ aerc: $(GOSRC)
 		-o $@
 
 aerc.conf: config/aerc.conf.in
-	sed -e 's:@SHAREDIR@:$(SHAREDIR):g' > $@ < config/aerc.conf.in
+	cat config/aerc.conf.in > $@
 
 debug: $(GOSRC)
 	GOFLAGS="-tags=notmuch" \
diff --git a/commands/set.go b/commands/set.go
index cc6333e..d2cdd9d 100644
--- a/commands/set.go
+++ b/commands/set.go
@@ -57,7 +57,7 @@ func SetCore(aerc *widgets.Aerc, args []string) error {
 		return err
 	}
 
-	if err := config.LoadConfig(new_file); err != nil {
+	if err := config.LoadConfig(new_file, "NO_SHAREDIR_TO_SET"); err != nil {
 		return err
 	}
 
diff --git a/config/config.go b/config/config.go
index 87d183a..ca182ec 100644
--- a/config/config.go
+++ b/config/config.go
@@ -288,7 +288,7 @@ func installTemplate(root, sharedir, name string) error {
 	return nil
 }
 
-func (config *AercConfig) LoadConfig(file *ini.File) error {
+func (config *AercConfig) LoadConfig(file *ini.File, sharedir string) error {
 	if filters, err := file.GetSection("filters"); err == nil {
 		// TODO: Parse the filter more finely, e.g. parse the regex
 		for _, match := range filters.KeyStrings() {
@@ -318,6 +318,7 @@ func (config *AercConfig) LoadConfig(file *ini.File) error {
 			config.Filters = append(config.Filters, filter)
 		}
 	}
+
 	if viewer, err := file.GetSection("viewer"); err == nil {
 		if err := viewer.MapTo(&config.Viewer); err != nil {
 			return err
@@ -421,6 +422,18 @@ func (config *AercConfig) LoadConfig(file *ini.File) error {
 		}
 	}
 
+	for i, filter := range config.Filters {
+		config.Filters[i].Command = strings.ReplaceAll(filter.Command, "@SHAREDIR@", sharedir)
+	}
+
+	for i, templateDir := range config.Templates.TemplateDirs {
+		config.Templates.TemplateDirs[i] = strings.ReplaceAll(templateDir, "@SHAREDIR@", sharedir)
+	}
+
+	for i, styleSetDir := range config.Ui.StyleSetDirs {
+		config.Ui.StyleSetDirs[i] = strings.ReplaceAll(styleSetDir, "@SHAREDIR@", sharedir)
+	}
+
 	if err := config.Ui.loadStyleSet(
 		config.Ui.StyleSetDirs); err != nil {
 		return err
@@ -470,6 +483,11 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
 			return nil, err
 		}
 	}
+	if sec, err := file.GetSection("templates"); err == nil {
+		if key, err := sec.GetKey("template-dirs"); err == nil {
+			sec.NewKey("template-dirs", strings.ReplaceAll(key.String(), "@SHAREDIR@", sharedir))
+		}
+	}
 	file.NameMapper = mapName
 	config := &AercConfig{
 		Bindings: BindingConfig{
@@ -543,7 +561,7 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
 	quit, _ := ParseBinding("<C-q>", ":quit<Enter>")
 	config.Bindings.AccountWizard.Add(quit)
 
-	if err = config.LoadConfig(file); err != nil {
+	if err = config.LoadConfig(file, sharedir); err != nil {
 		return nil, err
 	}

@bbjubjub2494
Copy link
Member

AFAICT this seems redundant now that #107880 is through. Can I close this?

@jshholland
Copy link
Contributor Author

Yep, that looks like it's done the job. I'll close this down now.

@jshholland jshholland closed this Jan 15, 2021
@jshholland jshholland deleted the update-aerc branch July 29, 2022 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants