handle makepkg.conf.d files
This commit is contained in:
14
flags.yaml
14
flags.yaml
@@ -20,13 +20,19 @@ common:
|
|||||||
packager: "ALHP $march$ <alhp@harting.dev>"
|
packager: "ALHP $march$ <alhp@harting.dev>"
|
||||||
makeflags: "-j$buildproc$"
|
makeflags: "-j$buildproc$"
|
||||||
# https://somegit.dev/ALHP/ALHP.GO/issues/110
|
# https://somegit.dev/ALHP/ALHP.GO/issues/110
|
||||||
rustflags: "-Copt-level=3 -Ctarget-cpu=$march$ -Clink-arg=-z -Clink-arg=pack-relative-relocs"
|
rustflags:
|
||||||
|
- "-Copt-level=3"
|
||||||
|
- "-Ctarget-cpu=$march$"
|
||||||
|
- "-Clink-arg=-z"
|
||||||
|
- "-Clink-arg=pack-relative-relocs"
|
||||||
ltoflags:
|
ltoflags:
|
||||||
- "-falign-functions=32" # https://github.com/InBetweenNames/gentooLTO/issues/164
|
- "-falign-functions=32" # https://github.com/InBetweenNames/gentooLTO/issues/164
|
||||||
kcflags: " -march=$march$ -O3"
|
kcflags: " -march=$march$ -O3"
|
||||||
kcppflags: " -march=$march$ -O3"
|
kcppflags: " -march=$march$ -O3"
|
||||||
fcflags: "$CFLAGS"
|
fcflags: "$FFLAGS"
|
||||||
fflags: "$CFLAGS"
|
fflags:
|
||||||
|
- "-O2": "-O3"
|
||||||
|
- "-march=$march$"
|
||||||
|
|
||||||
lto:
|
lto:
|
||||||
rustflags:
|
rustflags:
|
||||||
@@ -35,4 +41,4 @@ lto:
|
|||||||
options:
|
options:
|
||||||
- "!lto": "lto"
|
- "!lto": "lto"
|
||||||
|
|
||||||
cargo_profile_release_lto: "fat"
|
cargo_profile_release_lto: "fat"
|
||||||
|
37
utils.go
37
utils.go
@@ -26,6 +26,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
pacmanConf = "/usr/share/devtools/pacman.conf.d/multilib.conf"
|
pacmanConf = "/usr/share/devtools/pacman.conf.d/multilib.conf"
|
||||||
makepkgConf = "/usr/share/devtools/makepkg.conf.d/x86_64.conf"
|
makepkgConf = "/usr/share/devtools/makepkg.conf.d/x86_64.conf"
|
||||||
|
makepkgConfExt = "/etc/makepkg.conf.d"
|
||||||
logDir = "logs"
|
logDir = "logs"
|
||||||
pristineChroot = "root"
|
pristineChroot = "root"
|
||||||
buildDir = "build"
|
buildDir = "build"
|
||||||
@@ -337,7 +338,7 @@ func setupChroot() error {
|
|||||||
res, err := cmd.CombinedOutput()
|
res, err := cmd.CombinedOutput()
|
||||||
log.Debug(string(res))
|
log.Debug(string(res))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error updating chroot: %w\n%s", err, string(res))
|
return fmt.Errorf("error updating chroot: %w: %s", err, string(res))
|
||||||
}
|
}
|
||||||
case os.IsNotExist(err):
|
case os.IsNotExist(err):
|
||||||
err = os.MkdirAll(filepath.Join(conf.Basedir.Work, chrootDir), 0o755)
|
err = os.MkdirAll(filepath.Join(conf.Basedir.Work, chrootDir), 0o755)
|
||||||
@@ -349,15 +350,24 @@ func setupChroot() error {
|
|||||||
res, err := cmd.CombinedOutput()
|
res, err := cmd.CombinedOutput()
|
||||||
log.Debug(string(res))
|
log.Debug(string(res))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error creating chroot: %w\n%s", err, string(res))
|
return fmt.Errorf("error creating chroot: %w: %s", err, string(res))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// copy pacman.conf into pristine chroot to enable multilib
|
||||||
cmd = exec.Command("sudo", "cp", pacmanConf, //nolint:gosec
|
cmd = exec.Command("sudo", "cp", pacmanConf, //nolint:gosec
|
||||||
filepath.Join(conf.Basedir.Work, chrootDir, pristineChroot, "etc/pacman.conf"))
|
filepath.Join(conf.Basedir.Work, chrootDir, pristineChroot, "etc/pacman.conf"))
|
||||||
res, err = cmd.CombinedOutput()
|
res, err = cmd.CombinedOutput()
|
||||||
log.Debug(string(res))
|
log.Debug(string(res))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error copying pacman.conf to chroot: %w\n%s", err, string(res))
|
return fmt.Errorf("error copying pacman.conf to chroot: %w: %s", err, string(res))
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove makepkg conf extension, they are covered by our custom makepkg
|
||||||
|
cmd = exec.Command("sudo", "rm_chroot.py", filepath.Join(conf.Basedir.Work, chrootDir, pristineChroot, "etc/makepkg.conf.d"))
|
||||||
|
res, err = cmd.CombinedOutput()
|
||||||
|
log.Debug(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error removing makepkg.conf.d from chroot: %w: %s", err, string(res))
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return err
|
return err
|
||||||
@@ -482,6 +492,8 @@ func parseFlagSection(section any, makepkgConf, march string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := subMap.(string); ok && len(orgMatch) > 0 {
|
if _, ok := subMap.(string); ok && len(orgMatch) > 0 {
|
||||||
|
log.Debugf("replace %s with %s", orgMatch[0], fmt.Sprintf("\n%s=%s%s%s",
|
||||||
|
strings.ToUpper(subSec.(string)), orgMatch[2], replaceStringsFromMap(subMap.(string), replaceMap), orgMatch[4]))
|
||||||
makepkgConf = strings.ReplaceAll(makepkgConf, orgMatch[0], fmt.Sprintf("\n%s=%s%s%s",
|
makepkgConf = strings.ReplaceAll(makepkgConf, orgMatch[0], fmt.Sprintf("\n%s=%s%s%s",
|
||||||
strings.ToUpper(subSec.(string)), orgMatch[2], replaceStringsFromMap(subMap.(string), replaceMap), orgMatch[4]))
|
strings.ToUpper(subSec.(string)), orgMatch[2], replaceStringsFromMap(subMap.(string), replaceMap), orgMatch[4]))
|
||||||
continue
|
continue
|
||||||
@@ -534,7 +546,24 @@ func setupMakepkg(march string, flags map[string]any) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
makepkgStr := string(t)
|
makepkgStrBuilder := new(strings.Builder)
|
||||||
|
makepkgStrBuilder.Write(t)
|
||||||
|
|
||||||
|
// read makepkg conf.d
|
||||||
|
makepkgConfExt, err := Glob(filepath.Join(makepkgConfExt, "*.conf"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, makepkgExt := range makepkgConfExt {
|
||||||
|
ext, err := os.ReadFile(makepkgExt)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
makepkgStrBuilder.Write(ext)
|
||||||
|
}
|
||||||
|
|
||||||
|
makepkgStr := makepkgStrBuilder.String()
|
||||||
|
|
||||||
makepkgStr, err = parseFlagSection(flags["common"], makepkgStr, march)
|
makepkgStr, err = parseFlagSection(flags["common"], makepkgStr, march)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user