From 49a2e9d10de5de0def1861d4be650318e9889625 Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Thu, 24 Aug 2023 14:34:26 +0200 Subject: [PATCH] Fix use of canary file during `alr install` (#1429) --- src/alire/alire-install.adb | 12 ++++++--- src/alire/alire-releases.adb | 7 ++++-- src/alire/alire-releases.ads | 8 ++++-- .../my_index/crates/crate/crate1.tgz | Bin 0 -> 10240 bytes .../my_index/crates/crate/crate2.tgz | Bin 0 -> 296 bytes .../index/cr/crate1/crate1-1.0.0.toml | 10 ++++++++ .../index/cr/crate2/crate2-1.0.0.toml | 10 ++++++++ .../independent/my_index/index/index.toml | 1 + testsuite/tests/install/independent/test.py | 23 ++++++++++++++++++ testsuite/tests/install/independent/test.yaml | 4 +++ 10 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 testsuite/tests/install/independent/my_index/crates/crate/crate1.tgz create mode 100644 testsuite/tests/install/independent/my_index/crates/crate/crate2.tgz create mode 100644 testsuite/tests/install/independent/my_index/index/cr/crate1/crate1-1.0.0.toml create mode 100644 testsuite/tests/install/independent/my_index/index/cr/crate2/crate2-1.0.0.toml create mode 100644 testsuite/tests/install/independent/my_index/index/index.toml create mode 100644 testsuite/tests/install/independent/test.py create mode 100644 testsuite/tests/install/independent/test.yaml diff --git a/src/alire/alire-install.adb b/src/alire/alire-install.adb index 6bc1bc37..795e31fa 100644 --- a/src/alire/alire-install.adb +++ b/src/alire/alire-install.adb @@ -49,9 +49,15 @@ package body Alire.Install is -- Use or regular deployment facilities, in case there are any -- actions to perform. - Rel.Deploy (Env => Platforms.Current.Properties, - Parent_Folder => Prefix, - Was_There => Was_There); + Rel.Deploy (Env => Platforms.Current.Properties, + Parent_Folder => Prefix, + Was_There => Was_There, + Mark_Completion => False); + -- We set Mark_Completion to False because the deployment folder + -- is temporary, so we don't need to track completion if the + -- installation fails, and otherwise we will have a common file to + -- all installations (the ./alire/ canary file) that will cause a + -- clash after the first installation. if not Rel.Project_Files (Platforms.Current.Properties, With_Path => False).Is_Empty diff --git a/src/alire/alire-releases.adb b/src/alire/alire-releases.adb index f7440cae..769e35f2 100644 --- a/src/alire/alire-releases.adb +++ b/src/alire/alire-releases.adb @@ -247,7 +247,8 @@ package body Alire.Releases is Was_There : out Boolean; Perform_Actions : Boolean := True; Create_Manifest : Boolean := False; - Include_Origin : Boolean := False) + Include_Origin : Boolean := False; + Mark_Completion : Boolean := True) is use Alire.Directories; use all type Alire.Properties.Actions.Moments; @@ -350,7 +351,9 @@ package body Alire.Releases is end; end if; - Completed.Mark (Complete => True); + if Mark_Completion then + Completed.Mark (Complete => True); + end if; exception when E : others => diff --git a/src/alire/alire-releases.ads b/src/alire/alire-releases.ads index 3733d6fb..4d69e4e7 100644 --- a/src/alire/alire-releases.ads +++ b/src/alire/alire-releases.ads @@ -348,11 +348,15 @@ package Alire.Releases is Was_There : out Boolean; Perform_Actions : Boolean := True; Create_Manifest : Boolean := False; - Include_Origin : Boolean := False); + Include_Origin : Boolean := False; + Mark_Completion : Boolean := True); -- Deploy the sources of this release under the given Parent_Folder. If -- Create_Manifest, any packaged manifest will be moved out of the way -- and an authoritative manifest will be generated from index information. - -- The created manifest may optionally Include_Origin information. + -- The created manifest may optionally Include_Origin information. When + -- Mark_Completion, a trace file will be created in ./alire/copy_complete + -- so future inspections of the folder can ensure the operation wasn't + -- interrupted. private diff --git a/testsuite/tests/install/independent/my_index/crates/crate/crate1.tgz b/testsuite/tests/install/independent/my_index/crates/crate/crate1.tgz new file mode 100644 index 0000000000000000000000000000000000000000..a8623c93b8abbc9765a6635232e4a54b7c7ccc6e GIT binary patch literal 10240 zcmeH}%Wi`(5JkP_E8KKn#xK0@wu^oPK@=QSAOZRR+R&ybivUTiR_*ly8_ffAE@P(X z@}W#w)Iok&W0;?WH8h`tDGVmG%9ON}Y40Z}lNsYC>aISMANwKiIA@2vX)ir*$$lyJ z7u$+a|EJ0gu4>w@jIq@qaHjQK_pk3Dn23})>2FAS{bfd)af-2-^PK-&|Fqp7(j?ux z#$WSy*Oh)Q+UCtwX>!gA_kWJSRR4XQd*NffTqyCi=l@jy!b-yVA4`vU-nstMdTzbX zdb|FL1pfc`fxnPt(mWjh3ywFKSL?6HNag!OA$&84`o97B>dXz@GUBkyufxo`&&;ee{6>%T{0w4eaAOHd&00JNY c0w4eaAOHd&00JNY0w4eaAOHd&@KXdn0PT*9F#rGn literal 0 HcmV?d00001 diff --git a/testsuite/tests/install/independent/my_index/crates/crate/crate2.tgz b/testsuite/tests/install/independent/my_index/crates/crate/crate2.tgz new file mode 100644 index 0000000000000000000000000000000000000000..14a2617ac380bcae2166d0e1bfda6598a90a1118 GIT binary patch literal 296 zcmV+@0oVQ?iwFP!000001MSw!PJ}QN24L1aMQ7a0>E*P0w=U)xIs~B;0}0^!TP~V0 zM#o7kX5#-XC9mY_%U0)@bV+z*S_%P0Rl|Drpd zio7_6HeUU6=&LxEUHcU3BLC~fL2_&T4~>t>Cz|7${=e2g#R2_)10V9AAAWxqT%W&| zg#Z60*8HdbpKOkwW0AlB literal 0 HcmV?d00001 diff --git a/testsuite/tests/install/independent/my_index/index/cr/crate1/crate1-1.0.0.toml b/testsuite/tests/install/independent/my_index/index/cr/crate1/crate1-1.0.0.toml new file mode 100644 index 00000000..61c8709b --- /dev/null +++ b/testsuite/tests/install/independent/my_index/index/cr/crate1/crate1-1.0.0.toml @@ -0,0 +1,10 @@ +description = "Sample crate" +name = "crate1" +version = "1.0.0" +licenses = [] +maintainers = ["any@bo.dy"] +maintainers-logins = ["someone"] + +[origin."case(os)"."..."] +url = "file:../../../crates/crate/crate1.tgz" +hashes = ["sha256:d35efed8325f646652f533fa4094d580cf28bccc9cc1d85751738b446bbed37a"] \ No newline at end of file diff --git a/testsuite/tests/install/independent/my_index/index/cr/crate2/crate2-1.0.0.toml b/testsuite/tests/install/independent/my_index/index/cr/crate2/crate2-1.0.0.toml new file mode 100644 index 00000000..77677151 --- /dev/null +++ b/testsuite/tests/install/independent/my_index/index/cr/crate2/crate2-1.0.0.toml @@ -0,0 +1,10 @@ +description = "Sample crate" +name = "crate2" +version = "1.0.0" +licenses = [] +maintainers = ["any@bo.dy"] +maintainers-logins = ["someone"] + +[origin."case(os)"."..."] +url = "file:../../../crates/crate/crate2.tgz" +hashes = ["sha256:8a814f2f0683b3b4db10a1c1e08e951d81de0deff2fa0f70a29295e45184b795"] \ No newline at end of file diff --git a/testsuite/tests/install/independent/my_index/index/index.toml b/testsuite/tests/install/independent/my_index/index/index.toml new file mode 100644 index 00000000..c2a2c7db --- /dev/null +++ b/testsuite/tests/install/independent/my_index/index/index.toml @@ -0,0 +1 @@ +version = "1.2" diff --git a/testsuite/tests/install/independent/test.py b/testsuite/tests/install/independent/test.py new file mode 100644 index 00000000..c5598009 --- /dev/null +++ b/testsuite/tests/install/independent/test.py @@ -0,0 +1,23 @@ +""" +Test installation of two independent crates with `alr install` to verify that +our deployment system doesn't introduce any conflicts. +""" + +from drivers.alr import run_alr, init_local_crate +from drivers.asserts import assert_eq, assert_match, assert_installed +from subprocess import run + +import os + + +PREFIX=os.path.join(os.getcwd(), "install") +PREFIX_ARG=f"--prefix={PREFIX}" + +# Install both crates one after the other, shouldn't fail +run_alr("install", PREFIX_ARG, "crate1") +run_alr("install", PREFIX_ARG, "crate2") + +# Check contents of the prefix +assert_installed(PREFIX, ["crate1=1.0.0", "crate2=1.0.0"]) + +print('SUCCESS') \ No newline at end of file diff --git a/testsuite/tests/install/independent/test.yaml b/testsuite/tests/install/independent/test.yaml new file mode 100644 index 00000000..0a859639 --- /dev/null +++ b/testsuite/tests/install/independent/test.yaml @@ -0,0 +1,4 @@ +driver: python-script +indexes: + my_index: + in_fixtures: false -- 2.39.5