mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00
az-pim-cli: fix version command
This commit is contained in:
parent
70b8b393e3
commit
c0ac87829f
2 changed files with 39 additions and 3 deletions
|
@ -7,7 +7,6 @@
|
|||
buildPackages,
|
||||
nix-update-script,
|
||||
testers,
|
||||
az-pim-cli,
|
||||
}:
|
||||
buildGoModule (finalAttrs: {
|
||||
pname = "az-pim-cli";
|
||||
|
@ -20,12 +19,24 @@ buildGoModule (finalAttrs: {
|
|||
hash = "sha256-gf4VscHaUr3JtsJO5PAq1nyPeJxIwGPaiH/QdXKpvQ0=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
# removes info we don't have from version command
|
||||
./version-build-info.patch
|
||||
];
|
||||
|
||||
vendorHash = "sha256-PHrpUlAG/PBe3NKUGBQ1U7dCcqkSlErWX2dp9ZPB3+8=";
|
||||
|
||||
nativeBuildInputs = [
|
||||
installShellFiles
|
||||
];
|
||||
|
||||
env.CGO_ENABLED = 0;
|
||||
|
||||
ldflags = [
|
||||
"-s"
|
||||
"-X github.com/netr0m/az-pim-cli/cmd.version=v${finalAttrs.version}"
|
||||
];
|
||||
|
||||
postInstall = lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) (
|
||||
let
|
||||
emulator = stdenv.hostPlatform.emulator buildPackages;
|
||||
|
@ -41,8 +52,9 @@ buildGoModule (finalAttrs: {
|
|||
passthru = {
|
||||
updateScript = nix-update-script { };
|
||||
tests.version = testers.testVersion {
|
||||
command = "HOME=$TMPDIR az-pim-cli --version";
|
||||
package = az-pim-cli;
|
||||
command = "HOME=$TMPDIR az-pim-cli version";
|
||||
package = finalAttrs.finalPackage;
|
||||
version = "v${finalAttrs.version}";
|
||||
};
|
||||
};
|
||||
|
||||
|
|
24
pkgs/by-name/az/az-pim-cli/version-build-info.patch
Normal file
24
pkgs/by-name/az/az-pim-cli/version-build-info.patch
Normal file
|
@ -0,0 +1,24 @@
|
|||
diff --git a/cmd/version.go b/cmd/version.go
|
||||
index 816f044..ef107be 100644
|
||||
--- a/cmd/version.go
|
||||
+++ b/cmd/version.go
|
||||
@@ -31,8 +31,7 @@ type BuildInfo struct {
|
||||
}
|
||||
|
||||
func (b BuildInfo) String() string {
|
||||
- return fmt.Sprintf("az-pim-cli version %s (built with %s from %s on %s)",
|
||||
- b.Version, b.GoVersion, b.Commit, b.Date)
|
||||
+ return fmt.Sprintf("az-pim-cli version %s", b.Version)
|
||||
}
|
||||
|
||||
func printVersion(w io.Writer, info BuildInfo) {
|
||||
@@ -47,8 +46,8 @@ func createBuildInfo() BuildInfo {
|
||||
Date: date,
|
||||
}
|
||||
|
||||
- buildInfo, available := debug.ReadBuildInfo()
|
||||
- if !available {
|
||||
+ buildInfo, _ := debug.ReadBuildInfo()
|
||||
+ if true {
|
||||
return info
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue