Skip to content

Commit

Permalink
Merge branch 'master' into openbsd
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo authored Jun 23, 2024
2 parents c780a1a + 2e7b0c6 commit 4537bcb
Show file tree
Hide file tree
Showing 23 changed files with 167 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

steps:
- name: Check out repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: true

Expand Down
27 changes: 23 additions & 4 deletions .github/workflows/ci-toolchain.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: CI self+toolchain
# Build Alire with `alr build` and using a toolchain installed from Alire
# The `alr` being tested is the one which is being submitted in the PR
# Toolchain is tested from `alr install` (1st build) and `alr build` (2nd
# build), so those are two different toolchain installations of the same
# toolchain. This way we not only test that alr builds itself, but that
# toolchain installations via `alr install` work as intented.

on:
pull_request:
Expand Down Expand Up @@ -40,12 +44,22 @@ jobs:
with:
crates: gnat_native^${{matrix.gcc_version}} gprbuild

- name: Build alr with default toolchain
- name: Build alr with toolchain from `alr install`
shell: bash
run: dev/build.sh

# We can start using the alr we just built

- name: Select toolchain GNAT^${{matrix.gcc_version}}
run: ./bin/alr -d -n toolchain --select gnat_native^${{matrix.gcc_version}} gprbuild

- name: Show builder alr configuration
run: ./bin/alr -d -n version

- name: Verify proper toolchain used for 1st build
shell: bash
run: ./bin/alr -d -n version | grep 'compiled with version' | grep -q '${{ matrix.gcc_version }}'

- name: Update dependencies
run: ./bin/alr -d -n update

Expand All @@ -55,7 +69,8 @@ jobs:
- name: Show build environment, with debug fallback
run: ./bin/alr -d -n printenv || ./bin/alr -n -v -d printenv

- shell: bash
- name: Move ./bin to ./bin-old to allow for self-build
shell: bash
run: mv ./bin ./bin-old || { sleep 5s && mv ./bin ./bin-old; }
# Windows doesn't allow to replace a running exe so the next command
# fails otherwise. Also, this mv fails sometimes so we try twice JIC.
Expand All @@ -67,6 +82,10 @@ jobs:
- name: Show built version
run: ./bin/alr -d -n version

- name: Verify proper toolchain used for 2nd build
shell: bash
run: ./bin/alr -d -n version | grep 'compiled with version' | grep -q '${{ matrix.gcc_version }}'

# Run the testsuite with the just build alr. The testsuite picks the proper
# alr in the ./bin/alr location.

Expand All @@ -78,6 +97,6 @@ jobs:
- name: Install e3
run: pip install --upgrade -r testsuite/requirements.txt

- name: Run testsuite
run: cd testsuite; ./run.py -E
- name: Run testsuite # But ensure a new alr is not build
run: scripts/ci-github.sh build=false
shell: bash
10 changes: 5 additions & 5 deletions alire.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ commit = "56bbdc008e16996b6f76e443fd0165a240de1b13"

[pins.dirty_booleans]
url = "https://github.com/mosteo/dirty_booleans"
branch = "alire"
commit = "05c40d88ecfe109e575ec8b21dd6ffa2e61df1dc"

[pins.diskflags]
url = "https://github.com/mosteo/diskflags"
branch = "alire"
commit = "60729edf31816aca0036b13b2794c39a9bd0172e"

[pins.gnatcoll]
url = "https://github.com/alire-project/gnatcoll-core.git"
Expand All @@ -78,23 +78,23 @@ commit = "9a9c660f9c6f27f5ef75417e7fac7061dff14d78"

[pins.semantic_versioning]
url = "https://github.com/alire-project/semantic_versioning"
commit = "cc2148cf9c8934fb557b5ae49a3f7947194fa7ee"
commit = "4861e32bd8a2f0df038d3ecc9a72b6381e7a34cc"

[pins.simple_logging]
url = "https://github.com/alire-project/simple_logging"
commit = "3505dc645f3eef6799a486aae223d37e88cfc4d5"

[pins.si_units]
url = "https://github.com/mosteo/si_units"
branch = "alire"
commit = "9329d2591b82440ccc859a53f1380ac07ea4194d"

[pins.stopwatch]
url = "https://github.com/mosteo/stopwatch"
commit = "f607a63b714f09bbf6126de9851cbc21cf8666c9"

[pins.toml_slicer]
url = "https://github.com/mosteo/toml_slicer"
branch = "alire"
commit = "3e5cbdb5673b85a1da6344a41764ef1cbafe3289"

