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

Packages support file permissions and ownership #23

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,16 @@ jobs:
license: MPL-2.0
binary: ${{ steps.build.outputs.binary-path }}
bin_path: /usr/local/bin
file_permissions: 0o027

- name: dump RPM
run: |
echo "::group::maybe install rpm" 1>&2
Copy link

@jeanneryan jeanneryan Jun 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe install rpm

Is this a group name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, the group is just to hide the output from the package install if it happens, because that's almost never a part of the output we'll want to see. Click the twisty in the unlikely event you want to see oodles of output from apt 😆

Screenshot 2024-06-11 at 12 40 00

# runner is ubuntu, install rpm if it's not already available
which rpm || apt install -y rpm
echo "::endgroup::" 1>&2
rpm -qplv out/*.rpm

- name: dump deb
run: |
dpkg -c out/*.deb
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ inputs:
description: 'Path to install the binary at'
default: '/usr/bin'
required: false
file_permissions:
description: 'File permissions applied to all files in the package; specify in yaml/octal format: `0o022`; if empty, permissions are unmodified.'
default: ''
required: false
config_dir:
description: 'Directory of configs in desired filesystem structure.'
default: ''
Expand Down Expand Up @@ -177,6 +181,7 @@ runs:
INPUT_DEPENDS: ${{ inputs.depends }}
INPUT_BINARY: ${{ inputs.binary }}
INPUT_BIN_PATH: ${{ inputs.bin_path }}
INPUT_FILEPERMISSIONS: ${{ inputs.file_permissions }}
INPUT_CONFIG_DIR: ${{ inputs.config_dir }}
INPUT_PREINSTALL: ${{ inputs.preinstall }}
INPUT_POSTINSTALL: ${{ inputs.postinstall }}
Expand Down
66 changes: 36 additions & 30 deletions fpm_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ import (
)

type NfpmInput struct {
Name string
Arch string
Version string
Maintainer string
Vendor string
Description string
Homepage string
License string
Depends []string
Binary string
BinaryDest string
Preinstall string
Postinstall string
Preremove string
Postremove string
Name string
Arch string
Version string
Maintainer string
Vendor string
Description string
Homepage string
License string
Depends []string
Binary string
BinaryDest string
Preinstall string
Postinstall string
Preremove string
Postremove string
FilePermissions string

ConfigFiles []*ConfigFile
}
Expand Down Expand Up @@ -90,6 +91,7 @@ func main() {
inputPostinstall := os.Getenv("INPUT_POSTINSTALL")
inputPreremove := os.Getenv("INPUT_PREREMOVE")
inputPostremove := os.Getenv("INPUT_POSTREMOVE")
inputPermissions := os.Getenv("INPUT_FILEPERMISSIONS")

depends := strings.Split(inputDepends, ",")
if inputDepends == "" {
Expand All @@ -109,21 +111,22 @@ func main() {
}

input := &NfpmInput{
Name: inputName,
Arch: inputArch,
Version: inputVersion,
Maintainer: inputMaintainer,
Vendor: inputVendor,
Description: inputDescription,
Homepage: inputHomepage,
License: inputLicense,
Depends: depends,
Binary: inputBinary,
BinaryDest: binDest,
Preinstall: inputPreinstall,
Postinstall: inputPostinstall,
Preremove: inputPreremove,
Postremove: inputPostremove,
Name: inputName,
Arch: inputArch,
Version: inputVersion,
Maintainer: inputMaintainer,
Vendor: inputVendor,
Description: inputDescription,
Homepage: inputHomepage,
License: inputLicense,
Depends: depends,
Binary: inputBinary,
BinaryDest: binDest,
Preinstall: inputPreinstall,
Postinstall: inputPostinstall,
Preremove: inputPreremove,
Postremove: inputPostremove,
FilePermissions: inputPermissions,
}

input.ConfigFiles = findConfigs(inputConfigDir)
Expand Down Expand Up @@ -153,6 +156,9 @@ depends:
- {{ . }}
{{- end }}
{{- end }}
{{- if ne .FilePermissions "" }}
umask: {{ .FilePermissions }}
{{- end }}
contents:
{{- if ne .Binary "" }}
- src: {{ .Binary }}
Expand Down