azurelinux icon indicating copy to clipboard operation
azurelinux copied to clipboard

Add configurable docs and locales

Open dmcilvaney opened this issue 1 year ago • 1 comments

Merge Checklist

All boxes should be checked before merging the PR (just tick any boxes which don't apply to this PR)

  • [x] The toolchain has been rebuilt successfully (or no changes were made to it)
  • [x] The toolchain/worker package manifests are up-to-date
  • [x] Any updated packages successfully build (or no packages were changed)
  • [x] Packages depending on static components modified in this PR (Golang, *-static subpackages, etc.) have had their Release tag incremented.
  • [x] Package tests (%check section) have been verified with RUN_CHECK=y for existing SPEC files, or added to new SPEC files
  • [x] All package sources are available
  • [x] cgmanifest files are up-to-date and sorted (./cgmanifest.json, ./toolkit/scripts/toolchain/cgmanifest.json, .github/workflows/cgmanifest.json)
  • [x] LICENSE-MAP files are up-to-date (./SPECS/LICENSES-AND-NOTICES/data/licenses.json, ./SPECS/LICENSES-AND-NOTICES/LICENSES-MAP.md, ./SPECS/LICENSES-AND-NOTICES/LICENSE-EXCEPTIONS.PHOTON)
  • [x] All source files have up-to-date hashes in the *.signatures.json files
  • [x] sudo make go-tidy-all and sudo make go-test-coverage pass
  • [x] Documentation has been updated to match any changes to the build system
  • [ ] Ready to merge

Summary

We want to be able to disable documentation and locale files to minimize storage space. rpm offers two macros to help with this:

  • %_excludedocs 1: Disable any %doc file in a package
  • %_install_langs en:es:fr: Only include locale files that start with one of the prefixes. By setting it to NONE this matches no locales and effectively disables them.

These can be controlled by new settings in SystemConfig:

"DisableRpmDocs": true,
"DisableRpmLocales": true,
"OverrideRpmLocales": "en:fr:es"

DisableRpmLocales and OverrideRpmLocales are mutually exclusive.

For example, setting DisableRpmLocales will create /usr/lib/rpm/macros.d/macros.installercustomizations_customize_locales

# This macro file was dynamically generated by the Azure Linux Toolkit image generator
# based on the configuration used at image creation time.

# This stops locale files from being installed. %%_install_langs acts as a filter for locales
# which start with the provides strings. Setting it to an invalid value (ie 'NONE') will
# prevent any locale files from being installed.
# To enable locale files, remove this file, or comment out '%%_install_langs <LOCALE STRING>'
# Any packages which are already installed must be reinstalled for this change to take effect.

%_install_langs NONE
Change Log
  • Add DisableDocumentationDefines(), DisableLocaleDefines(), OverrideLocaleDefines() to rpm.go to create these macros.
  • Add customizationmacros package which can generate macro files
    • AddMacroFile() will create a new macro file inside the given root directory that contains each of the macros given.
    • AddCustomizationMacros() sets the new flags defined in SystemConfig along with some helpful comments.
Does this affect the toolchain?

NO

Test Methodology
  • Local builds of core-efi.json

dmcilvaney avatar Apr 11 '24 23:04 dmcilvaney

Need to wait on another PR first to fix a bunch of packages. Several packages include license files as %doc which should really be %license. We need to fix those before we ship images that disable documentation.

dmcilvaney avatar Apr 17 '24 23:04 dmcilvaney

Need more testing for locales, will leave them enabled in configs for now.

dmcilvaney avatar May 28 '24 18:05 dmcilvaney