# To disable version updating, export ALR_VERSION_DONT_PATCH with any value

Expand Down
4 changes: 2 additions & 2 deletions dev/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ALIRE_OS=$(get_OS); export ALIRE_OS

scripts/version-patcher.sh

echo "Building with ALIRE_OS=$ALIRE_OS..."
echo "Building with ALIRE_OS=$ALIRE_OS and $(gnat --version | head -1)"
gprbuild "-j$ALIRE_BUILD_JOBS" -r -p -P "$(dirname $0)/../alr_env.gpr" "$@"

scripts/version-patcher.sh _or_later
scripts/version-patcher.sh _or_later
23 changes: 17 additions & 6 deletions scripts/ci-github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,29 @@ pushd "$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
. ../dev/functions.sh
popd

# Mark location safe to assuage git if necessary (happens in some distros)
# Mark location safe to assuage git if necessary (happens under docker as we
# run with a different user).
if git status 2>&1 | grep -q "dubious ownership"; then
echo "Marking $PWD as safe for git"
git config --global --add safe.directory "$PWD"
echo "Marking $PWD as safe for git"
git config --global --add safe.directory "$PWD"

# Change ownership and group to current user of everything in the testsuite,
# as we have there some pre-created git repositories that would fail too.
# These are copied to temporary locations by the test runner, so we cannot
# simply use the `git config` trick.
sudo chown -R $(id -u):$(id -g) testsuite
fi

# Patch version
scripts/version-patcher.sh

# Build alr
export ALIRE_OS=$(get_OS)
gprbuild -j0 -p -P alr_env
# Build alr if no argument is "build=false"
if [[ " $* " == *" build=false "* ]]; then
echo "Skipping alr build, explicitly disabled via arguments"
else
export ALIRE_OS=$(get_OS)
gprbuild -j0 -p -P alr_env
fi

# Disable distro detection if supported
if [ "${ALIRE_DISABLE_DISTRO:-}" == "true" ]; then
Expand Down
2 changes: 1 addition & 1 deletion scripts/version-patcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ fi
$bin "$@"

echo "Resulting version file:"
cat src/alire/alire-version.ads | grep Current_Str
cat src/alire/alire-version.ads | grep "Current_Str : constant String"
29 changes: 14 additions & 15 deletions src/alire/alire-externals-from_output.adb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ with Alire.OS_Lib.Subprocess;
with Alire.Paths;
with Alire.Releases;
with Alire.TOML_Keys;
with Alire.Utils.Regex;
with Alire.Utils.TTY;

with Semantic_Versioning;
Expand Down Expand Up @@ -48,20 +49,13 @@ package body Alire.Externals.From_Output is
end if;

