mirror of
https://github.com/kairos-io/immucore.git
synced 2025-08-02 06:52:03 +00:00
+x generator.sh
Signed-off-by: Itxaka <itxaka@spectrocloud.com>
This commit is contained in:
parent
14e0faacee
commit
717851b0b2
@ -55,14 +55,16 @@ lint:
|
||||
|
||||
build-immucore:
|
||||
FROM +golang-image
|
||||
COPY +version/VERSION ./
|
||||
ARG VERSION=$(cat VERSION)
|
||||
WORKDIR /work
|
||||
COPY go.mod go.sum /work
|
||||
COPY main.go /work
|
||||
COPY --dir internal /work
|
||||
COPY --dir pkg /work
|
||||
RUN CGO_ENABLED=0 go build -o immucore -ldflags "-X internal/version.Version=$VERSION"
|
||||
COPY +version/VERSION ./
|
||||
ARG VERSION=$(cat VERSION)
|
||||
ARG LDFLAGS="-s -w -X github.com/kairos-io/immucore/internal/version.Version=$VERSION"
|
||||
RUN echo ${LDFLAGS}
|
||||
RUN CGO_ENABLED=0 go build -o immucore -ldflags "${LDFLAGS}"
|
||||
SAVE ARTIFACT /work/immucore AS LOCAL build/immucore-$VERSION
|
||||
|
||||
build-dracut:
|
||||
|
34
dracut/28immucore/generator.sh
Normal file → Executable file
34
dracut/28immucore/generator.sh
Normal file → Executable file
@ -1,32 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
set +x
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
GENERATOR_DIR="$2"
|
||||
|
||||
[ -z "$GENERATOR_DIR" ] && exit 1
|
||||
[ -d "$GENERATOR_DIR" ] || mkdir "$GENERATOR_DIR"
|
||||
|
||||
# See https://github.com/kairos-io/packages/blob/d12b12b043a71d8471454f7b4fc84c3181d2bf60/packages/system/dracut/immutable-rootfs/30cos-immutable-rootfs/cos-generator.sh#L29
|
||||
|
||||
## GENERATE SYSROOT
|
||||
cos_img=$(getarg cos-img/filename=)
|
||||
[ -z "${cos_img}" ] && exit 0
|
||||
|
||||
{
|
||||
echo "[Unit]"
|
||||
echo "Before=initrd-root-fs.target"
|
||||
echo "DefaultDependencies=no"
|
||||
echo "Before=initrd-fs.target"
|
||||
echo "Conflicts=initrd-switch-root.target"
|
||||
echo "Requires=initrd-root-fs.target"
|
||||
echo "After=initrd-root-fs.target cos-setup-rootfs.service"
|
||||
echo "[Service]"
|
||||
echo "Type=oneshot"
|
||||
echo "RemainAfterExit=yes"
|
||||
echo "ExecStart=/usr/bin/immucore start"
|
||||
echo "[Mount]"
|
||||
echo "Where=/sysroot"
|
||||
echo "What=/run/initramfs/cos-state/${cos_img#/}"
|
||||
echo "Options=ro,suid,dev,exec,auto,nouser,async"
|
||||
} > "$GENERATOR_DIR"/sysroot.mount
|
||||
|
||||
echo "[Install]"
|
||||
echo "RequiredBy=initrd-fs.target"
|
||||
} > "$GENERATOR_DIR"/immucore.service
|
||||
|
||||
|
||||
if [ ! -e "$GENERATOR_DIR/initrd-fs.target.requires/immucore.service" ]; then
|
||||
mkdir -p "$GENERATOR_DIR"/initrd-fs.target.requires
|
||||
ln -s "$GENERATOR_DIR"/immucore.service \
|
||||
"$GENERATOR_DIR"/initrd-fs.target.requires/immucore.service
|
||||
fi
|
||||
## END GENERATE SYSROOT
|
14
dracut/28immucore/immucore.service
Normal file
14
dracut/28immucore/immucore.service
Normal file
@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=immucore
|
||||
DefaultDependencies=no
|
||||
After=systemd-udev-settle.service
|
||||
Requires=systemd-udev-settle.service
|
||||
Before=dracut-initqueue.service
|
||||
Conflicts=initrd-switch-root.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
StandardOutput=journal+console
|
||||
ExecStartPre=-/usr/bin/systemctl stop oem.mount
|
||||
ExecStart=/usr/bin/immucore start
|
@ -23,9 +23,13 @@ install() {
|
||||
declare moddir=${moddir}
|
||||
declare systemdutildir=${systemdutildir}
|
||||
declare systemdsystemunitdir=${systemdsystemunitdir}
|
||||
declare initdir=${initdir}
|
||||
|
||||
# Add missing elemental binary, drop once we get yip lib inside immucore as its only needed to run the stages
|
||||
inst_multiple immucore elemental
|
||||
inst_script "${moddir}/generator.sh" "${systemdutildir}/system-generators/immucore-generator"
|
||||
inst_simple "${moddir}/immucore.service" "${systemdsystemunitdir}/immucore.service"
|
||||
mkdir -p "${initdir}/${systemdsystemunitdir}/initrd-fs.target.requires"
|
||||
ln_r "../immucore.service" "${systemdsystemunitdir}/initrd-fs.target.requires/immucore.service"
|
||||
dracut_need_initqueue
|
||||
}
|
@ -2,5 +2,6 @@
|
||||
# so at the end, just before we let init do the switch_root
|
||||
# Note that initramfs run with RootDirectory=/sysroot
|
||||
install_items+=" /etc/systemd/system/cos-setup-initramfs.service /etc/systemd/system/initrd.target.requires/cos-setup-initramfs.service "
|
||||
install_items+=" /etc/systemd/system/cos-setup-rootfs.service /etc/systemd/system/initrd-fs.target.requires/cos-setup-rootfs.service "
|
||||
# RUN BY IMMUCORE BUT FAILING
|
||||
#install_items+=" /etc/systemd/system/cos-setup-rootfs.service /etc/systemd/system/initrd-fs.target.requires/cos-setup-rootfs.service "
|
||||
add_dracutmodules+=" immucore "
|
@ -87,9 +87,11 @@ func (s *State) WriteFstab(fstabFile string) func(context.Context) error {
|
||||
// ln -sf -t / /sysroot/system
|
||||
func (s *State) RunStageOp(stage string) func(context.Context) error {
|
||||
return func(ctx context.Context) error {
|
||||
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}).With().Caller().Logger()
|
||||
cmd := fmt.Sprintf("elemental run-stage %s", stage)
|
||||
s.Logger.Debug().Str("cmd", cmd)
|
||||
_, err := utils.SH(cmd)
|
||||
log.Logger.Debug().Str("cmd", cmd).Msg("")
|
||||
output, err := utils.SH(cmd)
|
||||
log.Logger.Debug().Str("output", output).Msg("")
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -183,8 +185,10 @@ func (s *State) Register(g *herd.Graph) error {
|
||||
|
||||
runtime, err := state.NewRuntime()
|
||||
if err != nil {
|
||||
s.Logger.Debug().Err(err).Msg("")
|
||||
return err
|
||||
}
|
||||
s.Logger.Debug().Str("state", litter.Sdump(runtime)).Msg("Register")
|
||||
|
||||
// TODO: add hooks, fstab (might have missed some), systemd compat
|
||||
// TODO: We should also set tmpfs here (not -related)
|
||||
@ -250,7 +254,7 @@ func (s *State) Register(g *herd.Graph) error {
|
||||
// "auto",
|
||||
//"nouser",
|
||||
"async",
|
||||
}, 60*time.Second),
|
||||
}, 10*time.Second),
|
||||
),
|
||||
)
|
||||
if err != nil {
|
||||
@ -389,7 +393,7 @@ func (s *State) Register(g *herd.Graph) error {
|
||||
[]string{
|
||||
"ro", // or rw
|
||||
},
|
||||
60*time.Second,
|
||||
10*time.Second,
|
||||
)(ctx))
|
||||
|
||||
}
|
||||
@ -435,7 +439,7 @@ func (s *State) Register(g *herd.Graph) error {
|
||||
mountRootCondition,
|
||||
herd.WithCallback(
|
||||
s.MountOP(
|
||||
runtime.OEM.Label,
|
||||
runtime.OEM.Name,
|
||||
s.path("/oem"),
|
||||
runtime.OEM.Type,
|
||||
[]string{
|
||||
@ -443,8 +447,8 @@ func (s *State) Register(g *herd.Graph) error {
|
||||
"suid",
|
||||
"dev",
|
||||
"exec",
|
||||
"noauto",
|
||||
"nouser",
|
||||
//"noauto",
|
||||
//"nouser",
|
||||
"async",
|
||||
}, 10*time.Second),
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user