optimise sign

This commit is contained in:
ferrreo 2023-09-05 13:14:14 +01:00
parent e323da1a41
commit c846ba2da5
3 changed files with 47 additions and 2 deletions

BIN
ppp

Binary file not shown.

View File

@ -128,17 +128,62 @@ func compare(basePackages map[string]packageInfo, targetPackages map[string]pack
} }
func signFiles(path string) { 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)
}
ch := make(chan bool) ch := make(chan bool)
go func() { go func() {
sign(ch, path+"*.deb") sign(ch, path+"*.deb")
}() }()
<-ch <-ch
signQueue := make(chan string, 10)
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
wg.Add(1)
go func() {
defer wg.Done()
for {
select {
case path, ok := <-signQueue:
if !ok {
return
}
ch := make(chan bool)
go func() {
sign(ch, path)
}()
<-ch
default:
// No more files to sign, exit the goroutine
return
}
}
}()
}
for _, file := range files {
signQueue <- path + file
}
close(signQueue)
wg.Wait()
} }
func sign(ch chan bool, path string) { func sign(ch chan bool, path string) {
if strings.HasSuffix(path, ".deb") { if strings.HasSuffix(path, ".deb") {
fmt.Printf("Signing %s \n", path) fmt.Printf("Signing %s \n", path)
cmd := exec.Command("dpkg-sig", "--sign", "builder", path) cmd := exec.Command("bash -c dpkg-sig", "--sign", "builder", path)
err := cmd.Run() err := cmd.Run()
if err != nil { if err != nil {
panic(err) panic(err)

View File

@ -39,7 +39,7 @@ echo "Getting ubuntu main pool 64bit"
cd ../ cd ../
if [ $(ls ./output/ | wc -l) -l 1 ]; then if [ $(ls ./output/ | wc -l) -lt 1 ]; then
echo "Repos are synced" echo "Repos are synced"
exit 0 exit 0
fi fi