build: improve the use of attached/base.

This commit is contained in:
Alexandre Pujol 2025-04-05 21:31:51 +02:00
parent ea022725be
commit 8d71574e4d
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
3 changed files with 10 additions and 15 deletions

View file

@ -30,7 +30,8 @@ func init() {
// Apply will re-attach the disconnected path
// - Add the attach_disconnected.path flag on all frofile with the attach_disconnected flag
// - Add the attached/base abstraction in the profile
// - Replace the base abstraction by attached/base
// - Replace the consoles abstraction by attached/consoles
// - For compatibility, non disconnected profile will have the @{att} variable set to /
func (b ReAttach) Apply(opt *Option, profile string) (string, error) {
var insert string
@ -42,25 +43,15 @@ func (b ReAttach) Apply(opt *Option, profile string) (string, error) {
"attach_disconnected",
"attach_disconnected,attach_disconnected.path=@{att}",
)
profile = strings.ReplaceAll(profile,
"include <abstractions/base>",
"include <abstractions/attached/base>",
)
profile = strings.ReplaceAll(profile,
"include <abstractions/consoles>",
"include <abstractions/attached/consoles>",
)
old := "include if exists <local/" + opt.Name + ">"
new := "include <abstractions/attached/base>\n " + old
profile = strings.Replace(profile, old, new, 1)
for _, match := range regProfile.FindAllStringSubmatch(profile, -1) {
name := match[1]
if name == opt.Name {
continue
}
old = "include if exists <local/" + opt.Name + "_" + name + ">"
new = "include <abstractions/attached/base>\n " + old
profile = strings.Replace(profile, old, new, 1)
}
} else {
insert = "@{att} = /\n"
}