Update Lazarus Versions List In Fpcupdeluxe: A Feature Proposal
Hey guys! Today, let's dive into a cool feature proposal that could make managing your Lazarus installations in fpcupdeluxe a whole lot easier. If you're like me, you probably appreciate staying up-to-date with the latest versions, and this suggestion aims to streamline that process.
The Current Challenge
Currently, switching to a newer version of Lazarus involves manually tweaking the fpcup.ini file. This means digging into the configuration and modifying lines like these:
[ALIASlazTAG]
stable.gitlab=lazarus_4_2
4.2.gitlab=lazarus_4_2
4.0.gitlab=lazarus_4_0
3.8.gitlab=lazarus_3_8
...
This manual process isn't exactly user-friendly and can be a bit cumbersome, especially if you're frequently switching between versions or want to ensure you're always on the latest release. So, what's the solution? Let's explore a more automated approach.
The Proposed Solution: Automated Lazarus Version Updates
The core idea is to implement a function within fpcupdeluxe that automatically fetches an updated list of available Lazarus versions. Imagine a scenario where, upon starting fpcupdeluxe, it automatically checks for new versions and updates the fpcup.ini file and the respective version list. Sounds neat, right?
To achieve this, the proposal suggests leveraging the Gitlab REST API, specifically the Tags API. This API provides a straightforward way to retrieve information about tags (which, in this case, represent Lazarus versions) within the Lazarus Git repository.
Diving into the Gitlab REST API
The Gitlab REST API offers a powerful and efficient way to interact with Gitlab repositories programmatically. For our purpose, the Tags API is particularly relevant. By sending a GET request to a specific URL, we can retrieve a JSON response containing information about the available Lazarus versions.
Specifically, the proposed solution uses the following URL:
'https://gitlab.com/api/v4/projects/28419588/repository/tags?search=lazarus'
This request fetches tags from the Lazarus repository on Gitlab, filtering for those that include "lazarus" in their name. The response is a JSON array containing detailed information about each tag, such as its name, message, target, and commit details.
Understanding the JSON Response
The JSON response from the Gitlab API is quite comprehensive. Here's a snippet of what it looks like:
[
{
"name": "lazarus_4_4",
"message": "tagged fixes 4.4",
"target": "677cbe6e0b521c78fee65265ae6a00f8fbc5911e",
"commit": {
"id": "98f9c7a7a102139e43b39050ebbb5c48d805f59f",
"short_id": "98f9c7a7",
"created_at": "2025-11-08T09:46:28.000+01:00",
"parent_ids": [
"fd57d96566094d0d644f7f61f7d1c087e8ee8d78"
],
"title": "set fixes version to 4.4",
"message": "set fixes version to 4.4\n",
"author_name": "mattias",
"author_email": "nc-gaertnma@netcologne.de",
"authored_date": "2025-11-08T09:46:28.000+01:00",
"committer_name": "mattias",
"committer_email": "nc-gaertnma@netcologne.de",
"committed_date": "2025-11-08T09:46:28.000+01:00",
"trailers": {},
"extended_trailers": {},
"web_url": "https://gitlab.com/freepascal.org/lazarus/lazarus/-/commit/98f9c7a7a102139e43b39050ebbb5c48d805f59f"
},
"release": null,
"protected": true,
"created_at": "2025-11-08T09:34:59.000Z"
},
{
"name": "lazarus_4_2",
"message": "tagged fixes version 4.2",
"target": "c228aee61157ec88f994fa06073e30978b7acfc8",
"commit": {
"id": "b51eb6f0e87da578205ddcc993fe0674a8766178",
"short_id": "b51eb6f0",
"created_at": "2025-07-19T10:01:39.000+02:00",
"parent_ids": [
"59ef62578642905e15f32000abd25f1fdafb2368"
],
"title": "set fixes version to 4.2",
"message": "set fixes version to 4.2\n",
"author_name": "mattias",
"author_email": "nc-gaertnma@netcologne.de",
"authored_date": "2025-07-19T10:01:39.000+02:00",
"committer_name": "mattias",
"committer_email": "nc-gaertnma@netcologne.de",
"committed_date": "2025-07-19T10:01:39.000+02:00",
"trailers": {},
"extended_trailers": {},
"web_url": "https://gitlab.com/freepascal.org/lazarus/lazarus/-/commit/b51eb6f0e87da578205ddcc993fe0674a8766178"
},
"release": null,
"protected": true,
"created_at": "2025-07-19T08:04:43.000Z"
},
...
]
The key piece of information we're interested in is the name field, which corresponds to the Lazarus version tag (e.g., "lazarus_4_4", "lazarus_4_2").
Implementation with Synapse
The proposal includes a code snippet demonstrating how to retrieve and process this JSON data using Synapse, a popular Pascal library for network communication. Of course, this could also be achieved with other libraries like fphttpclient. Here's the code:
const
URL = 'https://gitlab.com/api/v4/projects/28419588/repository/tags?search=lazarus';
procedure TForm1.GetLazVers;
var
HTTPSender: THTTPSend;
rawJson: AnsiString;
LazTAGArr: TJSONArray;
LazTAGObj: TJSONObject;
ix: Integer;
LazTAGname, LazTAGVer: string;
begin
HTTPSender := THTTPSend.Create;
try
HTTPSender.HTTPMethod('GET', URL);
if (HTTPSender.ResultCode >= 100) and (HTTPSender.ResultCode <= 299) then
begin
rawJson := readJSONFrom(HTTPSender.Document);
LazTAGArr := TJSONArray(GetJSON(rawJson));
Memo1.Lines.Clear;
{ Show the first 10 }
for ix := 0 to 9 do
begin
LazTAGObj := LazTAGArr.Items[ix] as TJSONObject;
LazTAGname := LazTAGObj.FindPath('name').AsString;
LazTAGVer := nametoVer(LazTAGname);
Memo1.Lines.Add(LazTAGVer + '.gitlab=' + LazTAGname);
end;
LazTAGArr.Free;
end;
finally
HTTPSender.Free;
end;
end;
Let's break down what this code does:
- Create a
THTTPSendobject: This object is responsible for handling the HTTP request. - Set the HTTP method to GET and the URL: We're making a GET request to the Gitlab API endpoint.
- Check the result code: We ensure the request was successful (result code between 100 and 299).
- Read the JSON response: The
readJSONFromfunction reads the response from theHTTPSender.Document. - Parse the JSON: We use
TJSONArrayandTJSONObjectto navigate the JSON structure. - Extract the tag names: We loop through the first 10 tags (for demonstration purposes) and extract the
namefield. - Format the output: We format the output string as
LazTAGVer + '.gitlab=' + LazTAGname. - Display the results: The results are added to a
Memo1component. - Free resources: We free the allocated objects to prevent memory leaks.
Sample Output
Running this code snippet produces output similar to this:
4.4.gitlab=lazarus_4_4
4.2.gitlab=lazarus_4_2
4.0.gitlab=lazarus_4_0
4.0RC3.gitlab=lazarus_4_0RC3
3.8.gitlab=lazarus_3_8
4.0RC2.gitlab=lazarus_4_0RC2
4.0RC1.gitlab=lazarus_4_0_RC_1
3.6.gitlab=lazarus_3_6
3.4.gitlab=lazarus_3_4
3.2.gitlab=lazarus_3_2
This output provides a clean list of Lazarus versions that can be used to update the fpcup.ini file.
Potential Improvements and Expansion
The provided code serves as a solid foundation for this feature. However, there's always room for improvement and expansion. Here are a few ideas:
- Error Handling: Implement more robust error handling to gracefully handle network issues or API changes.
- Configuration: Allow users to configure the update interval and other settings.
- Automatic Updates: Implement the automatic update of the
fpcup.inifile, potentially with a confirmation prompt for the user. - UI Integration: Integrate the feature seamlessly into the fpcupdeluxe user interface.
- Version Comparison: Implement logic to compare the fetched versions with the currently installed versions and highlight new releases.
Source Code Attachment
To facilitate further development and experimentation, the source code for this proposal has been attached and is available here. Feel free to download it, explore it, and contribute your improvements!
Conclusion: Streamlining Lazarus Version Management
This feature proposal offers a practical solution to streamline the process of managing Lazarus versions in fpcupdeluxe. By leveraging the Gitlab REST API, we can automate the retrieval of version information and simplify the process of staying up-to-date. This not only saves time and effort but also enhances the overall user experience. I believe this would be a valuable addition to fpcupdeluxe, and I'm excited to see how it can be further developed and implemented. What do you guys think?