diff --git a/rust2rpm/__main__.py b/rust2rpm/__main__.py index b43957d..4d22871 100644 --- a/rust2rpm/__main__.py +++ b/rust2rpm/__main__.py @@ -252,20 +252,23 @@ def make_patches(args, version, toml): toml_after = toml_before if args.patch: - with tempfile.NamedTemporaryFile("w+t", dir=os.path.dirname(toml), - prefix="Cargo.", suffix=".toml") as tmpfile: - tmpfile.writelines(toml_after) - tmpfile.flush() + # remove original Cargo.toml file + os.remove(toml) - editor = util.detect_editor() - subprocess.check_call([editor, tmpfile.name]) + # write auto-patched Cargo.toml to disk + with open(toml, "w") as file: + file.writelines(toml_after) + file.flush() - mtime_after2 = file_mtime(tmpfile.name) - toml_after2 = open(tmpfile.name).readlines() + editor = util.detect_editor() + subprocess.check_call([editor, toml]) - diff2 = make_diff(toml_path, - toml_after, mtime_before, - toml_after2, mtime_after2) + mtime_after2 = file_mtime(toml) + toml_after2 = open(toml).readlines() + + diff2 = make_diff(toml_path, + toml_after, mtime_before, + toml_after2, mtime_after2) return diff1, diff2 diff --git a/rust2rpm/tests/samples/cxx-build-1.0.71.fedora.spec b/rust2rpm/tests/samples/cxx-build-1.0.71.fedora.spec index 0bbddc9..6d7aa48 100644 --- a/rust2rpm/tests/samples/cxx-build-1.0.71.fedora.spec +++ b/rust2rpm/tests/samples/cxx-build-1.0.71.fedora.spec @@ -14,7 +14,7 @@ URL: https://crates.io/crates/cxx-build-1.0.71 Source: %{crates_source} # Automatically generated patch to strip foreign dependencies Patch: cxx-build-1.0.71-patch1.diff -# Maintainer patch to adjust dependencies +# Manually created patch for downstream crate metadata changes Patch: cxx-build-1.0.71-patch2.diff ExclusiveArch: %{rust_arches} diff --git a/rust2rpm/tests/samples/cxx-build-1.0.71.mageia.spec b/rust2rpm/tests/samples/cxx-build-1.0.71.mageia.spec index 4043f9b..04e41ab 100644 --- a/rust2rpm/tests/samples/cxx-build-1.0.71.mageia.spec +++ b/rust2rpm/tests/samples/cxx-build-1.0.71.mageia.spec @@ -16,7 +16,7 @@ URL: https://crates.io/crates/cxx-build-1.0.71 Source: %{crates_source} # Automatically generated patch to strip foreign dependencies Patch: cxx-build-1.0.71-patch1.diff -# Maintainer patch to adjust dependencies +# Manually created patch for downstream crate metadata changes Patch: cxx-build-1.0.71-patch2.diff ExclusiveArch: %{rust_arches} diff --git a/rust2rpm/tests/samples/cxx-build-1.0.71.opensuse.spec b/rust2rpm/tests/samples/cxx-build-1.0.71.opensuse.spec index 2f39cad..b2f406c 100644 --- a/rust2rpm/tests/samples/cxx-build-1.0.71.opensuse.spec +++ b/rust2rpm/tests/samples/cxx-build-1.0.71.opensuse.spec @@ -32,7 +32,7 @@ URL: https://crates.io/crates/cxx-build-1.0.71 Source: %{crates_source} # Automatically generated patch to strip foreign dependencies Patch: cxx-build-1.0.71-patch1.diff -# PATCH-FIX-OPENSUSE cxx-build-1.0.71-patch2.diff — Maintainer patch to adjust dependencies +# PATCH-FIX-OPENSUSE cxx-build-1.0.71-patch2.diff — Manually created patch for downstream crate metadata changes Patch: cxx-build-1.0.71-patch2.diff ExclusiveArch: %{rust_arches} diff --git a/rust2rpm/tests/samples/cxx-build-1.0.71.plain.spec b/rust2rpm/tests/samples/cxx-build-1.0.71.plain.spec index dc997fb..f5745e5 100644 --- a/rust2rpm/tests/samples/cxx-build-1.0.71.plain.spec +++ b/rust2rpm/tests/samples/cxx-build-1.0.71.plain.spec @@ -14,7 +14,7 @@ URL: https://crates.io/crates/cxx-build-1.0.71 Source: %{crates_source} # Automatically generated patch to strip foreign dependencies Patch: cxx-build-1.0.71-patch1.diff -# Maintainer patch to adjust dependencies +# Manually created patch for downstream crate metadata changes Patch: cxx-build-1.0.71-patch2.diff ExclusiveArch: %{rust_arches} diff --git a/rust2rpm/tests/samples/nix-0.24.1.fedora.spec b/rust2rpm/tests/samples/nix-0.24.1.fedora.spec index 5071597..35e7259 100644 --- a/rust2rpm/tests/samples/nix-0.24.1.fedora.spec +++ b/rust2rpm/tests/samples/nix-0.24.1.fedora.spec @@ -14,7 +14,7 @@ URL: https://crates.io/crates/nix-0.24.1 Source: %{crates_source} # Automatically generated patch to strip foreign dependencies Patch: nix-0.24.1-patch1.diff -# Maintainer patch to adjust dependencies +# Manually created patch for downstream crate metadata changes Patch: nix-0.24.1-patch2.diff ExclusiveArch: %{rust_arches} diff --git a/rust2rpm/tests/samples/nix-0.24.1.mageia.spec b/rust2rpm/tests/samples/nix-0.24.1.mageia.spec index f532731..f2691d9 100644 --- a/rust2rpm/tests/samples/nix-0.24.1.mageia.spec +++ b/rust2rpm/tests/samples/nix-0.24.1.mageia.spec @@ -15,7 +15,7 @@ URL: https://crates.io/crates/nix-0.24.1 Source: %{crates_source} # Automatically generated patch to strip foreign dependencies Patch: nix-0.24.1-patch1.diff -# Maintainer patch to adjust dependencies +# Manually created patch for downstream crate metadata changes Patch: nix-0.24.1-patch2.diff ExclusiveArch: %{rust_arches} diff --git a/rust2rpm/tests/samples/nix-0.24.1.opensuse.spec b/rust2rpm/tests/samples/nix-0.24.1.opensuse.spec index 510fc66..653f635 100644 --- a/rust2rpm/tests/samples/nix-0.24.1.opensuse.spec +++ b/rust2rpm/tests/samples/nix-0.24.1.opensuse.spec @@ -32,7 +32,7 @@ URL: https://crates.io/crates/nix-0.24.1 Source: %{crates_source} # Automatically generated patch to strip foreign dependencies Patch: nix-0.24.1-patch1.diff -# PATCH-FIX-OPENSUSE nix-0.24.1-patch2.diff — Maintainer patch to adjust dependencies +# PATCH-FIX-OPENSUSE nix-0.24.1-patch2.diff — Manually created patch for downstream crate metadata changes Patch: nix-0.24.1-patch2.diff ExclusiveArch: %{rust_arches} diff --git a/rust2rpm/tests/samples/nix-0.24.1.plain.spec b/rust2rpm/tests/samples/nix-0.24.1.plain.spec index 8b8ec01..d493403 100644 --- a/rust2rpm/tests/samples/nix-0.24.1.plain.spec +++ b/rust2rpm/tests/samples/nix-0.24.1.plain.spec @@ -14,7 +14,7 @@ URL: https://crates.io/crates/nix-0.24.1 Source: %{crates_source} # Automatically generated patch to strip foreign dependencies Patch: nix-0.24.1-patch1.diff -# Maintainer patch to adjust dependencies +# Manually created patch for downstream crate metadata changes Patch: nix-0.24.1-patch2.diff ExclusiveArch: %{rust_arches} diff --git a/rust2rpm/tests/samples/tokio-1.19.2.fedora.spec b/rust2rpm/tests/samples/tokio-1.19.2.fedora.spec index da5f02e..06a6232 100644 --- a/rust2rpm/tests/samples/tokio-1.19.2.fedora.spec +++ b/rust2rpm/tests/samples/tokio-1.19.2.fedora.spec @@ -14,7 +14,7 @@ URL: https://crates.io/crates/tokio-1.19.2 Source: %{crates_source} # Automatically generated patch to strip foreign dependencies Patch: tokio-1.19.2-patch1.diff -# Maintainer patch to adjust dependencies +# Manually created patch for downstream crate metadata changes Patch: tokio-1.19.2-patch2.diff ExclusiveArch: %{rust_arches} diff --git a/rust2rpm/tests/samples/tokio-1.19.2.mageia.spec b/rust2rpm/tests/samples/tokio-1.19.2.mageia.spec index f214226..89098ab 100644 --- a/rust2rpm/tests/samples/tokio-1.19.2.mageia.spec +++ b/rust2rpm/tests/samples/tokio-1.19.2.mageia.spec @@ -15,7 +15,7 @@ URL: https://crates.io/crates/tokio-1.19.2 Source: %{crates_source} # Automatically generated patch to strip foreign dependencies Patch: tokio-1.19.2-patch1.diff -# Maintainer patch to adjust dependencies +# Manually created patch for downstream crate metadata changes Patch: tokio-1.19.2-patch2.diff ExclusiveArch: %{rust_arches} diff --git a/rust2rpm/tests/samples/tokio-1.19.2.opensuse.spec b/rust2rpm/tests/samples/tokio-1.19.2.opensuse.spec index 00f059d..be36657 100644 --- a/rust2rpm/tests/samples/tokio-1.19.2.opensuse.spec +++ b/rust2rpm/tests/samples/tokio-1.19.2.opensuse.spec @@ -32,7 +32,7 @@ URL: https://crates.io/crates/tokio-1.19.2 Source: %{crates_source} # Automatically generated patch to strip foreign dependencies Patch: tokio-1.19.2-patch1.diff -# PATCH-FIX-OPENSUSE tokio-1.19.2-patch2.diff — Maintainer patch to adjust dependencies +# PATCH-FIX-OPENSUSE tokio-1.19.2-patch2.diff — Manually created patch for downstream crate metadata changes Patch: tokio-1.19.2-patch2.diff ExclusiveArch: %{rust_arches} diff --git a/rust2rpm/tests/samples/tokio-1.19.2.plain.spec b/rust2rpm/tests/samples/tokio-1.19.2.plain.spec index f891e8a..6c7cc84 100644 --- a/rust2rpm/tests/samples/tokio-1.19.2.plain.spec +++ b/rust2rpm/tests/samples/tokio-1.19.2.plain.spec @@ -14,7 +14,7 @@ URL: https://crates.io/crates/tokio-1.19.2 Source: %{crates_source} # Automatically generated patch to strip foreign dependencies Patch: tokio-1.19.2-patch1.diff -# Maintainer patch to adjust dependencies +# Manually created patch for downstream crate metadata changes Patch: tokio-1.19.2-patch2.diff ExclusiveArch: %{rust_arches}