Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

garble: fix build #345252

Merged
merged 2 commits into from
Nov 3, 2024
Merged
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
38 changes: 38 additions & 0 deletions pkgs/by-name/ga/garble/0001-Add-version-info.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
From e46a41faac008ede4acbeb18db5b3076eb206de5 Mon Sep 17 00:00:00 2001
From: wxt <[email protected]>
Date: Sun, 3 Nov 2024 15:11:49 +0800
Subject: [PATCH] Add version info

---
main.go | 1 +
testdata/script/help.txtar | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/main.go b/main.go
index 0de5a2f..1c830b1 100644
--- a/main.go
+++ b/main.go
@@ -362,6 +362,7 @@ func mainErr(args []string) error {
// manually construct something like a pseudo-version.
// TODO: remove when this code is dead, hopefully in Go 1.22.
if mod.Version == "(devel)" {
+ mod.Version = "@version@"
var vcsTime time.Time
var vcsRevision string
for _, setting := range info.Settings {
diff --git a/testdata/script/help.txtar b/testdata/script/help.txtar
index 8f25260..859f492 100644
--- a/testdata/script/help.txtar
+++ b/testdata/script/help.txtar
@@ -91,7 +91,7 @@ stderr 'directory not found'
# and to be able to use static VCS info, use an environment variable.
# First, test without the information, and then with it.
exec garble version
-stdout -count=1 'mvdan.cc/garble \(devel\)'
+stdout -count=1 'mvdan.cc/garble @version@'
stdout -count=1 'Build settings'
stdout -count=3 '-compiler|GOOS|GOARCH'
! stdout 'vcs'
--
2.46.1

77 changes: 77 additions & 0 deletions pkgs/by-name/ga/garble/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
lib,
stdenv,
buildGoModule,
fetchFromGitHub,
diffoscope,
git,
versionCheckHook,
replaceVars,
nix-update-script,
}:

buildGoModule rec {
pname = "garble";
version = "0.13.0";

src = fetchFromGitHub {
owner = "burrowers";
repo = "garble";
rev = "refs/tags/v${version}";
hash = "sha256-FtI5lAeqjRPN47iC46bcEsRLQb7mItw4svsnLkRpNxY=";
};

__darwinAllowLocalNetworking = true;

ldflags = [
"-buildid=00000000000000000000" # length=20
];

patches = [
(replaceVars ./0001-Add-version-info.patch {
inherit version;
})
];

checkFlags = [
"-skip"
"TestScript/gogarble"
];

vendorHash = "sha256-mSdajYiMEg2ik0ocfmHK+XddEss1qLu6rDwzjocaaW0=";

# Used for some of the tests.
nativeCheckInputs = [
diffoscope
git
versionCheckHook
];

preCheck = ''
export HOME=$(mktemp -d)
export WORK=$(mktemp -d)
'';

# Several tests fail with
# FAIL: testdata/script/goenv.txtar:27: "$WORK/.temp 'quotes' and spaces" matches "garble|importcfg|cache\\.gob|\\.go"
doCheck = !stdenv.hostPlatform.isDarwin;

nativeInstallCheckInputs = [
versionCheckHook
];
versionCheckProgramArg = [ "version" ];
doInstallCheck = false;

passthru.updateScript = nix-update-script { };

meta = {
description = "Obfuscate Go code by wrapping the Go toolchain";
homepage = "https://github.com/burrowers/garble/";
maintainers = with lib.maintainers; [
davhau
bot-wxt1221
];
license = lib.licenses.bsd3;
mainProgram = "garble";
};
}
35 changes: 0 additions & 35 deletions pkgs/development/tools/garble/default.nix

This file was deleted.

2 changes: 0 additions & 2 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19450,8 +19450,6 @@ with pkgs;

ganv = callPackage ../development/libraries/ganv { };

garble = callPackage ../development/tools/garble { };

gcab = callPackage ../development/libraries/gcab { };

gcovr = with python3Packages; toPythonApplication gcovr;
Expand Down