Skip to content
This repository was archived by the owner on Feb 4, 2026. It is now read-only.

Commit 01e3771

Browse files
committed
fix: install locked version instead of latest
1 parent dae470d commit 01e3771

File tree

3 files changed

+61
-8
lines changed

3 files changed

+61
-8
lines changed

cmd/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func downloadAsset(pkg *spec.Package, assetPath *spec.AssetPath) (*assets.Asset,
126126

127127
// validateAsset checks if the asset is valid.
128128
func validateAsset(pkg *spec.Package, asset *assets.Asset) error {
129-
checksumStr, ok := pkg.Checksums[asset.Name]
129+
checksumStr, ok := pkg.Assets.Checksums[asset.Name]
130130
if !ok {
131131
debug("spec is missing asset checksum")
132132
return nil

cmd/install.go

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@ func InstallAll(args []string) error {
2626

2727
errCount := 0
2828
for _, pkg := range lck.Packages {
29-
path := pkg.Specfile
30-
if path == "" {
31-
debug("missing specfile for %s, falling back to name/owner", pkg.FullName())
32-
path = pkg.FullName()
33-
}
34-
err = installPackage(path)
29+
err = installLockedPackage(pkg)
3530
if err != nil {
3631
errCount += 1
3732
log("! %s", err)
@@ -111,3 +106,61 @@ func installPackage(path string) error {
111106
log("✓ installed package %s to %s", pkg.FullName(), dir)
112107
return nil
113108
}
109+
110+
// installLockedPackage installs a specific version of a package from the lockfile.
111+
func installLockedPackage(lckPkg *spec.Package) error {
112+
path := lckPkg.Specfile
113+
if path == "" {
114+
debug("missing specfile for %s, falling back to name/owner", lckPkg.FullName())
115+
path = lckPkg.FullName()
116+
}
117+
118+
log("> installing %s...", path)
119+
120+
pkg, err := readSpec(path)
121+
if err != nil {
122+
return err
123+
}
124+
125+
// lock the version
126+
debug("locked version = %s", lckPkg.Version)
127+
pkg.Version = lckPkg.Version
128+
pkg.Assets = lckPkg.Assets
129+
130+
if !hasNewVersion(pkg) {
131+
log("✓ already at the %s version", pkg.Version)
132+
return nil
133+
}
134+
135+
assetPath, err := buildAssetPath(pkg)
136+
if err != nil {
137+
return err
138+
}
139+
140+
asset, err := downloadAsset(pkg, assetPath)
141+
if err != nil {
142+
return err
143+
}
144+
145+
err = validateAsset(pkg, asset)
146+
if err != nil {
147+
return err
148+
}
149+
150+
err = unpackAsset(pkg, asset)
151+
if err != nil {
152+
return err
153+
}
154+
155+
err = installFiles(pkg, asset)
156+
if err != nil {
157+
return err
158+
}
159+
160+
// no need to add the package to the lockfile,
161+
// it's already there
162+
163+
dir := spec.Dir(workDir, pkg.Owner, pkg.Name)
164+
log("✓ installed package %s to %s", pkg.FullName(), dir)
165+
return nil
166+
}

internal/spec/specfile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ type Package struct {
7575
Description string `json:"description,omitempty"`
7676
Keywords []string `json:"keywords,omitempty"`
7777
Symbols []string `json:"symbols,omitempty"`
78-
Assets `json:"assets"`
78+
Assets Assets `json:"assets"`
7979
}
8080

8181
// Assets are archives of package files, each for a specific platform.

0 commit comments

Comments
 (0)