Skip to content

Commit

Permalink
fix(rpm): do git versioning properly
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanabx committed May 5, 2024
1 parent d0aa286 commit 807b2da
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
8 changes: 4 additions & 4 deletions .rpm/desktop-entry-daemon.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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

Expand Down
14 changes: 6 additions & 8 deletions .rpm/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,36 @@ 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 || :

# 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


Expand Down

0 comments on commit 807b2da

Please sign in to comment.