Skip to content

Commit 2feafa8

Browse files
committed
Set file mode from request
Fall back to 0644 if not set.
1 parent 7a19a00 commit 2feafa8

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

‎deb/go.mod‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/gohugoio/hugoreleaser-archive-plugins/deb
33
go 1.19
44

55
require (
6-
github.com/gohugoio/hugoreleaser-plugins-api v0.5.0
6+
github.com/gohugoio/hugoreleaser-plugins-api v0.6.0
77
github.com/goreleaser/nfpm/v2 v2.18.1
88
)
99

‎deb/go.sum‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
6262
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
6363
github.com/gohugoio/hugoreleaser-plugins-api v0.5.0 h1:/jroeaa+w2q2ikeTiG8x7r721FbaWhvSrAM7uPFV7Ko=
6464
github.com/gohugoio/hugoreleaser-plugins-api v0.5.0/go.mod h1:DZbhdQL7/zopVHtEBJqWXOtscstfmbo9CAEIbG6tdd0=
65+
github.com/gohugoio/hugoreleaser-plugins-api v0.6.0 h1:U6cH8JKl/GhcThtFfsoIVOVSNq+iqZNGtUlnXnlxfKA=
66+
github.com/gohugoio/hugoreleaser-plugins-api v0.6.0/go.mod h1:DZbhdQL7/zopVHtEBJqWXOtscstfmbo9CAEIbG6tdd0=
6567
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
6668
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
6769
github.com/google/rpmpack v0.0.0-20220314092521-38642b5e571e h1:6Jn9JtfCn20uycra92LxTkq5yfBKNSFlRJPBk8/Cxhg=

‎deb/main.go‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package main
1616

1717
import (
1818
"io"
19+
"io/fs"
1920
"log"
2021
"os"
2122
"path/filepath"
@@ -86,12 +87,12 @@ type debArchivist struct {
8687
settings Settings
8788
}
8889

89-
func (a *debArchivist) Add(sourceFilename, targetPath string) error {
90+
func (a *debArchivist) Add(sourceFilename, targetPath string, mode fs.FileMode) error {
9091
a.files = append(a.files, &files.Content{
9192
Source: filepath.ToSlash(sourceFilename),
9293
Destination: targetPath,
9394
FileInfo: &files.ContentFileInfo{
94-
Mode: 0o755,
95+
Mode: mode,
9596
},
9697
})
9798

@@ -160,7 +161,10 @@ func createArchive(req archiveplugin.Request) error {
160161
}
161162

162163
for _, file := range req.Files {
163-
archivist.Add(file.SourcePathAbs, file.TargetPath)
164+
if file.Mode == 0 {
165+
file.Mode = 0644
166+
}
167+
archivist.Add(file.SourcePathAbs, file.TargetPath, file.Mode)
164168
}
165169

166170
return archivist.Finalize()

0 commit comments

Comments
 (0)