build: refactor makefile to be gnu compatible
All checks were successful
build and upload / build (push) Successful in 15s

This commit is contained in:
2025-05-03 01:01:02 +02:00
parent 9e3b8398ad
commit 6ea363a421
5 changed files with 311 additions and 31 deletions

1
.gitignore vendored
View File

@@ -7,3 +7,4 @@
target target
.idea .idea
completions.* completions.*
Makefile.config

View File

@@ -1,42 +1,42 @@
ifeq ($(CARGO_PKG_VERSION),) SHELL := /bin/sh
CARGO_PKG_VERSION := 0.0.0
endif
ifeq ($(APP_NAME),) PROJECT ?= $(shell grep "^name =" Cargo.toml | cut -d '"' -f 2)
APP_NAME := feddy VERSION ?= $(shell grep "^version =" Cargo.toml | cut -d '"' -f 2)
endif
build: clean -include Makefile.config
INSTALL ?= install
INSTALL_PROGRAM ?= $(INSTALL) -m 755
INSTALL_DATA ?= $(INSTALL) -m 644
.PHONY: build format rpm install uninstall
build:
cargo build --release cargo build --release
./target/release/$(APP_NAME) --generate=bash > completions.bash
./target/release/$(APP_NAME) --generate=zsh > completions.zsh
./target/release/$(APP_NAME) --generate=fish > completions.fish
clean:
rm -f completions.bash
rm -f completions.zsh
rm -f completions.fish
format: format:
cargo fmt --all cargo fmt --all
# PREFIX is environment variable, but if it is not set, then set default value rpm:
ifeq ($(PREFIX),) rm -rf $(HOME)/rpmbuild
PREFIX := /usr/local rpmdev-setuptree
endif tar -czf $(HOME)/rpmbuild/SOURCES/$(PROJECT)-$(VERSION).tar.gz \
--transform "s|^|$(PROJECT)-$(VERSION)/|" \
data \
src \
Cargo.toml \
Cargo.lock \
configure \
Makefile \
README.md \
LICENSE
cp $(PROJECT).spec $(HOME)/rpmbuild/SPECS/$(PROJECT).spec
rpmbuild -ba $(HOME)/rpmbuild/SPECS/$(PROJECT).spec
install: install:
install -d $(PREFIX)/bin/ $(INSTALL) -d $(DESTDIR)$(bindir)
install -m 755 target/release/$(APP_NAME) $(PREFIX)/bin/ $(INSTALL_PROGRAM) target/release/$(PROJECT) $(DESTDIR)$(bindir)/$(PROJECT)
install -d /usr/share/bash-completion/completions/
install -m 644 completions.bash /usr/share/bash-completion/completions/$(APP_NAME)
install -d /usr/share/zsh/site-functions/
install -m 644 completions.zsh /usr/share/zsh/site-functions/_$(APP_NAME)
install -d /usr/share/fish/vendor_completions.d/
install -m 644 completions.fish /usr/share/fish/vendor_completions.d/$(APP_NAME).fish
uninstall: uninstall:
rm -f $(PREFIX)/bin/$(APP_NAME) rm -f $(DESTDIR)$(bindir)/$(PROJECT)
rm -f /usr/share/bash-completion/completions/$(APP_NAME)
rm -f /usr/share/zsh/site-functions/_$(APP_NAME)
rm -f /usr/share/fish/vendor_completions.d/$(APP_NAME).fish

102
cliff.toml Normal file
View File

