Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
438 changes: 437 additions & 1 deletion apt_test.go

Large diffs are not rendered by default.

36 changes: 32 additions & 4 deletions buildtools/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
alpinecommand "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/alpine"
aptcommand "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/apt"
cargocommand "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/cargo"
aptflex "github.com/jfrog/build-info-go/flexpack/apt"
conancommand "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/conan"
nixcommand "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/nix"
rubycommandexec "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/ruby"
Expand Down Expand Up @@ -2360,9 +2361,20 @@ func AptCmd(c *cli.Context) error {
if err != nil {
return err
}
// Strip build flags so they aren't passed through to apt-get. Build-info
// collection is out of scope for the auth flow.
filteredArgs, _, err := build.ExtractBuildDetailsFromArgs(args)
args, fromFile, err := coreutils.ExtractStringOptionFromArgs(args, "from-file")
if err != nil {
return err
}
// Expand --from-file: inject package names after the "install" subcommand.
if fromFile != "" {
pkgs, err := aptflex.ReadPackagesFile(fromFile)
if err != nil {
return fmt.Errorf("--from-file %s: %w", fromFile, err)
}
args = injectPackagesAfterInstall(args, pkgs)
}
// Extract build flags (--build-name, --build-number, --module, --project).
filteredArgs, buildConfiguration, err := build.ExtractBuildDetailsFromArgs(args)
if err != nil {
return err
}
Expand All @@ -2388,14 +2400,30 @@ func AptCmd(c *cli.Context) error {
SetTrusted(trusted).
SetRepoName(repoName).
SetDist(dist).
SetComponent(component)
SetComponent(component).
SetBuildConfiguration(buildConfiguration)
if serverDetails != nil {
cmd.SetServerDetails(serverDetails)
}

return commands.ExecWithPackageManager(cmd, "apt")
}

// injectPackagesAfterInstall inserts pkgs into args immediately after the
// "install" subcommand token. If "install" is not present, pkgs are appended.
func injectPackagesAfterInstall(args, pkgs []string) []string {
for i, a := range args {
if a == "install" {
result := make([]string, 0, len(args)+len(pkgs))
result = append(result, args[:i+1]...)
result = append(result, pkgs...)
result = append(result, args[i+1:]...)
return result
}
}
return append(args, pkgs...)
}

// aptSetupCmd handles 'jf setup apt' — writes a persistent sources.list entry.
func aptSetupCmd(c *cli.Context) error {
// --remove only needs root (enforced in Run); skip server/repo validation.
Expand Down
8 changes: 7 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,10 @@ require (

//replace github.com/ktrysmt/go-bitbucket => github.com/ktrysmt/go-bitbucket v0.9.80

// replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260604085947-7c110b77b4b4
// replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260729061834-1c527b8abaa6

//replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.54.2-0.20251007084958-5eeaa42c31a6

replace github.com/jfrog/jfrog-cli-artifactory => github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260910055841-3cfc8c3712e2

replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.13.1-0.20260901184543-ec0cffa4e661
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ github.com/jellydator/ttlcache/v3 v3.4.0 h1:YS4P125qQS0tNhtL6aeYkheEaB/m8HCqdMMP
github.com/jellydator/ttlcache/v3 v3.4.0/go.mod h1:Hw9EgjymziQD3yGsQdf1FqFdpp7YjFMd4Srg5EJlgD4=
github.com/jfrog/archiver/v3 v3.6.4 h1:qHAWCLKwo3+ocHNNoWzGZ8ESl8QQk/lR3W09Pt+ROvE=
github.com/jfrog/archiver/v3 v3.6.4/go.mod h1:5V9l+Fte30Y4qe9dUOAd3yNTf8lmtVNuhKNrvI8PMhg=
github.com/jfrog/build-info-go v1.13.1-0.20260828071122-bb92ab7ba69b h1:kQRepoHjiJWwDx14CkrfBlfRHaHWf77XXWogqoMsVzU=
github.com/jfrog/build-info-go v1.13.1-0.20260828071122-bb92ab7ba69b/go.mod h1:CYRUCvLKfyARjoJXLWAxce1qNUxTEtbRKAARkV42vpE=
github.com/jfrog/build-info-go v1.13.1-0.20260901184543-ec0cffa4e661 h1:Iy9U1t1E961l7sCTuOs3xGYP3pXFxQNxgxMxzHdJaLE=
github.com/jfrog/build-info-go v1.13.1-0.20260901184543-ec0cffa4e661/go.mod h1:CYRUCvLKfyARjoJXLWAxce1qNUxTEtbRKAARkV42vpE=
github.com/jfrog/froggit-go v1.23.1 h1:4wmaHeuptxVINbovMaeITzVhi3+VQoc/FFIjF4axzu0=
github.com/jfrog/froggit-go v1.23.1/go.mod h1:wRDryqyp3oe+eHgME2mpnEQmO8XBECIPagFwj0nHmdI=
github.com/jfrog/go-mockhttp v0.3.1 h1:/wac8v4GMZx62viZmv4wazB5GNKs+GxawuS1u3maJH8=
Expand All @@ -402,8 +402,8 @@ github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYL
github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w=
github.com/jfrog/jfrog-cli-application v1.0.2-0.20260621072921-cadb78770a3e h1:jUfQzLCVbUazw7FEXf3+57vQheDSHa/Px/Gp4pf/sNI=
github.com/jfrog/jfrog-cli-application v1.0.2-0.20260621072921-cadb78770a3e/go.mod h1:p8yLtbmCxxQucIbLZKnWu0F+EDtj6NLXbRQCEK/nb6o=
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260901141441-82d1b03bc083 h1:jjHlAgpi9jQMN1mhCqMmb2RnoxACSrpBks/CHNV0CGo=
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260901141441-82d1b03bc083/go.mod h1:g3l9tPAVq/3cYRfhNEsy9TXuvK1kvt5YUSMuWKTKyUg=
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260910055841-3cfc8c3712e2 h1:KWXseNzikekPCN9gSd2sGB6Ox07KW0o+iGyJj1SZ4jM=
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260910055841-3cfc8c3712e2/go.mod h1:ojLACy/rvlJ0SHWo8hZLFjG1Jwu/kYamPRmeNWCHHlQ=
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260827111619-bee4d60fbdc7 h1:4ytBkQB+iBS/KbG+a974hiZbmTith6KuWa5g0Zvw+z4=
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260827111619-bee4d60fbdc7/go.mod h1:vuARjRZopsCqVcZmWzCgw5Pr9QD1FWvwFxijV4bvJJI=
github.com/jfrog/jfrog-cli-evidence v0.9.5-0.20260618135203-4d2bdd4ee35f h1:MV4BATdkEoUYJmdPDvaB9EBb8JQZg28n/K4X7dcmyAY=
Expand Down
1 change: 1 addition & 0 deletions testdata/apt_debian_remote_repository_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"rclass": "remote",
"packageType": "debian",
"url": "http://deb.debian.org/debian",
"debianDefaultArchitectures": "arm64,amd64",
"repoLayoutRef": "simple-default",
"xrayIndex": false
}
1 change: 1 addition & 0 deletions testdata/apt_remote_repository_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"rclass": "remote",
"packageType": "debian",
"url": "http://archive.ubuntu.com/ubuntu",
"debianDefaultArchitectures": "amd64",
"repoLayoutRef": "simple-default",
"xrayIndex": false
}
1 change: 1 addition & 0 deletions testdata/apt_virtual_repository_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"rclass": "virtual",
"packageType": "debian",
"repositories": ["${APT_LOCAL_REPO}", "${APT_REMOTE_REPO}", "${APT_DEBIAN_REMOTE_REPO}"],
"debianDefaultArchitectures": "arm64,amd64",
"repoLayoutRef": "simple-default",
"defaultDeploymentRepo": "${APT_LOCAL_REPO}"
}
1 change: 1 addition & 0 deletions utils/tests/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ var (
AptRemoteRepo = "cli-apt-remote"
AptDebianRemoteRepo = "cli-apt-debian-remote"
AptVirtualRepo = "cli-apt-virtual"
AptBuildName = "cli-apt-build"
PoetryLocalRepo = "cli-poetry-local"
PoetryRemoteRepo = "cli-poetry-remote"
PoetryVirtualRepo = "cli-poetry-virtual"
Expand Down
2 changes: 2 additions & 0 deletions utils/tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ func GetBuildNames() []string {
TestPipenv: {&PipenvBuildName},
TestPoetry: {&PoetryBuildName},
TestUv: {&UvBuildName},
TestApt: {&AptBuildName},
TestNix: {&NixBuildName},
TestCargo: {&CargoBuildName},
TestAlpine: {&AlpineBuildName},
Expand Down Expand Up @@ -707,6 +708,7 @@ func AddTimestampToGlobalVars() {
AptRemoteRepo += uniqueSuffix
AptDebianRemoteRepo += uniqueSuffix
AptVirtualRepo += uniqueSuffix
AptBuildName += uniqueSuffix
ConanLocalRepo += uniqueSuffix
ConanRemoteRepo += uniqueSuffix
ConanVirtualRepo += uniqueSuffix
Expand Down
Loading