func()

in packaging/linux/deb/template_rules.go [68:115]


func (w *rulesWrapper) OverridePerms() fmt.Stringer {
	b := &strings.Builder{}

	artifacts := w.GetArtifacts(w.target)

	var fixPerms bool
	checkPerms := func(cfgs map[string]dalec.ArtifactConfig) bool {
		for _, cfg := range cfgs {
			if cfg.Permissions.Perm() != 0 {
				return true
			}
		}
		return false
	}

	checkDirPerms := func(dirConfigs map[string]dalec.ArtifactDirConfig) bool {
		for _, cfg := range dirConfigs {
			if cfg.Mode.Perm() != 0 {
				return true
			}
		}
		return false
	}

	fixPerms = checkPerms(artifacts.Binaries) ||
		checkPerms(artifacts.ConfigFiles) ||
		checkPerms(artifacts.Manpages) ||
		checkPerms(artifacts.Headers) ||
		checkPerms(artifacts.Licenses) ||
		checkPerms(artifacts.Docs) ||
		checkPerms(artifacts.Libs) ||
		checkPerms(artifacts.Libexec) ||
		checkPerms(artifacts.DataDirs) ||
		checkDirPerms(artifacts.Directories.GetConfig()) ||
		checkDirPerms(artifacts.Directories.GetState())

	if fixPerms {
		// Normally this should be `execute_after_dh_fixperms`, however this doesn't
		// work on Ubuntu 18.04.
		// Instead we need to override dh_fixperms and run it ourselves and then
		// our extra script.
		b.WriteString("override_dh_fixperms:\n")
		b.WriteString("\tdh_fixperms\n")
		b.WriteString("\tdebian/dalec/fix_perms.sh\n\n")
	}

	return b
}