add PackageInfoExists function to 'cos' package
BUG=b/153744290
TEST=gofmt; goimports; golint; go vet; go build; go test
Change-Id: I73caa2513c01bf447480b1a3b6a45be88e4308f5
diff --git a/src/pkg/cos/pkg_info.go b/src/pkg/cos/pkg_info.go
index ef3763b..af94ac9 100644
--- a/src/pkg/cos/pkg_info.go
+++ b/src/pkg/cos/pkg_info.go
@@ -33,6 +33,12 @@
InstalledPackages []packageJSON `json:"installedPackages"`
}
+// PackageInfoExists returns whether COS package information exists.
+func PackageInfoExists() bool {
+ info, err := os.Stat(packageInfoDefaultJSONFile)
+ return !os.IsNotExist(err) && !info.IsDir()
+}
+
// GetPackageInfo loads the package information from this COS system and returns
// it.
func GetPackageInfo() (PackageInfo, error) {