-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
RPM Packaging support #3265
Open
istiak101
wants to merge
6
commits into
wailsapp:v3-alpha
Choose a base branch
from
istiak101:v3-alpha
base: v3-alpha
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
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.
+178
−3
Open
RPM Packaging support #3265
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8401bcf
RPM Packaging support
istiak101 412a35a
Update changelog.mdx
istiak101 5ea58c3
Merge branch 'wailsapp:v3-alpha' into v3-alpha
istiak101 9a6b1ca
Remove not needed variables
istiak101 34934c3
Merge branch 'v3-alpha' into v3-alpha
leaanthony 059293e
Merge branch 'v3-alpha' into v3-alpha
leaanthony File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
%global debug_package %{nil} | ||
|
||
Name: @NAME@ | ||
Summary: @SUMMARY@ | ||
Version: @VERSION@ | ||
Release: @RPM_RELEASE@%{?dist} | ||
License: @LICENSE@ | ||
|
||
Source0: %{name} | ||
Source1: %{name}.desktop | ||
Source2: %{name}.png | ||
|
||
%description | ||
@DESCRIPTION@ | ||
|
||
%install | ||
mkdir -p %{buildroot}%{_bindir} %{buildroot}%{_datadir}/{applications,pixmaps} | ||
|
||
cp %{SOURCE0} %{buildroot}%{_bindir}/%{name} | ||
cp %{SOURCE1} %{buildroot}%{_datadir}/applications/%{name}.desktop | ||
cp %{SOURCE2} %{buildroot}%{_datadir}/pixmaps/%{name}.png | ||
|
||
%post | ||
# Install the desktop entry | ||
update-desktop-database &> /dev/null || : | ||
|
||
%postun | ||
# Uninstall the desktop entry | ||
update-desktop-database &> /dev/null || : | ||
|
||
|
||
%files | ||
%{_bindir}/%{name} | ||
%{_datadir}/applications/%{name}.desktop | ||
%{_datadir}/pixmaps/%{name}.png | ||
|
||
|
||
%changelog | ||
* @RELEASE_DATE@ @AUTHOR@ <@AUTHOR_EMAIL@> - %{version}-%{release} | ||
- Initial build |
This file contains 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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package commands | ||
|
||
import ( | ||
_ "embed" | ||
"errors" | ||
"fmt" | ||
"github.com/pterm/pterm" | ||
"github.com/wailsapp/wails/v3/internal/s" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
type GenerateRPMOptions struct { | ||
Binary string `description:"The binary to package including path"` | ||
Icon string `description:"Path to the icon"` | ||
DesktopFile string `description:"Path to the desktop file"` | ||
OutputDir string `description:"Path to the output directory" default:"."` | ||
BuildDir string `description:"Path to the build directory"` | ||
} | ||
|
||
func GenerateRPM(options *GenerateRPMOptions) error { | ||
|
||
defer func() { | ||
pterm.DefaultSpinner.Stop() | ||
}() | ||
|
||
if options.Binary == "" { | ||
return fmt.Errorf("binary not provided") | ||
} | ||
if options.Icon == "" { | ||
return fmt.Errorf("icon path not provided") | ||
} | ||
if options.DesktopFile == "" { | ||
return fmt.Errorf("desktop file path not provided") | ||
} | ||
if options.BuildDir == "" { | ||
// Create temp directory | ||
var err error | ||
options.BuildDir, err = os.MkdirTemp("", "wails-rpm-*") | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
var err error | ||
options.OutputDir, err = filepath.Abs(options.OutputDir) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
pterm.Println(pterm.LightYellow("RPM Generator v1.0.0")) | ||
|
||
return generateRPM(options) | ||
} | ||
|
||
func generateRPM(options *GenerateRPMOptions) error { | ||
numberOfSteps := 5 | ||
p, _ := pterm.DefaultProgressbar.WithTotal(numberOfSteps).WithTitle("Generating RPM").Start() | ||
|
||
// Get the last path of the binary and normalise the name | ||
name := normaliseName(filepath.Base(options.Binary)) | ||
|
||
log(p, "Preparing RPMBUILD Directory: "+options.BuildDir) | ||
|
||
sources := filepath.Join(options.BuildDir, "SOURCES") | ||
s.MKDIR(sources) | ||
s.COPY(options.Binary, sources) | ||
s.COPY(options.DesktopFile, sources) | ||
s.COPY(filepath.Join(options.BuildDir, name+".png"), sources) | ||
s.CHMOD(filepath.Join(sources, filepath.Base(options.Binary)), 0755) | ||
|
||
// Build RPM | ||
if !s.EXISTS("/usr/bin/rpmbuild") { | ||
return errors.New("You need to install \"rpm-build\" tool to build RPM.") | ||
} | ||
log(p, fmt.Sprintf("Running rpmbuild -bb --define \"_rpmdir %s\" --define \"_sourcedir %s\" %s.spec", options.BuildDir, sources, name)) | ||
_, err := s.EXEC(fmt.Sprintf("rpmbuild -bb --define \"_rpmdir %s\" --define \"_sourcedir %s\" %s.spec", options.BuildDir, sources, name)) | ||
if err != nil { | ||
fmt.Println(err.Error()) | ||
return err | ||
} | ||
|
||
log(p, "RPM created.") | ||
return nil | ||
} |
This file contains 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 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 |
---|---|---|
|
@@ -287,6 +287,7 @@ tasks: | |
vars: | ||
PRODUCTION: "true" | ||
cmds: | ||
- task: create:rpm | ||
- task: create:appimage | ||
|
||
create:appimage: | ||
|
@@ -301,7 +302,7 @@ tasks: | |
cmds: | ||
# Copy binary + icon to appimage dir | ||
- cp {{ "{{.APP_BINARY}}" }} {{ "{{.APP_NAME}}" }} | ||
- cp ../appicon.png appicon.png | ||
- cp ../appicon.png '{{ "{{.APP_NAME}}" }}.png' | ||
# Generate AppImage | ||
- wails3 generate appimage -binary {{ "{{.APP_NAME}}" }} -icon {{ "{{.ICON}}" }} -desktopfile {{ "{{.DESKTOP_FILE}}" }} -outputdir {{ "{{.OUTPUT_DIR}}" }} -builddir {{ "{{.ROOT_DIR}}" }}/build/appimage | ||
vars: | ||
|
@@ -311,17 +312,61 @@ tasks: | |
DESKTOP_FILE: '{{ "{{.APP_NAME}}" }}.desktop' | ||
OUTPUT_DIR: '../../bin' | ||
|
||
create:rpm: | ||
summary: Creates a RPM package | ||
dir: build/rpm | ||
platforms: [ linux ] | ||
deps: | ||
- task: build:linux | ||
vars: | ||
PRODUCTION: "true" | ||
- task: generate:linux:dotdesktop | ||
cmds: | ||
# Copy binary + icon to rpmbuild dir | ||
- cp {{ "{{.APP_BINARY}}" }} {{ "{{.APP_NAME}}" }} | ||
- cp ../appicon.png '{{ "{{.APP_NAME}}" }}.png' | ||
- cp ../rpm/app.spec '{{ "{{.APP_NAME}}" }}.spec' | ||
- sed -i -e 's/@NAME@/{{ "{{.APP_NAME}}" }}/g' | ||
-e 's/@SUMMARY@/{{ "{{.APP_SUMMARY}}" }}/g' | ||
-e 's/@VERSION@/{{ "{{.APP_VERSION}}" }}/g' | ||
-e 's/@RPM_RELEASE@/{{ "{{.RPM_RELEASE}}" }}/g' | ||
-e 's/@DESCRIPTION@/{{ "{{.APP_DESC}}" }}/g' | ||
-e 's/@AUTHOR@/{{ "{{.APP_AUTHOR}}" }}/g' | ||
-e 's/@AUTHOR_EMAIL@/{{ "{{.AUTHOR_EMAIL}}" }}/g' | ||
-e 's/@LICENSE@/{{ "{{.APP_LICENSE}}" }}/g' | ||
-e 's/@RELEASE_DATE@/{{ "{{.RELEASE_DATE}}" }}/g' | ||
{{ "{{.APP_NAME}}" }}.spec | ||
# Generate RPM | ||
- wails3 generate rpm -binary {{ "{{.APP_NAME}}" }} -icon {{ "{{.ICON}}" }} -desktopfile {{ "{{.DESKTOP_FILE}}" }} -outputdir {{ "{{.OUTPUT_DIR}}" }} -builddir {{ "{{.ROOT_DIR}}" }}/build/rpm | ||
- mv {{ "{{.ROOT_DIR}}" }}/build/rpm/$(uname -m)/*.rpm {{ "{{.OUTPUT_DIR}}" }} | ||
vars: | ||
APP_SUMMARY: 'Hello Wails' | ||
APP_VERSION: '1.0.0' | ||
RPM_RELEASE: '1' | ||
APP_DESC: 'Hello Wails is demo application developed on Wails.' | ||
APP_URL: 'https://github.com/wailsapp/wails' | ||
APP_AUTHOR: "Lea Anthony" | ||
AUTHOR_EMAIL: "[email protected]" | ||
APP_LICENSE: "MIT" | ||
APP_BINARY: '../../bin/{{ "{{.APP_NAME}}" }}' | ||
RELEASE_DATE: {{ "'{{now | date \"Mon Jan 02 2006\"}}'" }} | ||
ICON: '../appicon.png' | ||
DESKTOP_FILE: '{{ "{{.APP_NAME}}" }}.desktop' | ||
OUTPUT_DIR: '../../bin' | ||
|
||
generate:linux:dotdesktop: | ||
summary: Generates a `.desktop` file | ||
dir: build | ||
sources: | ||
- "appicon.png" | ||
generates: | ||
- '{{ "{{.ROOT_DIR}}"}}/build/appimage/{{ "{{.APP_NAME}}" }}.desktop' | ||
- '{{ "{{.ROOT_DIR}}"}}/build/rpm/{{ "{{.APP_NAME}}" }}.desktop' | ||
cmds: | ||
- mkdir -p {{ "{{.ROOT_DIR}}"}}/build/appimage | ||
- mkdir -p {{ "{{.ROOT_DIR}}"}}/build/{appimage,rpm} | ||
# Run `wails3 generate .desktop -help` for all the options | ||
- wails3 generate .desktop -name "{{ "{{.APP_NAME}}" }}" -exec "{{ "{{.EXEC}}" }}" -icon "{{ "{{.ICON}}" }}" -outputfile {{ "{{.ROOT_DIR}}"}}/build/appimage/{{ "{{.APP_NAME}}" }}.desktop -categories "{{ "{{.CATEGORIES}}" }}" | ||
- wails3 generate .desktop -name "{{ "{{.APP_NAME}}" }}" -exec "{{ "{{.EXEC}}" }}" -icon "{{ "{{.ICON}}" }}" -outputfile {{ "{{.ROOT_DIR}}"}}/build/rpm/{{ "{{.APP_NAME}}" }}.desktop -categories "{{ "{{.CATEGORIES}}" }}" | ||
# -comment "A comment" | ||
# -terminal "true" | ||
# -version "1.0" | ||
|
@@ -333,7 +378,7 @@ tasks: | |
vars: | ||
APP_NAME: '{{ "{{.APP_NAME}}" }}' | ||
EXEC: '{{ "{{.APP_NAME}}" }}' | ||
ICON: 'appicon' | ||
ICON: '{{ "{{.APP_NAME}}" }}' | ||
CATEGORIES: 'Development;' | ||
OUTPUTFILE: '{{ "{{.ROOT_DIR}}"}}/build/appimage/{{ "{{.APP_NAME}}" }}.desktop' | ||
|
||
|
This file contains 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.
I think it would be worth passing in the subdirectory to this task rather than doing both. An example of this:
Call with:
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.
I am not sure what do you mean. I am quite dumb to be honest. Do you want me to generate rpm separately?