mirror of
https://github.com/gwebu-team/profile.d.git
synced 2025-12-10 20:55:46 +00:00
Format the code, add fmt and check targets
Some checks failed
Makefile CI / build (push) Has been cancelled
Some checks failed
Makefile CI / build (push) Has been cancelled
This commit is contained in:
parent
82d22c0bf0
commit
60e62585eb
8 changed files with 188 additions and 162 deletions
|
|
@ -6,6 +6,8 @@
|
||||||
- `make rpm` - Build RPM package
|
- `make rpm` - Build RPM package
|
||||||
- `make podman_rpm` - Build RPM using podman (for MacOS)
|
- `make podman_rpm` - Build RPM using podman (for MacOS)
|
||||||
- `make changelog` - Add changelog entry via ./changelog.sh
|
- `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
|
- `make clean` - Clean generated files
|
||||||
- Pre-commit hooks run automatically on commit (see .pre-commit-config.yaml)
|
- 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
|
- **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)
|
- **Line Endings**: LF only (enforced by pre-commit, see .editorconfig)
|
||||||
- **No trailing whitespace** (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
|
- **OS Compatibility**: Support both Linux and MacOS with conditional logic
|
||||||
- **Naming**: Profile.d files use `z-<name>.sh` pattern for alphabetical loading
|
- **Naming**: Profile.d files use `z-<name>.sh` pattern for alphabetical loading
|
||||||
- **Licensing**: The Unlicense unless explicitly stated otherwise
|
- **Licensing**: The Unlicense unless explicitly stated otherwise
|
||||||
|
|
@ -23,8 +25,8 @@
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
- No specific testing framework currently used
|
- No specific testing framework currently used
|
||||||
|
- Use `make check` to lint shell scripts with shellcheck
|
||||||
- Shell scripts should be tested with basic manual verification
|
- Shell scripts should be tested with basic manual verification
|
||||||
- Use `set -euo pipefail` for robust error handling
|
|
||||||
|
|
||||||
## Cursor/Copilot Rules
|
## Cursor/Copilot Rules
|
||||||
- No specific .cursorrules or .github/copilot-instructions.md found
|
- No specific .cursorrules or .github/copilot-instructions.md found
|
||||||
|
|
|
||||||
17
Makefile
17
Makefile
|
|
@ -1,8 +1,8 @@
|
||||||
SHELL:=/bin/bash # Use bash syntax, mitigates dash's printf on Debian
|
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)
|
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_ver:=$(firstword $(subst -, ,$(ver)))
|
||||||
rpm_rev:=$(subst $(rpm_ver)-,,$(ver))
|
name_rev:=$(subst $(rpm_ver)-,,$(ver))
|
||||||
rpm_rev:=$(subst -,_,$(rpm_rev))
|
rpm_rev:=$(subst -,_,$(name_rev))
|
||||||
|
|
||||||
|
|
||||||
help:
|
help:
|
||||||
|
|
@ -15,6 +15,8 @@ help:
|
||||||
@echo " rpm: Create an RPM package."
|
@echo " rpm: Create an RPM package."
|
||||||
@echo " podman_rpm Create an RPM package using podman on MacOS."
|
@echo " podman_rpm Create an RPM package using podman on MacOS."
|
||||||
@echo " changelog: Add a changelog entry to gwebu-profile.spec.in."
|
@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
|
||||||
@echo " clean: Clean all generated files."
|
@echo " clean: Clean all generated files."
|
||||||
@echo
|
@echo
|
||||||
|
|
@ -45,6 +47,17 @@ changelog:
|
||||||
./changelog.sh
|
./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
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -rf dist
|
rm -rf dist
|
||||||
|
|
|
||||||
16
build.sh
16
build.sh
|
|
@ -3,13 +3,16 @@
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
shopt -s nullglob dotglob
|
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
|
set -x # debug
|
||||||
|
|
||||||
. /etc/os-release
|
. /etc/os-release
|
||||||
ARCH="${ARCH:-$(uname -m)}" #
|
ARCH="${ARCH:-$(uname -m)}" #
|
||||||
VER="${VER:-${VERSION_ID%%\.*}}" # 8
|
VER="${VER:-${VERSION_ID%%\.*}}" # 9
|
||||||
DIST_PRE="${PLATFORM_ID##*:}" # el8
|
DIST_PRE="${PLATFORM_ID##*:}" # el9
|
||||||
DIST="${DIST:-${DIST_PRE%%[0-9]*}}" # el
|
DIST="${DIST:-${DIST_PRE%%[0-9]*}}" # el
|
||||||
OUT_DIR="/tmp/RPMS"
|
OUT_DIR="/tmp/RPMS"
|
||||||
|
|
||||||
|
|
@ -24,17 +27,20 @@ export LC_TIME="${LANG}"
|
||||||
rm -rf "$OUT_DIR"
|
rm -rf "$OUT_DIR"
|
||||||
mkdir "$OUT_DIR"
|
mkdir "$OUT_DIR"
|
||||||
|
|
||||||
|
# Download all sources and patches.
|
||||||
#spectool -g ./*.spec
|
#spectool -g ./*.spec
|
||||||
#
|
#
|
||||||
|
# Install all build dependencies.
|
||||||
#if [ "$UID" == "0" ]; then
|
#if [ "$UID" == "0" ]; then
|
||||||
# dnf builddep -y --refresh ./*.spec
|
# dnf builddep -y --refresh ./*.spec
|
||||||
#fi
|
#fi
|
||||||
|
|
||||||
# make rpmsrc
|
# make dist
|
||||||
|
|
||||||
rpmbuild -ta ./dist/*.tar.xz \
|
rpmbuild -ta ./dist/*.tar.xz \
|
||||||
--define "_sourcedir $PWD/dist" \
|
--define "_sourcedir $PWD/dist" \
|
||||||
--define "_srcrpmdir $OUT_DIR" \
|
--define "_srcrpmdir $OUT_DIR" \
|
||||||
--define "_rpmdir $OUT_DIR" \
|
--define "_rpmdir $OUT_DIR"
|
||||||
|
|
||||||
mv "$OUT_DIR"/*/*.rpm "$OUT_DIR/"
|
mv "$OUT_DIR"/*/*.rpm "$OUT_DIR/"
|
||||||
rmdir "$OUT_DIR"/* 2>/dev/null || true
|
rmdir "$OUT_DIR"/* 2>/dev/null || true
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,7 @@ fi
|
||||||
|
|
||||||
# SSH Control Masters tools (setup controlmasters to be in ~/.ssh/c).
|
# 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 --")'
|
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)'
|
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)'
|
alias ssh_controlmasters_stop='(cd ~/.ssh/c; [ "$(ls -A)" ] && for i in *; do echo -n "$i: "; ssh -O stop "${i%:*}" -p "${i##*:}"; done)'
|
||||||
|
|
|
||||||
|
|
@ -183,8 +183,7 @@ function twtty {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
export PS1="$TITLEBAR\
|
export PS1="$TITLEBAR${C1}┌${C2}─(\
|
||||||
${C1}┌${C2}─(\
|
|
||||||
${C1}\${my_D}${C2}, ${C1}Err ${C3}\${my_P[*]}${C2}, ${C3}\${my_TTY}\
|
${C1}\${my_D}${C2}, ${C1}Err ${C3}\${my_P[*]}${C2}, ${C3}\${my_TTY}\
|
||||||
${C2})─${C1}─\${my_FILL}${C2}─(\
|
${C2})─${C1}─\${my_FILL}${C2}─(\
|
||||||
${C1}\${my_PWD}\
|
${C1}\${my_PWD}\
|
||||||
|
|
@ -225,6 +224,7 @@ if [ ! -d "$HOME/bash_history" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# call and unset
|
# call and unset
|
||||||
twtty; unset twtty
|
twtty
|
||||||
|
unset twtty
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
Summary: Gwebu profile.d - cool date, prompt with history, aliases
|
Summary: Gwebu profile.d - cool date, prompt with history, aliases
|
||||||
Name: gwebu-profile
|
Name: gwebu-profile
|
||||||
Version: 1.0.8
|
Version: 1.0.9
|
||||||
Release: 0
|
Release: 0
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
|
|
@ -41,6 +41,9 @@ install -m 0644 etc/profile.d/*.sh %{buildroot}%{_sysconfdir}/profile.d/
|
||||||
|
|
||||||
|
|
||||||
%changelog
|
%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
|
* Sun Nov 02 2025 Doncho N. Gunchev <dgunchev@gmail.com> - 1.0.8-0
|
||||||
- Fixing VENV again...
|
- Fixing VENV again...
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue