Format the code, add fmt and check targets
Some checks failed
Makefile CI / build (push) Has been cancelled

This commit is contained in:
Doncho N. Gunchev 2025-11-30 16:58:57 +02:00
parent 82d22c0bf0
commit 60e62585eb
Signed by: dgunchev
GPG key ID: D30FD19F37E002A9
8 changed files with 188 additions and 162 deletions

View file

@ -6,6 +6,8 @@
- `make rpm` - Build RPM package
- `make podman_rpm` - Build RPM using podman (for MacOS)
- `make changelog` - Add changelog entry via ./changelog.sh
- `make check` - Run shellcheck on all shell scripts
- `make fmt` - Format all shell scripts with shfmt
- `make clean` - Clean generated files
- Pre-commit hooks run automatically on commit (see .pre-commit-config.yaml)
@ -14,7 +16,7 @@
- **File Permissions**: profile.d scripts must be 0644 (install -m 0644) - they are sourced, not executed
- **Line Endings**: LF only (enforced by pre-commit, see .editorconfig)
- **No trailing whitespace** (enforced by pre-commit, see .editorconfig)
- **Error Handling**: Use `command -v` instead of `which` for portability
- **Error Handling**: Use `command -v` instead of `which` for portability, `set -euo pipefail`
- **OS Compatibility**: Support both Linux and MacOS with conditional logic
- **Naming**: Profile.d files use `z-<name>.sh` pattern for alphabetical loading
- **Licensing**: The Unlicense unless explicitly stated otherwise
@ -23,8 +25,8 @@
## Testing
- No specific testing framework currently used
- Use `make check` to lint shell scripts with shellcheck
- Shell scripts should be tested with basic manual verification
- Use `set -euo pipefail` for robust error handling
## Cursor/Copilot Rules
- No specific .cursorrules or .github/copilot-instructions.md found

View file

@ -1,8 +1,8 @@
SHELL:=/bin/bash # Use bash syntax, mitigates dash's printf on Debian
ver:=$(shell git describe --dirty --long --match='v[0-9]*.[0-9]*' | cut -c 2- | cut -d - -f 1,2,4)
rpm_ver:=$(firstword $(subst -, ,$(ver)))
rpm_rev:=$(subst $(rpm_ver)-,,$(ver))
rpm_rev:=$(subst -,_,$(rpm_rev))
name_rev:=$(subst $(rpm_ver)-,,$(ver))
rpm_rev:=$(subst -,_,$(name_rev))
help:
@ -15,6 +15,8 @@ help:
@echo " rpm: Create an RPM package."
@echo " podman_rpm Create an RPM package using podman on MacOS."
@echo " changelog: Add a changelog entry to gwebu-profile.spec.in."
@echo " check: Run shellcheck on all shell scripts."
@echo " fmt: Format all shell scripts with shfmt."
@echo
@echo " clean: Clean all generated files."
@echo
@ -45,6 +47,17 @@ changelog:
./changelog.sh
.PHONY: check
check:
shellcheck --shell=bash --external-sources --source-path=etc/profile.d *.sh etc/profile.d/*.sh
rpmlint *.spec.in
.PHONY: fmt
fmt:
shfmt -w -i 4 -ci *.sh etc/profile.d/*.sh
.PHONY: clean
clean:
rm -rf dist

View file

@ -3,13 +3,16 @@
set -euo pipefail
shopt -s nullglob dotglob
if [ "$(uname -s)" != "Linux" ]; then echo "This script only works on Linux!" >&2; exit 254; fi
if [ "$(uname -s)" != "Linux" ]; then
echo "This script only works on Linux!" >&2
exit 254
fi
set -x # debug
. /etc/os-release
ARCH="${ARCH:-$(uname -m)}" #
VER="${VER:-${VERSION_ID%%\.*}}" # 8
DIST_PRE="${PLATFORM_ID##*:}" # el8
VER="${VER:-${VERSION_ID%%\.*}}" # 9
DIST_PRE="${PLATFORM_ID##*:}" # el9
DIST="${DIST:-${DIST_PRE%%[0-9]*}}" # el
OUT_DIR="/tmp/RPMS"
@ -24,17 +27,20 @@ export LC_TIME="${LANG}"
rm -rf "$OUT_DIR"
mkdir "$OUT_DIR"
# Download all sources and patches.
#spectool -g ./*.spec
#
# Install all build dependencies.
#if [ "$UID" == "0" ]; then
# dnf builddep -y --refresh ./*.spec
#fi
# make rpmsrc
# make dist
rpmbuild -ta ./dist/*.tar.xz \
--define "_sourcedir $PWD/dist" \
--define "_srcrpmdir $OUT_DIR" \
--define "_rpmdir $OUT_DIR" \
--define "_rpmdir $OUT_DIR"
mv "$OUT_DIR"/*/*.rpm "$OUT_DIR/"
rmdir "$OUT_DIR"/* 2>/dev/null || true

View file

@ -5,5 +5,7 @@ fi
# SSH Control Masters tools (setup controlmasters to be in ~/.ssh/c).
alias ssh_controlmasters_ls='(cd ~/.ssh/c; ls -A 2>/dev/null || echo "-- No control masters --")'
# shellcheck disable=SC2154
alias ssh_controlmasters_check='(cd ~/.ssh/c; [ "$(ls -A)" ] && for i in *; do echo -n "$i: "; ssh -O check "${i%:*}" -p "${i##*:}"; done)'
# shellcheck disable=SC2154
alias ssh_controlmasters_stop='(cd ~/.ssh/c; [ "$(ls -A)" ] && for i in *; do echo -n "$i: "; ssh -O stop "${i%:*}" -p "${i##*:}"; done)'

View file

@ -183,8 +183,7 @@ function twtty {
;;
esac
export PS1="$TITLEBAR\
${C1}${C2}(\
export PS1="$TITLEBAR${C1}${C2}─(\
${C1}\${my_D}${C2}, ${C1}Err ${C3}\${my_P[*]}${C2}, ${C3}\${my_TTY}\
${C2})${C1}\${my_FILL}${C2}(\
${C1}\${my_PWD}\
@ -225,6 +224,7 @@ if [ ! -d "$HOME/bash_history" ]; then
fi
# call and unset
twtty; unset twtty
twtty
unset twtty
fi

View file

@ -1,6 +1,6 @@
Summary: Gwebu profile.d - cool date, prompt with history, aliases
Name: gwebu-profile
Version: 1.0.8
Version: 1.0.9
Release: 0
BuildArch: noarch
License: GPLv2
@ -41,6 +41,9 @@ install -m 0644 etc/profile.d/*.sh %{buildroot}%{_sysconfdir}/profile.d/
%changelog
* Sun Nov 30 2025 Doncho N. Gunchev <dgunchev@gmail.com> - 1.0.9-0
- Format the code, add fmt and check targets
* Sun Nov 02 2025 Doncho N. Gunchev <dgunchev@gmail.com> - 1.0.8-0
- Fixing VENV again...