mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-08 05:50:47 +00:00
Fix race in fatal exit & context shutdown.
This commit is contained in:
@@ -9,9 +9,11 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var returnCode = 0
|
||||||
|
|
||||||
func fatal(err error) {
|
func fatal(err error) {
|
||||||
fmt.Printf("ERROR: %s\n", err)
|
fmt.Printf("ERROR: %s\n", err)
|
||||||
os.Exit(1)
|
returnCode = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadConfig(command *commander.Command) error {
|
func loadConfig(command *commander.Command) error {
|
||||||
@@ -50,26 +52,32 @@ func loadConfig(command *commander.Command) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
defer func() { os.Exit(returnCode) }()
|
||||||
|
|
||||||
command := cmd.RootCommand()
|
command := cmd.RootCommand()
|
||||||
|
|
||||||
err := command.Flag.Parse(os.Args[1:])
|
err := command.Flag.Parse(os.Args[1:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatal(err)
|
fatal(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = loadConfig(command)
|
err = loadConfig(command)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatal(err)
|
fatal(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = cmd.InitContext(command)
|
err = cmd.InitContext(command)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatal(err)
|
fatal(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
defer cmd.ShutdownContext()
|
defer cmd.ShutdownContext()
|
||||||
|
|
||||||
err = command.Dispatch(command.Flag.Args())
|
err = command.Dispatch(command.Flag.Args())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatal(err)
|
fatal(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
|
|
||||||
ERROR: unable to determine list of architectures, please specify explicitly
|
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)
|
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)
|
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
|
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)
|
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)'"
|
runCmd = "aptly repo import wheezy-contrib repo1 'pyspi >> 0.6.1-1.3)'"
|
||||||
expectedCode = 1
|
expectedCode = 1
|
||||||
|
|
||||||
|
def output_processor(self, output):
|
||||||
|
return "\n".join(sorted(output.split("\n")))
|
||||||
|
|
||||||
|
|
||||||
class ImportRepo6Test(BaseTest):
|
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"
|
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
|
expectedCode = 1
|
||||||
|
|
||||||
|
def output_processor(self, output):
|
||||||
|
return "\n".join(sorted(output.split("\n")))
|
||||||
|
|
||||||
|
|
||||||
class CopyRepo4Test(BaseTest):
|
class CopyRepo4Test(BaseTest):
|
||||||
"""
|
"""
|
||||||
@@ -86,6 +89,9 @@ class CopyRepo5Test(BaseTest):
|
|||||||
runCmd = "aptly repo copy repo1 repo2 'pyspi >> 0.6.1-1.3)'"
|
runCmd = "aptly repo copy repo1 repo2 'pyspi >> 0.6.1-1.3)'"
|
||||||
expectedCode = 1
|
expectedCode = 1
|
||||||
|
|
||||||
|
def output_processor(self, output):
|
||||||
|
return "\n".join(sorted(output.split("\n")))
|
||||||
|
|
||||||
|
|
||||||
class CopyRepo6Test(BaseTest):
|
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"
|
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
|
expectedCode = 1
|
||||||
|
|
||||||
|
def output_processor(self, output):
|
||||||
|
return "\n".join(sorted(output.split("\n")))
|
||||||
|
|
||||||
|
|
||||||
class MoveRepo4Test(BaseTest):
|
class MoveRepo4Test(BaseTest):
|
||||||
"""
|
"""
|
||||||
@@ -86,6 +89,9 @@ class MoveRepo5Test(BaseTest):
|
|||||||
runCmd = "aptly repo move repo1 repo2 'pyspi >> 0.6.1-1.3)'"
|
runCmd = "aptly repo move repo1 repo2 'pyspi >> 0.6.1-1.3)'"
|
||||||
expectedCode = 1
|
expectedCode = 1
|
||||||
|
|
||||||
|
def output_processor(self, output):
|
||||||
|
return "\n".join(sorted(output.split("\n")))
|
||||||
|
|
||||||
|
|
||||||
class MoveRepo6Test(BaseTest):
|
class MoveRepo6Test(BaseTest):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user