Skip to content

Commit

Permalink
fix: revert desktop-entry-daemon rpm spec changes
Browse files Browse the repository at this point in the history
This allows us to vendor the dependencies like we used to do (which works)
  • Loading branch information
ryanabx committed May 5, 2024
1 parent 11300da commit d0aa286
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 13 deletions.
43 changes: 30 additions & 13 deletions .rpm/desktop-entry-daemon.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,54 +36,65 @@ 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}.}

%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
55 changes: 55 additions & 0 deletions .rpm/setup.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d0aa286

Please sign in to comment.