add support for reusing crates from older package version
authorJan Palus <atler@pld-linux.org>
Fri, 5 Feb 2021 16:55:46 +0000 (17:55 +0100)
committerJan Palus <atler@pld-linux.org>
Fri, 5 Feb 2021 18:13:13 +0000 (19:13 +0100)
providing dependencies did not change in which case cargo will throw
error

create-crates.sh
delta.spec

index 414c80c750b41482f272c4d404d9f37b7a300009..0ce9d8a79288cc4e40c19b38ec03229fcbca57c6 100755 (executable)
@@ -1,6 +1,8 @@
 #!/bin/sh
 
-for cmd in bsdtar rpm-specdump cargo; do
+force_cargo_package="git-delta"
+
+for cmd in bsdtar rpm-specdump cargo perl; do
   if ! command -v $cmd > /dev/null 2> /dev/null; then
     not_installed="$not_installed$cmd "
   fi
@@ -23,6 +25,7 @@ spec_dump=$(rpm-specdump "$pkg_dir/$pkg_name.spec")
 pkg_version=$(echo "$spec_dump" | grep PACKAGE_VERSION | cut -f3 -d' ')
 pkg_src=$(basename $(echo "$spec_dump" | grep SOURCEURL0 | cut -f3- -d' '))
 crates_file="$pkg_name-crates-$pkg_version.tar.xz"
+cargo_package=${force_cargo_package:-$pkg_name}
 
 if [ -e "$pkg_dir/$crates_file" ]; then
   echo "ERROR: crates file $crates_file already exists" >&2
@@ -59,6 +62,9 @@ if [ $? -ne 0 ]; then
   exit 1
 fi
 
+# replace cargo package version with @@VERSION@@
+perl -pi -e 'BEGIN { undef $/;} s/(\[\[package\]\]\nname\s*=\s*"'"$cargo_package"'"\nversion\s*=\s*")[^"]+/$1\@\@VERSION\@\@/m' Cargo.lock
+
 cd ..
 tar cJf "$pkg_dir/$crates_file" "$src_dir"/{Cargo.lock,vendor}
 
index bb6abebc895523274f744e6e79c1279cd394d66d..d252575261b7f587a21df11a927d586a55f042b5 100644 (file)
@@ -1,3 +1,5 @@
+%define                crates_ver      0.5.0
+
 Summary:       A viewer for git and diff output
 Name:          delta
 Version:       0.5.0
@@ -7,7 +9,7 @@ Group:          Applications
 Source0:       https://github.com/dandavison/delta/archive/%{version}/%{name}-%{version}.tar.gz
 # Source0-md5: d75f73bc71407b86489eff88f837274d
 # ./create-crates.sh
-Source1:       %{name}-crates-%{version}.tar.xz
+Source1:       %{name}-crates-%{crates_ver}.tar.xz
 # Source1-md5: 55f896f9511f16f17d8d209d903904f1
 URL:           https://github.com/dandavison/delta
 BuildRequires: cargo
@@ -40,7 +42,10 @@ Delta's main features are:
   diff output.
 
 %prep
-%setup -q -b1
+%setup -q -a1
+
+%{__mv} delta-%{crates_ver}/* .
+sed -i -e 's/@@VERSION@@/%{version}/' Cargo.lock
 
 # use our offline registry
 export CARGO_HOME="$(pwd)/.cargo"
This page took 0.099519 seconds and 4 git commands to generate.