AdaCore Blog

First beta release of Alire, the package manager for Ada/SPARK

First beta release of Alire, the package manager for Ada/SPARK

by Fabien Chouteau

A few years ago we real­ized that hav­ing a pack­age man­ag­er for the Ada/SPARK com­mu­ni­ty would be a game chang­er. Since then, Ada­Core has been spon­sor­ing and con­tribut­ing to the Alire project cre­at­ed by Ale­jan­dro Mosteo from the Cen­tro Uni­ver­si­tario de la Defen­sa de Zaragoza. With this blog post I want to intro­duce Alire and explain why this project is impor­tant for the Ada/SPARK community.

What is a pack­age man­ag­er? #

There are many dif­fer­ent kinds of pack­age man­agers, Alire is a source-based pack­age man­ag­er focused on the Ada/SPARK pro­gram­ming language.

This means that the goal of Alire is to pro­vide an easy way to get, build and use Ada/SPARK projects in source form. It is a tool for devel­op­ers, as opposed to bina­ry pack­age man­agers which are pro­vid­ing ready to use appli­ca­tions for end-users. It is com­pa­ra­ble to opam for the OCaml ecosys­tem, or Cargo for Rust.

What are the ben­e­fits of Alire for the Ada/​SPARK ecosys­tem? #

In my opin­ion, the main ben­e­fit of a pack­age man­ag­er is to improve the col­lab­o­ra­tion with­in a com­mu­ni­ty of developers.

This is achieved in mul­ti­ple ways:

  • Alire is a cen­tral place to look for exist­ing projects. If you are look­ing for a library to pro­vide a giv­en fea­ture in your project, a quick search on the alire.ada.dev web­site will tell you if some­one from the com­mu­ni­ty already imple­ment­ed it.

  • The corol­lary is that Alire is a cen­tral place to con­tribute projects and make them avail­able to oth­er devel­op­ers in the community.

  • Alire pro­vides a com­mon and easy way to inte­grate projects from the com­mu­ni­ty in your own projects.

What does it mean in prac­tice? #

Let’s take a sim­ple sce­nario from per­son­al expe­ri­ence: I am writ­ing an appli­ca­tion in Ada, and I want my appli­ca­tion to pro­duce PDF reports.

We will look at dif­fer­ent steps of this sce­nario and com­pare how to achieve them with­out and with Alire. I will use the alr com­mand line tool from the Alire project.

1st step: find­ing an Ada PDF library #

  • Before Alire: I will search the web for a project that match­es my needs. Search engines are pret­ty pow­er­ful so if there is some­thing out there (on GitHub, Source­Forge, Git­Lab, or else­where) I will like­ly find it. Ada PDF” doesn’t yield good results, but Ada PDF library” does the job.

  • With Alire: A sim­ple search on the alire.ada.dev web­site gives me a list of Ada/​SPARK projects avail­able right now match­ing the PDF key­word: https://alire.ada.dev/search/?q=pdf Or on the com­mand line:

     $ alr list | grep pdf
    

2nd step: use APDF in my project #

  • Before Alire: Once I have found the APDF project (https://​apdf​.source​forge​.io/) I can either get the source from tar­ball or check­out the repos­i­to­ry. From that I have to under­stand how to use the source code in my project. Maybe I have to set the GPR_PROJECT_PATH, maybe I have to build and install the library.

  • With Alire:

    $ alr with apdf
    

    The alr with com­mand auto­mat­i­cal­ly fetch­es the lat­est ver­sion of APDF and makes it avail­able in my project.

3rd step: updat­ing APDF when new releas­es are avail­able #

  • Before Alire: I have no auto­mat­ed way to know if a new ver­sion of APDF is avail­able. I can fol­low forums and mail­ing lists in hope of catch­ing the infor­ma­tion, but this is not very reli­able. If I do get the infor­ma­tion that a new ver­sion of APDF is avail­able, I have to redo the 2nd step (down­load tar­ball, extract, set project path, etc.).

  • With Alire:

    $ alr update
    

    With the alr update com­mand, Alire will let me know if new ver­sions of my depen­den­cies are avail­able and auto­mat­i­cal­ly update them for me, if I wish to do so.

4th step: Oth­er devel­op­ers want to build my project #

  • Before Alire: I have to doc­u­ment in the README file all the steps to get and set up my depen­den­cies (down­load tar­ball, extract, set project path, etc). Any­one inter­est­ed in com­pil­ing my project has to fol­low all the steps, and do so tran­si­tive­ly for all dependencies.

  • With Alire:

    $ alr get my_project
    

    If I con­tributed my project to the Alire index, any­one can get the project and its depen­den­cies with a sim­ple com­mand. Oth­er­wise, one can check­out the repos­i­to­ry and use alr update to fetch the dependencies.

5th step: pub­lish­ing my project for oth­ers to use in their projects #

  • Before Alire: I have to doc­u­ment how to inte­grate my project in anoth­er project. I can then announce the project on an Ada/​SPARK com­mu­ni­ty forum like Red­dit r/​ada and hope that this or the repos­i­to­ry will show up in a Web search when peo­ple need my project.

  • With Alire:

    $ alr publish
    

    Alire pro­vides a com­mand to help pub­lish­ing projects in the Alire index. Once my project is in the index, a ded­i­cat­ed page will be cre­at­ed on the alire.ada.dev web­site and my project will be avail­able for Alire users. Of course it is still a good idea to announce it in the forums.

How many projects are avail­able in Alire? #

As of Octo­ber 2020, there are 130 projects (“crates” in the Alire vocab­u­lary) avail­able. You can browse through the list on the web­site: alire.ada.dev/crates.

There is also a net­work graph view of the Alire ecosys­tem: here.

How do I start? #

The first beta release of Alire was pub­lished a few days ago. Go to alire.ada.dev for instruc­tions on how to install and use the tool.

Posted in

About Fabien Chouteau

Fabien Chouteau

Fabien joined AdaCore in 2010 after his engineering degree at the EPITA (Paris). He is involved in real-time, embedded and hardware simulation technology. Maker/DIYer in his spare time, his projects include electronics, music and woodworking.