diff --git a/src/alire/alire-os_lib.ads b/src/alire/alire-os_lib.ads index 6621f0b0a..b2c88852a 100644 --- a/src/alire/alire-os_lib.ads +++ b/src/alire/alire-os_lib.ads @@ -38,13 +38,19 @@ package Alire.OS_Lib with Preelaborate is subtype Native_Path_Like is String with Dynamic_Predicate => - (for all Char of Native_Path_Like => Char /= Forbidden_Dir_Separator); + (for all Char of Native_Path_Like => Char /= Forbidden_Dir_Separator) + or else raise Ada.Assertions.Assertion_Error + with "Not a native-path-like: " & Native_Path_Like; subtype Portable_Path_Like is String with Dynamic_Predicate => - (for all Char of Portable_Path_Like => Char /= '\'); + (for all Char of Portable_Path_Like => Char /= '\') + or else raise Ada.Assertions.Assertion_Error + with "Not a portable-path-like: " & Portable_Path_Like; - function To_Portable (Path : Native_Path_Like) return Portable_Path_Like; + function To_Portable (Path : Any_Path) return Portable_Path_Like; + -- Path is Any_Path and not Native_Path_Like because some Windows native + -- programs return mixed style paths such as "C:/blah/blah". function To_Native (Path : Portable_Path_Like) return Native_Path_Like; @@ -57,7 +63,7 @@ private -- To_Portable_Like -- ---------------------- - function To_Portable (Path : Native_Path_Like) + function To_Portable (Path : Any_Path) return Portable_Path_Like is (case GNATCOLL.OS.Constants.OS is when MacOS | Unix => Path, diff --git a/src/alire/alire-publish.adb b/src/alire/alire-publish.adb index 6a0661e9e..7933986d4 100644 --- a/src/alire/alire-publish.adb +++ b/src/alire/alire-publish.adb @@ -630,12 +630,10 @@ package body Alire.Publish is With_Extension => False); Git : constant VCSs.Git.VCS := VCSs.Git.Handler; Is_Repo : constant Boolean := Git.Is_Repository (Base_Path (Context)); - Archive : constant Relative_Path := - Target_Dir - / (Milestone - & (if Is_Repo - then ".tgz" - else ".tbz2")); + Archive : constant Relative_Path := Target_Dir / (Milestone & ".tgz"); + -- We used to use tbz2 for locally tar'ed files, but that has an implicit + -- dependency on bzip2 that we are not managing yet, so for now we err on + -- the safe side of built-in tar gzip capabilities. ----------------- -- Git_Archive -- @@ -668,7 +666,7 @@ package body Alire.Publish is OS_Lib.Subprocess.Checked_Spawn ("tar", Empty_Vector - & "cfj" + & "cfz" & Archive -- Destination file at alire/archives/crate-version.tbz2 & String'("--exclude=./alire") @@ -1096,7 +1094,6 @@ package body Alire.Publish is then Ada.Directories.Full_Name (Path) else Ada.Directories.Full_Name (Root.Value.Path)); begin - if not Git.Is_Repository (Root_Path) then Git_Error ("no git repository found", Root_Path); end if; diff --git a/src/alire/alire-vcss-git.adb b/src/alire/alire-vcss-git.adb index 890374b04..4ceab380f 100644 --- a/src/alire/alire-vcss-git.adb +++ b/src/alire/alire-vcss-git.adb @@ -536,6 +536,7 @@ package body Alire.VCSs.Git is Untracked_File : Natural := 0; Tracked_File : Natural := 0; begin + Trace.Debug ("git status output: " & Out_1.Flatten ("\n")); for Line of Out_1 loop if Contains (Line, "GNAT-TEMP-") then diff --git a/src/alire/alire-vfs.ads b/src/alire/alire-vfs.ads index 1b2013fa9..022c7f6a0 100644 --- a/src/alire/alire-vfs.ads +++ b/src/alire/alire-vfs.ads @@ -99,7 +99,9 @@ private ----------------- function To_Portable (Path : Relative_Path) return Portable_Path - is (Portable_Path (OS_Lib.To_Portable (Path))); + is (Portable_Path + (OS_Lib.To_Portable + (Path))); --------------- -- To_Native -- diff --git a/src/alire/alire.ads b/src/alire/alire.ads index d18789a00..bf506a9b3 100644 --- a/src/alire/alire.ads +++ b/src/alire/alire.ads @@ -1,3 +1,4 @@ +with Ada.Assertions; with Ada.Exceptions; with Ada.Strings.Unbounded; private with Ada.Strings.UTF_Encoding.Wide_Wide_Strings; @@ -144,7 +145,9 @@ package Alire with Preelaborate is -- Filenames with full path subtype Absolute_Path is Any_Path - with Dynamic_Predicate => Check_Absolute_Path (Absolute_Path); + with Dynamic_Predicate => Check_Absolute_Path (Absolute_Path) + or else raise Ada.Assertions.Assertion_Error + with "Path is not absolute: " & Absolute_Path; function Absolute_Path_Image (Path : Absolute_Path) return String; -- Needed for later instantiations diff --git a/testsuite/tests/monorepo/subdir-in-tar/test.py b/testsuite/tests/monorepo/subdir-in-tar/test.py index fe5ce4c3b..686a2bba5 100644 --- a/testsuite/tests/monorepo/subdir-in-tar/test.py +++ b/testsuite/tests/monorepo/subdir-in-tar/test.py @@ -17,7 +17,7 @@ # generated location as the "online" location, and this works because we are # forcing. p = run(["alr", "-q", "-f", "-n", "publish", "--skip-build", "--skip-submit", "--tar"], - input=f"file:{os.getcwd()}/alire/archives/xxx-0.1.0-dev.tbz2\n".encode()) + input=f"file:{os.getcwd()}/alire/archives/xxx-0.1.0-dev.tgz\n".encode()) p.check_returncode() # Add improper subdir to manifest diff --git a/testsuite/tests/publish/tarball-plaindir-nonstd/test.py b/testsuite/tests/publish/tarball-plaindir-nonstd/test.py index b6730ec51..0b54ebc52 100644 --- a/testsuite/tests/publish/tarball-plaindir-nonstd/test.py +++ b/testsuite/tests/publish/tarball-plaindir-nonstd/test.py @@ -26,13 +26,13 @@ # forcing. p = run(["alr", "-q", "-f", "-n", "publish", "--skip-build", "--skip-submit", "--tar", "--manifest", "xxx.toml"], - input=f"file:{os.getcwd()}/alire/archives/xxx-0.1.0-dev.tbz2\n".encode()) + input=f"file:{os.getcwd()}/alire/archives/xxx-0.1.0-dev.tgz\n".encode()) p.check_returncode() # Verify the generated file does not contain the alire folder -p = run(["tar", "tf", "alire/archives/xxx-0.1.0-dev.tbz2"], +p = run(["tar", "tf", os.path.join("alire", "archives", "xxx-0.1.0-dev.tgz")], capture_output=True) -p.check_returncode() +assert p.returncode == 0, "tar failed: " + p.stderr.decode() assert "xxx-0.0.0/alire/" not in p.stdout.decode(), \ "Unexpected contents in tarball: " + p.stdout.decode() diff --git a/testsuite/tests/publish/tarball-plaindir/test.py b/testsuite/tests/publish/tarball-plaindir/test.py index 4716e1028..a3b910d33 100644 --- a/testsuite/tests/publish/tarball-plaindir/test.py +++ b/testsuite/tests/publish/tarball-plaindir/test.py @@ -23,11 +23,11 @@ # generated location as the "online" location, and this works because we are # forcing. p = run(["alr", "-q", "-f", "-n", "publish", "--skip-build", "--skip-submit", "--tar"], - input=f"file:{os.getcwd()}/alire/archives/xxx-0.1.0-dev.tbz2\n".encode()) + input=f"file:{os.getcwd()}/alire/archives/xxx-0.1.0-dev.tgz\n".encode()) p.check_returncode() # Verify the generated file does not contain the alire folder -p = run(["tar", "tf", "alire/archives/xxx-0.1.0-dev.tbz2"], +p = run(["tar", "tf", "alire/archives/xxx-0.1.0-dev.tgz"], capture_output=True) p.check_returncode() assert "xxx-0.0.0/alire/" not in p.stdout.decode(), \