gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.39k stars 7.49k forks source link

Hugo includes deploy code even when built with "-tags nodeploy" #12009

Closed flyn-org closed 8 months ago

flyn-org commented 8 months ago
$ hugo version
hugo v0.121.1+extended linux/amd64 BuildDate=2024-02-06T18:00:00-06:00 VendorInfo=Fedora:0.121.1-1.fc39

Hugo includes optional code to support website deployment. This code brings in many dependencies, and Hugo provides an option to deactivate it (-tags nodeploy).

I maintain the official Hugo package for Fedora. Packaging the deploy code's dependencies has become difficult, so I now build the Hugo package without the deploy features. The trouble is that the Fedora packaging system automatically resolves dependencies by inspecting the imports found in Go code. I can partially address this by removing the "deploy" directory before building. However, config/allconfig/allconfig.go and config/allconfig/alldecoders.go import from the deploy directory regardless of the presence of the nodeploy tag.

Would it be possible to make conditional the use of deploy in allconfig.go and alldecoders.go with something like this

//go:build !nodeploy
// +build !nodeploy

?

That would go a long way to make packaging less fragile and more straight forward.

Here are my current steps, which might help illustrate what I am trying to describe:

  1. rm -rf deploy.
  2. Patch things with sed:
    • sed -i '/"github.com\/gohugoio\/hugo\/deploy"/d' config/allconfig/allconfig.go # Remove import.
    • sed -i 's/Deployment deploy.DeployConfig/Deployment bool/g' config/allconfig/allconfig.go # Replace use with bool.
    • sed -i '/"github.com\/gohugoio\/hugo\/deploy"/d' config/allconfig/alldecoders.go # Remove import.
    • sed -i 's/p.c.Deployment, err =/\/\/ p.c.Deployment, err =/g' config/allconfig/alldecoders.go # Comment out use.
  3. Run go build with -tags nodeploy.
  4. Run go test with -tags nodeploy.

Steps 1, 3, and 4 are fine. Step 2 is what I would like to avoid.

bep commented 8 months ago

Would it be possible to make conditional the use of deploy in allconfig.go and alldecoders.go with something like this

We still need/want to load the config, but we should split the deploy config out into its own package, I guess.

github-actions[bot] commented 7 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.