@@ -36,6 +36,7 @@ import (
3636 "strings"
3737
3838 "gocloud.dev/blob"
39+ "golang.org/x/crypto/openpgp/clearsign"
3940 "zombiezen.com/go/aptblob/internal/deb"
4041)
4142
@@ -196,7 +197,7 @@ func uploadSourcePackage(ctx context.Context, bucket *blob.Bucket, dscPath strin
196197 if err != nil {
197198 return nil , fmt .Errorf ("upload source package %s: %w" , packageName , err )
198199 }
199- p := deb .NewParser (bytes .NewReader (dsc ))
200+ p := deb .NewParser (bytes .NewReader (maybeClearSigned ( dsc ) ))
200201 p .Fields = deb .SourceControlFields
201202 if ! p .Single () {
202203 if err := p .Err (); err != nil {
@@ -211,6 +212,11 @@ func uploadSourcePackage(ctx context.Context, bucket *blob.Bucket, dscPath strin
211212 if err != nil {
212213 return nil , fmt .Errorf ("upload source package %s: files: %w" , packageName , err )
213214 }
215+
216+ _ , err = upload (ctx , bucket , dir + "/" + filepath .Base (dscPath ), "text/plain; charset=utf-8" , "immutable" , bytes .NewReader (dsc ))
217+ if err != nil {
218+ return nil , fmt .Errorf ("upload source package %s: %s: %w" , packageName , filepath .Base (dscPath ), err )
219+ }
214220 for _ , sig := range files {
215221 fname := sig .Filename
216222 contentType := mime .TypeByExtension (slashpath .Ext (fname ))
@@ -230,6 +236,16 @@ func uploadSourcePackage(ctx context.Context, bucket *blob.Bucket, dscPath strin
230236 return pkg , nil
231237}
232238
239+ // maybeClearSigned returns the plaintext of a file that may or may not be
240+ // wrapped in GPG clear-signed armor.
241+ func maybeClearSigned (data []byte ) []byte {
242+ block , _ := clearsign .Decode (data )
243+ if block == nil {
244+ return data
245+ }
246+ return block .Plaintext
247+ }
248+
233249// promotePackageField ensures the Package field is the first in the paragraph.
234250// It modifies the paragraph in-place.
235251//
0 commit comments