-
Notifications
You must be signed in to change notification settings - Fork 46
Change PGP signature file extension from .sig to .asc #2348
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
Open
gdams
wants to merge
2
commits into
microsoft/main
Choose a base branch
from
dev/gadams/sig
base: microsoft/main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+33
−12
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ import ( | |
| "log" | ||
| "os" | ||
| "path/filepath" | ||
| "strconv" | ||
| "strings" | ||
| ) | ||
|
|
||
|
|
@@ -94,8 +95,22 @@ func (a *archive) latestPath() string { | |
| return a.path | ||
| } | ||
|
|
||
| func (a *archive) sigPath() string { | ||
| return filepath.Join(a.workDir, a.name+".sig") | ||
| // legacySigNeeded reports whether this archive needs a legacy .sig file | ||
| // in addition to the .asc file, for backward compatibility with go1.26 and earlier. | ||
| func (a *archive) legacySigNeeded() bool { | ||
| // Archive names look like "go1.27.linux-amd64.tar.gz" or "go1.26.3.src.tar.gz". | ||
| if after, ok := strings.CutPrefix(a.name, "go1."); ok { | ||
| if dot := strings.IndexByte(after, '.'); dot > 0 { | ||
| if minor, err := strconv.Atoi(after[:dot]); err == nil && minor <= 26 { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're in microsoft/go, so we know what version we're building based on what branch we're in. It isn't necessary to parse the version, and simplifying it leaves the intent clearer. |
||
| return true | ||
| } | ||
| } | ||
| } | ||
|
gdams marked this conversation as resolved.
|
||
| return false | ||
| } | ||
|
|
||
| func (a *archive) ascPath() string { | ||
| return filepath.Join(a.workDir, a.name+".asc") | ||
| } | ||
|
|
||
| func (a *archive) macHardenPackPath() string { | ||
|
|
@@ -428,18 +443,18 @@ func (a *archive) prepareArchiveSignatures(ctx context.Context) ([]*fileToSign, | |
| if err := ctx.Err(); err != nil { | ||
| return nil, err | ||
| } | ||
| // Copy the archive file to have .sig suffix, e.g. "tar.gz" to "tar.gz.sig". The signing | ||
| // process sends the "tar.gz.sig" file to get a signature, then replaces the "tar.gz.sig" | ||
| // file's content in-place with the result. We need to preemptively make a renamed copy of the | ||
| // file so we end up with both the original file and sig on the machine. | ||
| log.Printf("Copying file for signature generation: %q -> %q", a.latestPath(), a.sigPath()) | ||
| if err := copyFile(a.sigPath(), a.latestPath()); err != nil { | ||
| // Copy the archive file with an ".asc" suffix. The signing process sends this file to get a | ||
| // signature, then replaces its content in-place with the result. We need to preemptively make | ||
| // a renamed copy of the file so we end up with both the original file and signature on the | ||
| // machine. | ||
| log.Printf("Copying file for signature generation: %q -> %q", a.latestPath(), a.ascPath()) | ||
| if err := copyFile(a.ascPath(), a.latestPath()); err != nil { | ||
| return nil, err | ||
| } | ||
| return []*fileToSign{ | ||
| { | ||
| originalPath: a.path, | ||
| fullPath: a.sigPath(), | ||
| fullPath: a.ascPath(), | ||
| authenticode: "LinuxSignManagedLanguageCompiler", | ||
| }, | ||
| }, nil | ||
|
|
@@ -458,9 +473,15 @@ func (a *archive) copyToDestination(ctx context.Context) error { | |
| if err := copyFile(filepath.Join(*destinationDir, a.name), a.latestPath()); err != nil { | ||
| return err | ||
| } | ||
| if err := copyFile(filepath.Join(*destinationDir, a.name+".sig"), a.sigPath()); err != nil { | ||
| if err := copyFile(filepath.Join(*destinationDir, a.name+".asc"), a.ascPath()); err != nil { | ||
| return err | ||
| } | ||
| // For go1.26 and earlier, also produce a .sig file for backward compatibility. | ||
| if a.legacySigNeeded() { | ||
| if err := copyFile(filepath.Join(*destinationDir, a.name+".sig"), a.ascPath()); err != nil { | ||
| return err | ||
| } | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the plan here is to break it in 1.27? Note that this breaks download tools, not only individual users' workflows. I don't think we should do this break, especially without already establishing simultaneous publishing for a while to allow for time to move.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear: I think that publishing both
.sigand.ascmakes sense. We can then use.ascin our own infra to reduce patching. I don't know if it ever makes sense to stop publishing.sig, though..sigis actually a more intuitive extension to slap on our download URLs to get a signature. It might actually be better to treat.ascas a "compatibility" signature, not even the main one.Users of Go don't even necessarily know about
.ascfrom upstream (my old note on #181):