Skip to content

Commit

Permalink
fix:[#90,#91] Fix wrong path for part-future and etc
Browse files Browse the repository at this point in the history
  • Loading branch information
matbme committed Aug 7, 2023
1 parent 42b33ea commit 114f339
Showing 1 changed file with 16 additions and 10 deletions.
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

0 comments on commit 114f339

Please sign in to comment.