mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-04-19 19:28:22 +00:00
Fix race in fatal exit & context shutdown.
This commit is contained in:
10
main.go
10
main.go
@@ -9,9 +9,11 @@ import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var returnCode = 0
|
||||
|
||||
func fatal(err error) {
|
||||
fmt.Printf("ERROR: %s\n", err)
|
||||
os.Exit(1)
|
||||
returnCode = 1
|
||||
}
|
||||
|
||||
func loadConfig(command *commander.Command) error {
|
||||
@@ -50,26 +52,32 @@ func loadConfig(command *commander.Command) error {
|
||||
}
|
||||
|
||||
func main() {
|
||||
defer func() { os.Exit(returnCode) }()
|
||||
|
||||
command := cmd.RootCommand()
|
||||
|
||||
err := command.Flag.Parse(os.Args[1:])
|
||||
if err != nil {
|
||||
fatal(err)
|
||||
return
|
||||
}
|
||||
|
||||
err = loadConfig(command)
|
||||
if err != nil {
|
||||
fatal(err)
|
||||
return
|
||||
}
|
||||
|
||||
err = cmd.InitContext(command)
|
||||
if err != nil {
|
||||
fatal(err)
|
||||
return
|
||||
}
|
||||
defer cmd.ShutdownContext()
|
||||
|
||||
err = command.Dispatch(command.Flag.Args())
|
||||
if err != nil {
|
||||
fatal(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
|
||||
ERROR: unable to determine list of architectures, please specify explicitly
|
||||
Loading packages...
|
||||
@@ -1 +1,3 @@
|
||||
|
||||
ERROR: unable to copy: unable to parse dependency: pyspi >> 0.6.1-1.3)
|
||||
Loading packages...
|
||||
@@ -1,2 +1,3 @@
|
||||
Loading packages...
|
||||
|
||||
ERROR: unable to import: unable to parse dependency: pyspi >> 0.6.1-1.3)
|
||||
Loading packages...
|
||||
@@ -1 +1,3 @@
|
||||
|
||||
ERROR: unable to determine list of architectures, please specify explicitly
|
||||
Loading packages...
|
||||
@@ -1 +1,3 @@
|
||||
|
||||
ERROR: unable to move: unable to parse dependency: pyspi >> 0.6.1-1.3)
|
||||
Loading packages...
|
||||
@@ -83,6 +83,9 @@ class ImportRepo5Test(BaseTest):
|
||||
runCmd = "aptly repo import wheezy-contrib repo1 'pyspi >> 0.6.1-1.3)'"
|
||||
expectedCode = 1
|
||||
|
||||
def output_processor(self, output):
|
||||
return "\n".join(sorted(output.split("\n")))
|
||||
|
||||
|
||||
class ImportRepo6Test(BaseTest):
|
||||
"""
|
||||
|
||||
@@ -53,6 +53,9 @@ class CopyRepo3Test(BaseTest):
|
||||
runCmd = "aptly repo copy -with-deps repo1 repo2 'pyspi (>> 0.6.1-1.3)' libboost-program-options-dev_1.49.0.1_i386"
|
||||
expectedCode = 1
|
||||
|
||||
def output_processor(self, output):
|
||||
return "\n".join(sorted(output.split("\n")))
|
||||
|
||||
|
||||
class CopyRepo4Test(BaseTest):
|
||||
"""
|
||||
@@ -86,6 +89,9 @@ class CopyRepo5Test(BaseTest):
|
||||
runCmd = "aptly repo copy repo1 repo2 'pyspi >> 0.6.1-1.3)'"
|
||||
expectedCode = 1
|
||||
|
||||
def output_processor(self, output):
|
||||
return "\n".join(sorted(output.split("\n")))
|
||||
|
||||
|
||||
class CopyRepo6Test(BaseTest):
|
||||
"""
|
||||
|
||||
@@ -53,6 +53,9 @@ class MoveRepo3Test(BaseTest):
|
||||
runCmd = "aptly repo move -with-deps repo1 repo2 'pyspi (>> 0.6.1-1.3)' libboost-program-options-dev_1.49.0.1_i386"
|
||||
expectedCode = 1
|
||||
|
||||
def output_processor(self, output):
|
||||
return "\n".join(sorted(output.split("\n")))
|
||||
|
||||
|
||||
class MoveRepo4Test(BaseTest):
|
||||
"""
|
||||
@@ -86,6 +89,9 @@ class MoveRepo5Test(BaseTest):
|
||||
runCmd = "aptly repo move repo1 repo2 'pyspi >> 0.6.1-1.3)'"
|
||||
expectedCode = 1
|
||||
|
||||
def output_processor(self, output):
|
||||
return "\n".join(sorted(output.split("\n")))
|
||||
|
||||
|
||||
class MoveRepo6Test(BaseTest):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user