This document details exit codes for APT (Advanced Package Tool) commands used in syspkg.
APT uses a simple binary exit code system:
- 0: Success
- 100: Any error occurred
- 1: Special case (apt run without options)
From Debian APT source code (cmdline/apt.cc):
- Returns 100 on failure, 0 on success
- Multiple
exit(100)statements throughout codebase for various errors - No specific exit codes for different error types
# No packages found - returns SUCCESS
$ apt search nonexistentpackage123456
$ echo $? # Returns: 0
# Invalid option - returns ERROR
$ apt search --invalid-option
$ echo $? # Returns: 100apt-get updatefailures: 100apt-get installfailures: 100- Repository errors: 100
- Network errors: 100
BUG: Our code incorrectly assumes:
// WRONG: APT search does NOT return 100 for "no packages found"
if exitError.ExitCode() == 100 {
// No packages found, return empty list
return []manager.PackageInfo{}, nil
}Reality:
- APT search returns 0 when no packages found
- APT search returns 100 only on actual errors (invalid options, etc.)
APT also uses dpkg-query which has different exit codes:
- 0: Success
- 1: Package not found (normal condition)
- 2: Serious error
Example:
// Current code in utils.go handles this correctly:
if exitErr.ExitCode() != 1 && !strings.Contains(string(out), "no packages found matching") {
return nil, fmt.Errorf("command failed with output: %s", string(out))
}- Fix search exit code handling: Remove incorrect 100 handling
- Test each command: APT uses different tools with different codes
- No generic helpers: APT behavior is unique
# Test in Ubuntu container
docker run --rm ubuntu:22.04 bash -c 'apt search test; echo $?'
docker run --rm ubuntu:22.04 bash -c 'apt search --invalid; echo $?'