Set cros.source correctly for bullseye
Use VERSION_CODENAME instead of hardcoding our own map of version
numbers to code names, so we shouldn't need to update this in the
future.
BUG=chromium:1217902
TEST="sudo apt update" in bullseye
Change-Id: I4c4fbdba7febbadb8d42bc8fe4f5316e77342b75
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/tremplin/+/3062187
Commit-Queue: Fergus Dall <sidereal@google.com>
Commit-Queue: David Munro <davidmunro@google.com>
Tested-by: Fergus Dall <sidereal@google.com>
Auto-Submit: Fergus Dall <sidereal@google.com>
Reviewed-by: David Munro <davidmunro@google.com>
diff --git a/src/chromiumos/tremplin/tremplin.go b/src/chromiumos/tremplin/tremplin.go
index 70d3055..5baa91f 100644
--- a/src/chromiumos/tremplin/tremplin.go
+++ b/src/chromiumos/tremplin/tremplin.go
@@ -1083,16 +1083,7 @@
if err == nil {
response.OsRelease = osRelease.toProto()
if osRelease.id == "debian" {
- if osRelease.versionID == "9" {
- err = s.writeContainerFile(container.Name, "/etc/apt/sources.list.d/cros.list", createAptSourceList(s.milestone, "stretch"))
- } else if osRelease.versionID == "10" {
- err = s.writeContainerFile(container.Name, "/etc/apt/sources.list.d/cros.list", createAptSourceList(s.milestone, "buster"))
- } else if osRelease.versionID == "" {
- // Unstable and maybe testing, closest to buster. We used to
- // forcibly downgrade them to stretch versions which is why
- // we upgrade them now instead of leaving it alone.
- err = s.writeContainerFile(container.Name, "/etc/apt/sources.list.d/cros.list", createAptSourceList(s.milestone, "buster"))
- }
+ err = s.writeContainerFile(container.Name, "/etc/apt/sources.list.d/cros.list", createAptSourceList(s.milestone, osRelease.versionCodename))
} // else unknown distro so do nothing.
if err != nil {
log.Print("Failed to update guest cros.list: ", err)
diff --git a/src/chromiumos/tremplin/version.go b/src/chromiumos/tremplin/version.go
index fc07663..5cf21c6 100644
--- a/src/chromiumos/tremplin/version.go
+++ b/src/chromiumos/tremplin/version.go
@@ -17,7 +17,7 @@
pb "chromiumos/vm_tools/tremplin_proto"
- "github.com/lxc/lxd/client"
+ lxd "github.com/lxc/lxd/client"
)
const (
@@ -61,11 +61,12 @@
// OsRelease encapsulates a subset of the os-release info as documented
// at https://www.freedesktop.org/software/systemd/man/os-release.html
type OsRelease struct {
- prettyName string
- name string
- version string
- versionID string
- id string
+ prettyName string
+ name string
+ version string
+ versionID string
+ versionCodename string
+ id string
}
// getFileResolvingSymlinks will get the contents of a container file while
@@ -121,6 +122,8 @@
osRelease.version = dequote(s[1])
case "VERSION_ID":
osRelease.versionID = dequote(s[1])
+ case "VERSION_CODENAME":
+ osRelease.versionCodename = dequote(s[1])
case "ID":
osRelease.id = dequote(s[1])
}
@@ -139,8 +142,12 @@
}
func createAptSourceList(milestone int, osVersion string) string {
- if milestone < 70 {
- return "deb https://storage.googleapis.com/cros-packages stretch main\n"
+ if osVersion == "" {
+ // The VERSION_CODENAME tag is only required to be
+ // present on stable versions of debian. For
+ // testing/unstable/experimental, bullseye is the most
+ // recent set of packages.
+ osVersion = "bullseye"
}
return fmt.Sprintf("deb https://storage.googleapis.com/cros-packages/%d %s main\n", milestone, osVersion)
}