Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix syncing of releases containing broken softlinks #1751

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion alire.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ commit = "56bbdc008e16996b6f76e443fd0165a240de1b13"

[pins.den]
url = "https://github.com/mosteo/den"
commit = "35d1f38395b93766dd64bca5901ce3b6a416ba1a"
commit = "681ab5ca522585953f2e1d70763731df34c96012"

[pins.dirty_booleans]
url = "https://github.com/mosteo/dirty_booleans"
Expand Down
18 changes: 8 additions & 10 deletions src/alire/alire-builds.adb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ with Alire.Paths.Vault;
with Alire.Roots;
with Alire.Settings.Builtins;

with GNATCOLL.VFS;
with Den.Filesystem;

package body Alire.Builds is

Expand Down Expand Up @@ -56,16 +56,14 @@ package body Alire.Builds is
Simple_Logging.Activity
("Syncing " & Release.Milestone.TTY_Image)
with Unreferenced;
Success : Boolean := False;
use GNATCOLL.VFS;
begin
GNATCOLL.VFS.Copy
(Create (+Src),
+Dst,
Success);

Assert (Success,
"Could not sync build dir from " & Src & " to " & Dst);
Den.Filesystem.Create_Directory (Dst);
Den.Filesystem.Copy (Src, Dst);
exception
when E : others =>
Log_Exception (E);
Raise_Checked_Error
("Could not sync build dir from " & Src & " to " & Dst);
end;

-- At this point we can generate the final crate configuration
Expand Down
11 changes: 3 additions & 8 deletions testsuite/drivers/builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,9 @@ def sync() -> None:
"""
Sync the shared build directory
"""
# We force the sync by running a build, no matter if it succeeds or not
try:
subprocess.run(["alr", "-q", "-d", "build"]
, stdout=subprocess.DEVNULL
, stderr=subprocess.DEVNULL
)
except:
pass
run_alr("build", "--stop-after=generation")
return


def sync_builds() -> None:
sync()
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
description = "Example crate"
name = "crate"
version = "0.1.0"
licenses = "GPL-3.0-only"
maintainers = ["[email protected]"]
maintainers-logins = ["mylogin"]
executables=['main']

[origin]
url = "file:../../../crate-0.1.0.tgz"
hashes = ["sha256:e246305107429e936610677bf5244d69510341a7df47cfce9e2278c4ad7da947"]
1 change: 1 addition & 0 deletions testsuite/tests/cache/softlinks/my_index/index/index.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version = "1.1"
60 changes: 60 additions & 0 deletions testsuite/tests/cache/softlinks/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
"""
Test proper syncing of softlinks, even bad ones

This test is Unix-only, as Windows' tar cannot recreate the broken links:

crate-0.1.0
└── crate
├── bin -> subdir/bin
├── broken -> missing
├── lib
│ ├── mock.so -> mock.so.0.0
│ ├── mock.so.0 -> mock.so.0.0
│ ├── mock.so.0.0
│ ├── zzz.so -> mock.so
│ └── zzz.so.0 -> mock.so
├── loop
│ ├── x -> z
│ ├── y -> x
│ └── z -> y
├── order
│ ├── ab -> b
│ ├── af -> d/f
│ ├── b
│ ├── cb -> b
│ ├── d
│ │ └── f
│ └── zf -> d/f
├── self -> self
├── subdir
│ ├── bin
│ │ ├── loop -> ../../subdir
│ │ └── x
│ ├── parent -> ..
│ └── self -> ../subdir
├── that -> this
└── this -> that

"""

import os
import shutil
import drivers.builds as builds
from drivers.alr import alr_with, init_local_crate, run_alr


init_local_crate()

# Make the crate depend on our troublesome crate and ensure syncing
alr_with("crate")
builds.sync()

# Ensure that a copy has been made to the cache
if builds.are_shared():
assert os.path.exists(builds.find_dir("crate"))

# Cleanup
os.chdir("..")
shutil.rmtree("xxx")

print('SUCCESS')
8 changes: 8 additions & 0 deletions testsuite/tests/cache/softlinks/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
driver: python-script
build_mode: both
control:
- [SKIP, "skip_unix", "Test is Unix-only"]
indexes:
my_index:
in_fixtures: false
compiler_only_index: {}
Loading