make ppp sign and add to repo as well

This commit is contained in:
ferrreo 2023-09-05 01:26:23 +01:00
parent dc8b44bae1
commit d00a594bb9

View File

@ -7,6 +7,7 @@ import (
"log" "log"
"net/http" "net/http"
"os" "os"
"os/exec"
"strings" "strings"
"sync" "sync"
@ -14,6 +15,16 @@ import (
) )
func main() { func main() {
if os.Args[1] == "sign" {
signFiles(os.Args[2])
return
}
if os.Args[1] == "repoadd" {
repoAdd(os.Args[2], os.Args[3])
return
}
config := config{ config := config{
Source: os.Args[1], Source: os.Args[1],
Target: os.Args[2], Target: os.Args[2],
@ -113,6 +124,56 @@ func compare(basePackages map[string]packageInfo, targetPackages map[string]pack
return output return output
} }
func repoAdd(path string, args string) {
dir, err := os.Open(path)
if err != nil {
panic(err)
}
defer dir.Close()
files, err := dir.Readdirnames(-1)
if err != nil {
panic(err)
}
for _, file := range files {
if strings.HasSuffix(file, ".deb") {
fmt.Printf("adding to repo %s \n", file)
cmd := exec.Command("reprepro", args, file)
err := cmd.Run()
if err != nil {
panic(err)
}
}
}
}
func signFiles(path string) {
dir, err := os.Open(path)
if err != nil {
panic(err)
}
defer dir.Close()
files, err := dir.Readdirnames(-1)
if err != nil {
panic(err)
}
for _, file := range files {
if strings.HasSuffix(file, ".deb") {
fmt.Printf("Signing %s \n", file)
cmd := exec.Command("dpkg-sig", "--sign", "builder", file)
err := cmd.Run()
if err != nil {
panic(err)
}
}
}
}
func download(packages map[string]packageInfo, url string, output string) { func download(packages map[string]packageInfo, url string, output string) {
// Create a buffered channel to store the packages to be downloaded // Create a buffered channel to store the packages to be downloaded
packageQueue := make(chan packageInfo, 10) packageQueue := make(chan packageInfo, 10)