declare
use GNAT.Regpat;
Matches : Match_Array (1 .. Match_Count'Last);
-- Although we should have at most one match, it turns out that the
-- match won't necessarily be on the first position in the array, as
-- it depends on the number of () expressions.

Lines : AAA.Strings.Vector;
Status : constant Integer :=
OS_Lib.Subprocess.Unchecked_Spawn_And_Capture
(This.Command.First_Element,
This.Command.Tail,
Lines);
Output : constant String :=
Lines.Flatten ("" & ASCII.LF);
Output : constant String := Lines.Flatten ("" & ASCII.LF);
-- ASCII.LF is used by Regpat for new lines
begin
if Status /= 0 then
Expand All @@ -73,13 +67,13 @@ package body Alire.Externals.From_Output is

Trace.Debug
("Looking for external in version string '" & Output & "'");
Match (This.Regexp, Output, Matches);

for I in Matches'Range loop
if Matches (I) /= No_Match then
declare
Version : constant String :=
Utils.Regex.First_Match (+This.Regstr, Output);
begin
if Version /= "" then
declare
Version : constant String :=
Output (Matches (I).First .. Matches (I).Last);
Path : constant Any_Path :=
OS_Lib.Subprocess.Locate_In_Path
(This.Command.First_Element);
Expand All @@ -89,16 +83,21 @@ package body Alire.Externals.From_Output is

Result.Insert
(Index.Crate (Name, Index.Query_Mem_Only).Base
.Retagging (Semantic_Versioning.Parse (Version))
.Retagging (Semantic_Versioning.Parse
(Version, Relaxed => True))
.Providing (This.Provides)
.Replacing (Origins.New_External ("path " & Path))
.Replacing (Notes => "Detected at " -- length is 12
& Shorten
(String (Path),
Max_Description_Length - 12)));
end;
else
Trace.Debug
("Failed to match a version using regexp '"
& (+This.Regstr) & "' on output: " & Version);
end if;
end loop;
end;
end;

return Result;
Expand Down
71 changes: 42 additions & 29 deletions src/alire/alire-externals-from_system.adb
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,49 @@ package body Alire.Externals.From_System is
else
for Candidate of Origin.Value.Packages loop
Trace.Detail ("Looking for system package: " & Candidate);
declare
Detector : constant System.Deployer'Class :=
System.Platform_Deployer (Candidate);
Result : constant System.Version_Outcomes.Outcome :=
Detector.Detect;
begin
if Result.Success then
Trace.Detail ("Success with system package: "
& Candidate);

-- A system package may be found more than once if
-- transitional and proper package names are given
-- for detection of the same system package.
declare
Release : constant Alire.Releases.Release
:= Index.Crate (Name, Index.Query_Mem_Only).Base
.Retagging (Result.Value)
.Providing (This.Provides)
.Replacing (Origins.New_System (Candidate))
.Replacing (Notes => "Provided by system package:"
& " " & Candidate);
begin
if Releases.Contains (Release) then
Trace.Debug ("Not readding same system package: "
& Release.Milestone.Image);
else
Releases.Insert (Release);
end if;
end;
end if;
declare
Detector : constant System.Deployer'Class :=
System.Platform_Deployer (Candidate);
Result : constant System.Version_Outcomes.Outcome :=
Detector.Detect;
begin
if Result.Success then
Trace.Detail ("Success with system package: "
& Candidate);

-- A system package may be found more than once if
-- transitional and proper package names are given
-- for detection of the same system package.
declare
Release : constant Alire.Releases.Release
:= Index.Crate (Name,
Index.Query_Mem_Only)
.Base
.Retagging (Result.Value)
.Providing (This.Provides)
.Replacing (Origins.New_System (Candidate))
.Replacing
(Notes => "Provided by system package:"
& " " & Candidate);
begin
if Releases.Contains (Release) then
Trace.Debug
("Not readding same system package: "
& Release.Milestone.Image);
else
Releases.Insert (Release);
end if;
end;
end if;
end;
exception
when E : others =>
Trace.Debug
("Error attempting version detection of system "
& "package [" & Candidate & "] for crate: "
& (+Name));
Log_Exception (E);
end;
end loop;
end if;
Expand Down
13 changes: 13 additions & 0 deletions src/alire/alire-origins-deployers-system-apt.adb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ package body Alire.Origins.Deployers.System.Apt is
Trace.Debug
("Unexpected version format, could not identify version");
end if;
exception
-- We do not really want to disturb users for a problem
-- introduced externally by some new package version in the
-- underlying distro. This will make the problem harder to
-- detect, but eventually someone should notice that a package
-- is not being detected as intended.
when Constraint_Error | Semantic_Versioning.Malformed_Input =>
Trace.Debug
("Unexpected error while parsing version from: "
& Match & " in line " & Line & " in pkg "
& This.Base.Package_Name);
return Version_Outcomes.Outcome_Failure
("could not be detected", Report => False);
end;
end if;
end loop;
Expand Down
2 changes: 1 addition & 1 deletion testsuite/fixtures/crates/libfoo_git/HEAD
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ref: refs/heads/master
ref: refs/heads/main
3 changes: 3 additions & 0 deletions testsuite/fixtures/crates/libfoo_git/config
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
repositoryformatversion = 0
filemode = true
bare = true
sharedrepository = 2
[receive]
denyNonFastforwards = true
Binary file not shown.

This file was deleted.

Binary file not shown.
2 changes: 0 additions & 2 deletions testsuite/fixtures/crates/libfoo_git/packed-refs

This file was deleted.

1 change: 0 additions & 1 deletion testsuite/fixtures/crates/libhello_git
Submodule libhello_git deleted from ce78e7
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
description = "Sample crate"
name = "crate1"
licenses = []
maintainers = ["[email protected]"]
maintainers-logins = ["someone"]

[[external]]
kind = "version-output"
version-command = ["echo", "1.1abc"] # Should result in 1.1.0+abc
version-regexp = "(.*)"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
description = "Sample crate"
name = "crate2"
licenses = []
maintainers = ["[email protected]"]
maintainers-logins = ["someone"]

[[external]]
kind = "version-output"
version-command = ["echo", "1.1.abc"] # Should result in 1.1.0+.abc
version-regexp = "(.*)"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version = "1.2"
Loading

0 comments on commit 4537bcb

Please sign in to comment.