Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:[#90,#91] Fix wrong path for part-future and etc #94

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions core/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ const (

const (
MountScriptPath = "/usr/sbin/.abroot-mountpoints"
MountUnitDir = "/.system/etc/systemd/system"
SystemDTargetDir = "/.system/etc/systemd/system/cryptsetup.target.wants"
MountUnitDir = "/etc/systemd/system"
SystemDTargetDir = "/etc/systemd/system/cryptsetup.target.wants"
MountUnitFile = "/abroot-mount.service"
)

Expand Down Expand Up @@ -103,7 +103,7 @@ func (s *ABSystem) CheckUpdate() (string, bool) {
return s.Registry.HasUpdate(s.CurImage.Digest)
}

// SyncEtc syncs /.system/etc -> /part-future/.system/etc
// SyncEtc syncs /var/lib/abroot/etc -> /part-future/.system/etc
func (s *ABSystem) SyncEtc(newEtc string) error {
PrintVerbose("ABSystem.SyncEtc: syncing /.system/etc -> %s", newEtc)

Expand All @@ -116,25 +116,31 @@ func (s *ABSystem) SyncEtc(newEtc string) error {
"subgid",
}

etcDir := "/.system/etc"
if _, err := os.Stat(etcDir); os.IsNotExist(err) {
current_part, err := s.RootM.GetPresent()
if err != nil {
PrintVerbose("ABSystem.SyncEtc:err: %s", err)
return err
}

etcDir := fmt.Sprintf("/var/lib/abroot/etc/%s", current_part.Label)
if _, err := os.Stat(etcDir); os.IsNotExist(err) {
PrintVerbose("ABSystem.SyncEtc:err(2): %s", err)
return err
}

for _, file := range etcFiles {
sourceFile := etcDir + "/" + file
destFile := newEtc + "/" + file

// write the diff to the destination
err := MergeDiff(sourceFile, destFile)
if err != nil {
PrintVerbose("ABSystem.SyncEtc:err(2): %s", err)
PrintVerbose("ABSystem.SyncEtc:err(3): %s", err)
return err
}
}

err := exec.Command( // TODO: use the Rsync method here
err = exec.Command( // TODO: use the Rsync method here
"rsync",
"-a",
"--exclude=passwd",
Expand All @@ -144,11 +150,11 @@ func (s *ABSystem) SyncEtc(newEtc string) error {
"--exclude=subuid",
"--exclude=subgid",
"--exclude=fstab",
"/.system/etc/",
etcDir,
newEtc,
).Run()
if err != nil {
PrintVerbose("ABSystem.SyncEtc:err(3): %s", err)
PrintVerbose("ABSystem.SyncEtc:err(4): %s", err)
return err
}

Expand Down Expand Up @@ -616,7 +622,7 @@ func (s *ABSystem) RunOperation(operation ABSystemOperation) error {
// ------------------------------------------------
PrintVerbose("[Stage 8] -------- ABSystemRunOperation")

newEtc := filepath.Join(systemNew, "/.system/etc")
newEtc := filepath.Join(systemNew, "/etc")
err = s.SyncEtc(newEtc)
if err != nil {
PrintVerbose("ABSystem.RunOperation:err(8): %s", err)
Expand Down