apkupdater: Implement Alpine Update()
Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
parent
76312192ae
commit
cd1ea5495e
@ -3,6 +3,7 @@ package apkupdater
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"os/exec"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -24,9 +25,19 @@ type AlpineLinuxPackageUpdate struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *AlpineLinuxPackageUpdate) Update() {
|
func (u *AlpineLinuxPackageUpdate) Update() {
|
||||||
|
|
||||||
u.apkLock.Lock()
|
u.apkLock.Lock()
|
||||||
log.Println("Updating packages...")
|
log.Println("Updating packages...")
|
||||||
|
cmd := exec.Command("apk", u.Packages...)
|
||||||
|
stdout, err := cmd.Output()
|
||||||
u.apkLock.Unlock()
|
u.apkLock.Unlock()
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err.Error())
|
||||||
|
}
|
||||||
|
if cmd.ProcessState.ExitCode() != 1 {
|
||||||
|
log.Printf("Update command returned exit status %d\n", cmd.ProcessState.ExitCode())
|
||||||
|
log.Println(string(stdout))
|
||||||
|
}
|
||||||
log.Println("Done updating packges")
|
log.Println("Done updating packges")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +56,7 @@ func (u *AlpineLinuxPackageUpdate) Run() {
|
|||||||
}
|
}
|
||||||
fmt.Println("Updater stopped")
|
fmt.Println("Updater stopped")
|
||||||
}()
|
}()
|
||||||
log.Println("Started apline linux package updater")
|
log.Println("Started Alpine linux package updater")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *AlpineLinuxPackageUpdate) ValidPackages() bool {
|
func (u *AlpineLinuxPackageUpdate) ValidPackages() bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user