sign 10 at once, repoadd 1 at once but new goroutine each time
This commit is contained in:
parent
58357ad68a
commit
57600fe132
99
src/main.go
99
src/main.go
@ -136,17 +136,38 @@ func repoAdd(path string, args string) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, file := range files {
|
addQueue := make(chan string, 1)
|
||||||
if strings.HasSuffix(file, ".deb") {
|
var wg sync.WaitGroup
|
||||||
fmt.Printf("adding to repo %s \n", file)
|
for i := 0; i < 1; i++ {
|
||||||
|
wg.Add(1)
|
||||||
cmd := exec.Command("reprepro", args, path+file)
|
go func() {
|
||||||
err := cmd.Run()
|
defer wg.Done()
|
||||||
if err != nil {
|
for {
|
||||||
panic(err)
|
select {
|
||||||
|
case path, ok := <-addQueue:
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ch := make(chan bool)
|
||||||
|
go func() {
|
||||||
|
add(ch, path, args)
|
||||||
|
}()
|
||||||
|
<-ch
|
||||||
|
default:
|
||||||
|
// No more files to add, exit the goroutine
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, file := range files {
|
||||||
|
addQueue <- path + file
|
||||||
|
}
|
||||||
|
|
||||||
|
close(addQueue)
|
||||||
|
|
||||||
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func signFiles(path string) {
|
func signFiles(path string) {
|
||||||
@ -162,16 +183,62 @@ func signFiles(path string) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, file := range files {
|
signQueue := make(chan string, 10)
|
||||||
if strings.HasSuffix(file, ".deb") {
|
var wg sync.WaitGroup
|
||||||
fmt.Printf("Signing %s \n", file)
|
for i := 0; i < 10; i++ {
|
||||||
cmd := exec.Command("dpkg-sig", "--sign", "builder", path+file)
|
wg.Add(1)
|
||||||
err := cmd.Run()
|
go func() {
|
||||||
if err != nil {
|
defer wg.Done()
|
||||||
panic(err)
|
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) {
|
||||||
|
if strings.HasSuffix(path, ".deb") {
|
||||||
|
fmt.Printf("Signing %s \n", path)
|
||||||
|
cmd := exec.Command("dpkg-sig", "--sign", "builder", path)
|
||||||
|
err := cmd.Run()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ch <- true
|
||||||
|
}
|
||||||
|
|
||||||
|
func add(ch chan bool, path string, args string) {
|
||||||
|
if strings.HasSuffix(path, ".deb") {
|
||||||
|
fmt.Printf("Adding to repo %s \n", path)
|
||||||
|
cmd := exec.Command("reprepro", args, path)
|
||||||
|
err := cmd.Run()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ch <- true
|
||||||
}
|
}
|
||||||
|
|
||||||
func download(packages map[string]packageInfo, url string, output string) {
|
func download(packages map[string]packageInfo, url string, output string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user