Skip to content
New issue

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

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

Already on GitHub? # to your account

Alpine support #6

Merged
merged 18 commits into from
Nov 15, 2022
Merged

Alpine support #6

merged 18 commits into from
Nov 15, 2022

Conversation

melezhik
Copy link
Contributor

@melezhik melezhik commented Nov 3, 2022

This is just a draft. For some reasons some of tests fail on SparrowCI - https://ci.sparrowhub.io/report/1488

@melezhik
Copy link
Contributor Author

melezhik commented Nov 3, 2022

02:54:29 :: === RUN   TestPkgsToInstall
02:54:29 :: 2022/11/03 02:54:29 [ERROR] running /sbin/apk info -qe coreutils: 'exit status 1'
02:54:29 :: 2022/11/03 02:54:29 [INFO] coreutils not installed
02:54:29 ::     util.go:79: true != false
02:54:29 :: 2022/11/03 02:54:29 [ERROR] running /sbin/apk info -qe coreutils: 'exit status 1'
02:54:29 :: 2022/11/03 02:54:29 [INFO] coreutils not installed
02:54:29 :: 2022/11/03 02:54:29 [ERROR] running /sbin/apk info -qe freedoom: 'exit status 1'
02:54:29 :: 2022/11/03 02:54:29 [INFO] freedoom not installed
02:54:29 :: --- FAIL: TestPkgsToInstall (0.07s)

I guess this is because coreutils are not preinstalled on vanilla Alpine Linux

@melezhik
Copy link
Contributor Author

melezhik commented Nov 3, 2022

it boils down to this assumption (not met on Alpine) - https://github.com/ema/pets/blob/master/planner_test.go#L15-L17

  // Test with one package already installed
  pf, err := NewPetsFile("/dev/null", "coreutils", "/etc/passwd", "root", "root", "0640", "", "")
  assertNoError(t, err)

@melezhik
Copy link
Contributor Author

melezhik commented Nov 3, 2022

util.go:79: /bin/chmod 0644 /dev/null != /usr/bin/chmod 0644 /dev/null

This is because assumption for location of chmod for alpine is wrong -

assertEquals(t, pa.Command.String(), "/usr/bin/chown nobody:root /etc/passwd")

pa := Chmod(pf)
  if pa != nil {
    t.Errorf("Expecting nil, got %v instead", pa)
  }

  pf.AddMode("0644")

  pa = Chmod(pf)

  assertEquals(t, pa.Cause.String(), "CHMOD")
  assertEquals(t, pa.Command.String(), "/usr/bin/chmod 0644 /dev/null")

it's indeed at /bin/chmod

@ema ema marked this pull request as ready for review November 14, 2022 18:22
Copy link
Owner

@ema ema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two comments, LGTM otherwise! Thanks.

package.go Outdated
}
return nil
return nil
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation looks off here, please use go fmt.

package.go Outdated
installed := NewCmd([]string{"apk", "info", "-qe", string(pp)})
_, _, err := RunCmd(installed)
if err != nil {
log.Printf("[ERROR] running %s: '%s'", installed, err)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing \n.

@melezhik
Copy link
Contributor Author

please see now ...

@melezhik melezhik requested a review from ema November 14, 2022 18:39
Copy link
Owner

@ema ema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you!

@ema ema merged commit abc598e into ema:master Nov 15, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants