// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0

package main

import (
	"fmt"

	"go.wit.com/lib/protobuf/zoopb"
	"go.wit.com/log"
)

// init the installed package list
func initPackages() {
	// Get the list of installed packages for the detected distro
	newP, err := getPackageList(me.distro)
	if err != nil {
		fmt.Println("Error:", err)
		return
	}

	// Print the installed packages and their versions
	for pkg, version := range newP {
		new1 := new(zoopb.Package)
		new1.Name = pkg
		new1.Version = version
		me.packages.Append(new1)
	}

	log.Info(me.hostname, "has distro", me.distro, "with", me.packages.Len(), "packages installed")
}

func addNew(name string, version string) {
	new1 := new(zoopb.Package)
	new1.Name = name
	new1.Version = version
	me.packages.Append(new1)
}