diff --git a/.gitignore b/.gitignore index ea8c4bf..093bf63 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ /target +/vendor +/*.log +/*.tar.xz +/*.rpm diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..70e2952 --- /dev/null +++ b/Makefile @@ -0,0 +1,79 @@ +NAME := sshca-cli +VERSION := $(shell sed -nr '/^version =/s/version = "(.*)"/\1/p' Cargo.toml) +RELEASE := $(shell rpm --eval "$$(sed -nr '/^Release:/s/Release:\s*(.*)/\1/p' sshca-cli.spec)") +ARCH := $(shell uname -m) + +MOCK_CONFIG = fedora-$(shell rpm --eval %fedora)-$(ARCH) + +debug: target/debug/$(NAME) + +release: target/release/$(NAME) + +target/debug/$(NAME): $(find src) $(wildcard Cargo.*) + cargo build + +target/release/$(NAME): $(find src) $(wildcard Cargo.*) + cargo build --release + +rpm: $(NAME)-$(VERSION)-$(RELEASE).$(ARCH).rpm + +$(NAME)-$(VERSION)-$(RELEASE).$(ARCH).rpm: \ + $(NAME)-$(VERSION)-$(RELEASE).src.rpm + mkdir -p rpmbuild + rpmbuild --rebuild \ + -D "_topdir ${PWD}/rpmbuild" \ + $< + mv rpmbuild/RPMS/$(ARCH)/*.rpm . + rm -rf rpmbuild + +srpm: $(NAME)-$(VERSION)-$(RELEASE).src.rpm + +$(NAME)-$(VERSION)-$(RELEASE).src.rpm: \ + $(NAME).spec \ + $(NAME)-$(VERSION).tar.xz \ + $(NAME)-$(VERSION)-vendor.tar.xz + rpmbuild -bs \ + -D "_topdir ${PWD}" \ + -D '_builddir %{_topdir}' \ + -D '_buildrootdir %{_topdir}' \ + -D '_rpmdir %{_topdir}' \ + -D '_sourcedir %{_topdir}' \ + -D '_specdir %{_topdir}' \ + -D '_srcrpmdir %{_topdir}' \ + $< + +$(NAME)-$(VERSION).tar.xz: \ + $(shell find src -type f) \ + Cargo.toml \ + Cargo.lock \ + $(wildcard LICENSE-*.txt) + tar -czf $@ \ + --transform 's/^/$(NAME)-$(VERSION)\//' \ + src \ + Cargo.lock \ + Cargo.toml \ + LICENSE-*.txt + +$(NAME)-$(VERSION)-vendor.tar.xz: Cargo.lock + cargo vendor + tar -czf $@ vendor + +mockbuild: $(NAME)-$(VERSION)-$(RELEASE).src.rpm + mock -r $(MOCK_CONFIG) --resultdir $(PWD) $< + +clean: + rm -f $(NAME)*-$(VERSION)-$(RELEASE).*.rpm + rm -f $(NAME)-$(VERSION).tar.xz + rm -f $(NAME)-$(VERSION)-vendor.tar.xz + rm -f build.log hw_info.log installed_pkgs.log root.log state.log + +fullclean: clean + rm -rf target + +.PHONY: \ + clean \ + debug \ + mockbuild \ + release \ + rpm \ + srpm diff --git a/sshca-cli.spec b/sshca-cli.spec new file mode 100644 index 0000000..07b3ab9 --- /dev/null +++ b/sshca-cli.spec @@ -0,0 +1,60 @@ +# Generated by rust2rpm 25 +%bcond_without check + +# prevent library files from being installed +%global __cargo_is_lib() 0 + +%global crate sshca-cli + +Name: sshca-cli +Version: 0.1.0 +Release: 1%{?dist} +Summary: CLI client for SSHCA + +SourceLicense: MIT OR Apache-2.0 +License: MIT OR Apache-2.0 +# LICENSE.dependencies contains a full license breakdown + +URL: https://git.pyrocufflink.net/dustin/sshca +Source: sshca-cli-%{version}.tar.xz +Source: sshca-cli-%{version}-vendor.tar.xz + +ExclusiveArch: %{rust_arches} + +BuildRequires: cargo-rpm-macros >= 25 +BuildRequires: openssl-devel + +%global _description %{expand: +CLI client for SSHCA.} + +%description %{_description} + +%prep +%autosetup -n %{crate}-%{version} -p1 -a1 +%cargo_prep -v vendor + + +%build +%cargo_build +%{cargo_license_summary} +%{cargo_license} > LICENSE.dependencies +%{cargo_vendor_manifest} + +%install +%cargo_install + +%if %{with check} +%check +%cargo_test +%endif + +%files +%license LICENSE-Apache-2.0.txt +%license LICENSE-MIT.txt +%license LICENSE.dependencies +%license cargo-vendor.txt +%{_bindir}/sshca-cli + +%changelog +* Sun Nov 05 2023 Dustin C. Hatch - 0.1.0-1 +- Initial package