From 807b2daf74c7f68e71b4514cf1e4d8457962cb4d Mon Sep 17 00:00:00 2001 From: Ryan Brue Date: Sun, 5 May 2024 02:21:35 -0500 Subject: [PATCH] fix(rpm): do git versioning properly --- .rpm/desktop-entry-daemon.spec | 8 ++++---- .rpm/setup.sh | 14 ++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.rpm/desktop-entry-daemon.spec b/.rpm/desktop-entry-daemon.spec index 952ada1..7929f16 100644 --- a/.rpm/desktop-entry-daemon.spec +++ b/.rpm/desktop-entry-daemon.spec @@ -11,7 +11,7 @@ %global date ### Name: desktop-entry-daemon -Version: %{ver}~%{date} +Version: %{ver}~git%{date}.%{sub %{commit} 1 7} Release: %autorelease Summary: A daemon for managing temporary desktop entries @@ -36,8 +36,8 @@ 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: desktop-entry-daemon-%{ver}.tar.xz -Source: desktop-entry-daemon-%{ver}-vendor.tar.xz +Source: desktop-entry-daemon-%{commit}.tar.xz +Source: desktop-entry-daemon-%{commit}-vendor.tar.xz BuildRequires: cargo-rpm-macros >= 26 BuildRequires: rustc @@ -54,7 +54,7 @@ Requires: dbus %description %{_description} %prep -%autosetup -n %{crate}-%{ver} -p1 -a1 +%autosetup -n %{name}-%{commit} -p1 -a1 %cargo_prep -N cat .vendor/config.toml >> .cargo/config diff --git a/.rpm/setup.sh b/.rpm/setup.sh index 1a4dbb1..8cc2988 100644 --- a/.rpm/setup.sh +++ b/.rpm/setup.sh @@ -14,30 +14,28 @@ repo=$5 LATEST="latest" # Clone repo and cd into it -mkdir $name-$version && cd $name-$version && git clone --recurse-submodules $repo . +mkdir $name-$commit && cd $name-$commit && git clone --recurse-submodules $repo . # Get latest commit hash if commit is set to latest if [[ "$commit" == "$LATEST" ]] then commit=$(git rev-parse HEAD) + cd .. && mv $name-latest $name-$commit && cd $name-$commit 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 +tar -pcJf $name-$commit-vendor.tar.xz vendor && mv $name-$commit-vendor.tar.xz ../$name-$commit-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 +tar -pcJf $name-$commit.tar.xz $name-$commit +rm -rf $name-$commit # Get specfile cp $path_to_spec $name.spec 2>/dev/null || : @@ -45,7 +43,7 @@ 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') +current_date=$(date +'%Y%m%d.%H') sed -i "/^%global date / s/.*/%global date $current_date/" $name.spec