From d0aa2869ad7966be76c5d9459564b845094702d7 Mon Sep 17 00:00:00 2001 From: Ryan Brue Date: Sat, 4 May 2024 23:53:12 -0500 Subject: [PATCH] fix: revert desktop-entry-daemon rpm spec changes This allows us to vendor the dependencies like we used to do (which works) --- .rpm/desktop-entry-daemon.spec | 43 ++++++++++++++++++-------- .rpm/setup.sh | 55 ++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 13 deletions(-) create mode 100644 .rpm/setup.sh diff --git a/.rpm/desktop-entry-daemon.spec b/.rpm/desktop-entry-daemon.spec index 4471a45..952ada1 100644 --- a/.rpm/desktop-entry-daemon.spec +++ b/.rpm/desktop-entry-daemon.spec @@ -4,10 +4,16 @@ # prevent library files from being installed %global cargo_install_lib 0 +%global crate desktop-entry-daemon + +%global ver ### +%global commit ### +%global date ### + Name: desktop-entry-daemon -Version: v0.1.0~alpha.4 +Version: %{ver}~%{date} Release: %autorelease -Summary: A DBus service to manage freedesktop desktop entries +Summary: A daemon for managing temporary desktop entries SourceLicense: Apache-2.0 # 0BSD OR MIT OR Apache-2.0 @@ -30,9 +36,17 @@ License: 0BSD OR MIT OR Apache-2.0 AND Apache-2.0 AND Apache-2.0 OR MIT A # LICENSE.dependencies contains a full license breakdown URL: https://github.com/ryanabx/desktop-entry-daemon -Source: https://github.com/ryanabx/desktop-entry-daemon/archive/refs/tags/v0.1.0-alpha.4.tar.gz +Source: desktop-entry-daemon-%{ver}.tar.xz +Source: desktop-entry-daemon-%{ver}-vendor.tar.xz BuildRequires: cargo-rpm-macros >= 26 +BuildRequires: rustc +BuildRequires: cargo +BuildRequires: just + +BuildRequires: systemd-rpm-macros + +Requires: dbus %global _description %{expand: %{summary}.} @@ -40,44 +54,47 @@ BuildRequires: cargo-rpm-macros >= 26 %description %{_description} %prep -%autosetup -n desktop-entry-daemon-0.1.0-alpha.4 -p1 -%cargo_prep - -%generate_buildrequires -%cargo_generate_buildrequires +%autosetup -n %{crate}-%{ver} -p1 -a1 +%cargo_prep -N +cat .vendor/config.toml >> .cargo/config %build %cargo_build %{cargo_license_summary} %{cargo_license} > LICENSE.dependencies +%{cargo_vendor_manifest} %install install -Dm0755 target/release/desktop-entry-daemon %{buildroot}/%{_libexecdir}/desktop-entry-daemon install -Dm0644 profile.d/desktop-entry-daemon.sh %{buildroot}/%{_sysconfdir}/profile.d/desktop-entry-daemon.sh install -Dm0644 systemd/desktop-entry-daemon.service %{buildroot}/%{_userunitdir}/desktop-entry-daemon.service + %if %{with check} %check %cargo_test %endif %post -%systemd_post desktop-entry-daemon.service +%systemd_post %{name}.service +%systemd_post %{name}-clean.service %preun -%systemd_preun desktop-entry-daemon.service +%systemd_preun %{name}.service +%systemd_preun %{name}-clean.service %postun -%systemd_postun_with_restart desktop-entry-daemon.service +%systemd_postun_with_restart %{name}.service +%systemd_postun_with_restart %{name}-clean.service %files %license LICENSE -%license docs/LICENSE %license LICENSE.dependencies +%license cargo-vendor.txt %doc README.md %{_libexecdir}/%{name} %{_userunitdir}/%{name}.service %{_sysconfdir}/profile.d/%{name}.sh %changelog -%autochangelog +%autochangelog \ No newline at end of file diff --git a/.rpm/setup.sh b/.rpm/setup.sh new file mode 100644 index 0000000..1a4dbb1 --- /dev/null +++ b/.rpm/setup.sh @@ -0,0 +1,55 @@ +#!/bin/bash -x + +# name of the crate/package +name=$1 +# version of the crate/package +version=$2 +# commit to target (latest == master) +commit=$3 +# path to the spec file on the pc +path_to_spec=$4 +# repo link +repo=$5 + +LATEST="latest" + +# Clone repo and cd into it +mkdir $name-$version && cd $name-$version && git clone --recurse-submodules $repo . + +# Get latest commit hash if commit is set to latest +if [[ "$commit" == "$LATEST" ]] +then + commit=$(git rev-parse HEAD) +fi + +# Short commit, used for versioning +short_commit=${commit:0:6} + +# Reset to specified commit +git reset --hard $commit + +# Vendor dependencies and zip vendor +mkdir .vendor +cargo vendor > .vendor/config.toml +tar -pcJf $name-$version-vendor.tar.xz vendor && mv $name-$version-vendor.tar.xz ../$name-$version-vendor.tar.xz +# Back into parent directory +rm -rf vendor && cd .. + +# Zip source +tar -pcJf $name-$version.tar.xz $name-$version +rm -rf $name-$version + +# Get specfile +cp $path_to_spec $name.spec 2>/dev/null || : + +# Make replacements to specfile +sed -i "/^%global ver / s/.*/%global ver $version/" $name.spec +sed -i "/^%global commit / s/.*/%global commit $commit/" $name.spec +current_date=$(date +'%Y%m%d.%H%M') +sed -i "/^%global date / s/.*/%global date $current_date/" $name.spec + + +ls -a +pwd + +echo Done! $1 $2 $3 $4 $5 \ No newline at end of file