From ad86ad658e83b8533c3e3f39933dffaf6ce94a51 Mon Sep 17 00:00:00 2001 From: samuel Date: Thu, 27 Apr 2023 14:44:46 +0200 Subject: [PATCH] [Dev] First commit --- Makefile | 52 +++++++++++++++++++++++++++++++++++++++++++++++ README.md | 3 ++- netoik-shfmt.spec | 37 +++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 Makefile create mode 100644 netoik-shfmt.spec diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0962f25 --- /dev/null +++ b/Makefile @@ -0,0 +1,52 @@ +NAME = shfmt +VERSION = $(shell [ -d ".git" ] && git describe | sed "s/-/./g") +BRANCH = $(shell [ -d ".git" ] && git branch --show-current) + +RPM_SOURCEDIR = $(shell rpm --eval "%{_sourcedir}") + +VARDIR = $(shell rpm --eval "%{_var}") + +NOTHING = "Nothing to do" + +.PHONY: build +build: + @echo "$(NOTHING)" + +.PHONY: clean +clean: + @echo "$(NOTHING)" + +.PHONY: name +name: + @echo "$(NAME)" + +.PHONY: version +version: + @echo "$(VERSION)" + +$(RPM_SOURCEDIR)/$(NAME)-%.tar.gz: * + git archive --format=tar.gz \ + --output="$@" \ + --prefix="$(NAME)-$(VERSION)/" \ + --worktree-attributes \ + --verbose \ + "$(BRANCH)" + +.PHONY: tarball +tarball: $(RPM_SOURCEDIR)/$(NAME)-$(VERSION).tar.gz + +.PHONY: install +install: + install -D --target-directory="$(DESTDIR)$(VARDIR)/$(NAME)" README.md LICENSE + +.PHONY: check_format +check_format: + @echo "$(NOTHING)" + +.PHONY: check_linting +check_linting: + @echo "$(NOTHING)" + +.PHONY: unit_test +unit_test: + @echo "$(NOTHING)" diff --git a/README.md b/README.md index 2dfee45..78e31a0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ # netoik-shfmt -Install shfmt package when it is only available via Snap. \ No newline at end of file +Install shfmt package when it is only available via Snap. +This is needed because non-shell users do not have access to Snap tools in their PATH. diff --git a/netoik-shfmt.spec b/netoik-shfmt.spec new file mode 100644 index 0000000..f13453c --- /dev/null +++ b/netoik-shfmt.spec @@ -0,0 +1,37 @@ +%define debug_package %{nil} + +Name: %(make name) +Version: %(make version) +Release: 1%{?dist} +Summary: Netoik Shfmt package when it is only available via Snap + +License: GPLv3 +Source0: %{name}-%{version}.tar.gz + +BuildArch: x86_64 +BuildRequires: make +Requires: snapd + +%description +Netoik Shfmt package when it is only available via Snap + +%prep +%autosetup -v + +%build +%make_build + +%install +%make_install + +%post +ln --symbolic --force /var/lib/snapd/snap/bin/shfmt %{_bindir}/%{name} + +%preun +if [ $1 -eq 0 ]; then + rm --force %{_bindir}/%{name} +fi + +%files +%attr(644, root, root) %{_var}/%{name}/README.md +%attr(644, root, root) %{_var}/%{name}/LICENSE