@@ -0,0 +1,102 @@
# git-cliff ~ configuration file
# https://git-cliff.org/docs/configuration
[changelog]
# changelog header
header = """
# Changelog\n
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.\n
"""
# template for the changelog body
# https://keats.github.io/tera/docs/#introduction
body = """
{% macro print_commit(commit) -%}
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
{% if commit.breaking %}[**breaking**] {% endif %}\
{{ commit.message | upper_first }} - \
([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }}))\
{% endmacro -%}
{% if version %}\
{% if previous.version %}\
## [{{ version | trim_start_matches(pat="v") }}]\
($REPO/-/compare/{{ previous.version }}...{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% endif %}\
{% else %}\
## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | striptags | trim | upper_first }}
{% for commit in commits
| filter(attribute="scope")
| sort(attribute="scope") %}
{{ self::print_commit(commit=commit) }}
{%- endfor -%}
{% raw %}\n{% endraw %}\
{%- for commit in commits %}
{%- if not commit.scope -%}
{{ self::print_commit(commit=commit) }}
{% endif -%}
{% endfor -%}
{% endfor %}\n
"""
# template for the changelog footer
footer = """
<!-- generated by git-cliff -->
"""
# remove the leading and trailing whitespace from the templates
trim = true
# postprocessors
postprocessors = [
{ pattern = '\$REPO', replace = "https://git.rawleenc.dev/rawleenc/feddy" }, # replace repository URL
]
[git]
# parse the commits based on https://www.conventionalcommits.org
conventional_commits = true
# filter out the commits that are not conventional
filter_unconventional = true
# process each line of a commit as an individual commit
split_commits = false
# regex for preprocessing the commit messages
commit_preprocessors = [
# { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/orhun/git-cliff/issues/${2}))"}, # replace issue numbers
]
# regex for parsing and grouping commits
commit_parsers = [
{ message = "^feat", group = "<!-- 0 -->🚀 Features" },
{ message = "^fix", group = "<!-- 1 -->🐛 Bug Fixes" },
{ message = "^doc", group = "<!-- 3 -->📚 Documentation" },
{ message = "^perf", group = "<!-- 4 -->⚡ Performance" },
{ message = "^refactor\\(clippy\\)", skip = true },
{ message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
{ message = "^style", group = "<!-- 5 -->🎨 Styling" },
{ message = "^test", group = "<!-- 6 -->🧪 Testing" },
{ message = "^chore\\(release\\): prepare for", skip = true },
{ message = "^chore\\(deps.*\\)", skip = true },
{ message = "^chore\\(pr\\)", skip = true },
{ message = "^chore\\(pull\\)", skip = true },
{ message = "^chore|^ci", group = "<!-- 7 -->⚙️ Miscellaneous Tasks" },
{ body = ".*security", group = "<!-- 8 -->🛡️ Security" },
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" },
{ message = "^build", group = "<!-- 10 -->🔨 Build" },
]
# protect breaking changes from being skipped due to matching a skipping commit_parser
protect_breaking_commits = false
# filter out the commits that are not matched by commit parsers
filter_commits = false
# regex for matching git tags
# tag_pattern = "v[0-9].*"
# regex for skipping tags
# skip_tags = "v0.1.0-beta.1"
# regex for ignoring tags
ignore_tags = ""
# sort the tags topologically
topo_order = false
# sort the commits inside sections by oldest/newest order
sort_commits = "newest"
# limit the number of commits included in the changelog.
# limit_commits = 42

145
configure vendored Executable file
View File

@@ -0,0 +1,145 @@
#!/bin/bash
# Configuration script for the feddy project
usage() {
cat <<EOF
Usage: $0 [OPTION]...
Configuration options:
--help display this help message
--build=BUILD system on which the package is built
--host=HOST system on which the package will run
--program-prefix=PREFIX prefix for installed program names
--disable-dependency-tracking
disable dependency tracking
--prefix=DIR install files in PREFIX [/usr/local]
--exec-prefix=DIR install binaries in EPREFIX [PREFIX]
--bindir=DIR install user executables in DIR [EPREFIX/bin]
--sbindir=DIR install admin executables in DIR [EPREFIX/sbin]
--sysconfdir=DIR install configuration files in DIR [PREFIX/etc]
--datadir=DIR install data files in DIR [PREFIX/share]
--includedir=DIR install headers in DIR [PREFIX/include]
--libdir=DIR install libraries in DIR [EPREFIX/lib]
--libexecdir=DIR install internal programs in DIR [EPREFIX/libexec]
--localstatedir=DIR install variable state data in DIR [PREFIX/var]
--sharedstatedir=DIR install modifiable state data in DIR [PREFIX/com]
--mandir=DIR install man pages in DIR [DATADIR/man]
--infodir=DIR install info files in DIR [DATADIR/info]
EOF
exit 0
}
# Default values
build="$(uname -m)-unknown-linux"
host="$(uname -m)-unknown-linux"
program_prefix=''
dependency_tracking='yes'
prefix='/usr/local'
exec_prefix='${prefix}'
bindir='${exec_prefix}/bin'
sbindir='${exec_prefix}/sbin'
sysconfdir='${prefix}/etc'
datadir='${prefix}/share'
includedir='${prefix}/include'
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
localstatedir='${prefix}/var'
sharedstatedir='${prefix}/com'
mandir='${datadir}/man'
infodir='${datadir}/info'
# Argument processing
for arg in "$@"; do
case $arg in
--help)
usage
;;
--build=*)
build="${arg#*=}"
;;
--host=*)
host="${arg#*=}"
;;
--program-prefix=*)
program_prefix="${arg#*=}"
;;
--disable-dependency-tracking)
dependency_tracking="yes"
;;
--prefix=*)
prefix="${arg#*=}"
;;
--exec-prefix=*)
exec_prefix="${arg#*=}"
;;
--bindir=*)
bindir="${arg#*=}"
;;
--sbindir=*)
sbindir="${arg#*=}"
;;
--sysconfdir=*)
sysconfdir="${arg#*=}"
;;
--datadir=*)
datadir="${arg#*=}"
;;
--includedir=*)
includedir="${arg#*=}"
;;
--libdir=*)
libdir="${arg#*=}"
;;
--libexecdir=*)
libexecdir="${arg#*=}"
;;
--localstatedir=*)
localstatedir="${arg#*=}"
;;
--sharedstatedir=*)
sharedstatedir="${arg#*=}"
;;
--mandir=*)
mandir="${arg#*=}"
;;
--infodir=*)
infodir="${arg#*=}"
;;
*)
;;
esac
done
# Check for cargo (required for compilation)
if ! command -v cargo &> /dev/null; then
echo "Error: cargo is required but not installed. Please install Rust and cargo."
exit 1
fi
# Generate Makefile.config
cat > Makefile.config <<EOF
# Automatically generated by the configure script
build = $build
host = $host
program_prefix = $program_prefix
dependency_tracking = $dependency_tracking
prefix = $prefix
exec_prefix = $exec_prefix
bindir = $bindir
sbindir = $sbindir
sysconfdir = $sysconfdir
datadir = $datadir
includedir = $includedir
libdir = $libdir
libexecdir = $libexecdir
localstatedir = $localstatedir
sharedstatedir = $sharedstatedir
mandir = $mandir
infodir = $infodir
EOF
echo "Configuration complete."
echo " Build: $build"
echo " Host: $host"
echo " Prefix: $prefix"
echo " Bindir: $bindir"

32
feddy.spec Normal file
View File

@@ -0,0 +1,32 @@
Name: feddy
Version: 0.1.0
Release: 1%{?dist}
Summary: Your awesome, friendly, lightning-fast, and super-easy-to-use Fedora Buddy !
Vendor: Rawleenc
%global debug_package %{nil}
License: MIT
URL: https://git.rawleenc.dev/rawleenc/feddy
Source0: %{name}-%{version}.tar.gz
%description
Your awesome, friendly, lightning-fast, and super-easy-to-use Fedora Buddy !
%prep
%autosetup
%build
%make_build
%install
%configure
%make_install
%files
%license LICENSE
%doc README.md
%{_bindir}/feddy
%changelog
%autochangelog