build: improve the use of attached/base.
This commit is contained in:
parent
ea022725be
commit
8d71574e4d
3 changed files with 10 additions and 15 deletions
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
abi <abi/4.0>,
|
abi <abi/4.0>,
|
||||||
|
|
||||||
|
include if exists <abstractions/base>
|
||||||
|
|
||||||
@{att}/@{run}/systemd/journal/dev-log w,
|
@{att}/@{run}/systemd/journal/dev-log w,
|
||||||
@{att}/@{run}/systemd/journal/socket w,
|
@{att}/@{run}/systemd/journal/socket w,
|
||||||
@{att}/@{run}/systemd/journal/stdout rw,
|
@{att}/@{run}/systemd/journal/stdout rw,
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
# SPDX-License-Identifier: GPL-2.0-only
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
# LOGPROF-SUGGEST: no
|
# LOGPROF-SUGGEST: no
|
||||||
|
|
||||||
|
# Do not use it manually, it is automatically included in profiles when it is required.
|
||||||
|
|
||||||
abi <abi/4.0>,
|
abi <abi/4.0>,
|
||||||
|
|
||||||
# There are the common ways to refer to consoles
|
# There are the common ways to refer to consoles
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,8 @@ func init() {
|
||||||
|
|
||||||
// Apply will re-attach the disconnected path
|
// Apply will re-attach the disconnected path
|
||||||
// - Add the attach_disconnected.path flag on all frofile with the attach_disconnected flag
|
// - 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 /
|
// - For compatibility, non disconnected profile will have the @{att} variable set to /
|
||||||
func (b ReAttach) Apply(opt *Option, profile string) (string, error) {
|
func (b ReAttach) Apply(opt *Option, profile string) (string, error) {
|
||||||
var insert string
|
var insert string
|
||||||
|
|
@ -42,25 +43,15 @@ func (b ReAttach) Apply(opt *Option, profile string) (string, error) {
|
||||||
"attach_disconnected",
|
"attach_disconnected",
|
||||||
"attach_disconnected,attach_disconnected.path=@{att}",
|
"attach_disconnected,attach_disconnected.path=@{att}",
|
||||||
)
|
)
|
||||||
|
profile = strings.ReplaceAll(profile,
|
||||||
|
"include <abstractions/base>",
|
||||||
|
"include <abstractions/attached/base>",
|
||||||
|
)
|
||||||
profile = strings.ReplaceAll(profile,
|
profile = strings.ReplaceAll(profile,
|
||||||
"include <abstractions/consoles>",
|
"include <abstractions/consoles>",
|
||||||
"include <abstractions/attached/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 {
|
} else {
|
||||||
insert = "@{att} = /\n"
|
insert = "@{att} = /\n"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue