My hook script for the repository task (see the list of FAI tasks) doesn't seem to be having an effect on the final state of installation. Why not? Is this the expected behavior? If so, why? And what, if anything, can I do to work around this restriction?


I'm trying to use FAI to install Docker CE from the Docker package repository (see Installing Packages from a 3rd Party Repository with FAI). Following the official instructions, I'm trying to use the add-apt-repository utility to add the package repository to the APT repository index. In order to get the add-apt-repository utility I'm trying to install the software-properties-common package. My plan was to use a hook script for the repository phase to install software-properties-common and then use add-apt-repository to add the Docker repository.

Solution Attempt

I created the following repository-task hook script for a SOFTPROPCOMM class:


# /srv/fai/config/hooks/repository.SOFTPROPCOMM

# Print command
echo apt-get install software-properties-common

# Execute command
apt-get install software-properties-common

Then I perform a dirinstall to create a chroot environment:

sudo fai \
--verbose \
--cfdir '/etc/fai' \
--class 'SOFTPROPCOMM' \
--cspace 'file:///srv/fai/config' \
dirinstall 'softpropcomm' \
| tee fai-softpropcomm.log

Then I enter the chroot environment:

sudo chroot softpropcomm

and from inside the chroot environment I check for the presence of the add-apt-repository application:

which add-apt-repository

and also for the presence of the software-properties-common package:

dpkg -l | grep -Fi software-properties-common

Neither the application nor the package appear to be present. So I try manually installing the package (still from within the chroot):

apt-get install software-properties-common

The installation proceeds as expected for a new package (one that isn't already installed on the system) and after the package installation completes I can verify that the add-apt-repository application has been successfully installed. This seems to suggest that repository-task hook script did not execute successfully. So I and look at my log file (back on the host - outside of the chroot):

cat fai-softpropcomm.log \
| grep -Fi -B1 -A2 software-properties-common

This produces the following output:

Calling hook: repository.SOFTPROPCOMM
apt-get install software-properties-common
Reading package lists...
Building dependency tree...
Reading state information...
software-properties-common is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 86 not upgraded.

This seems to suggest that the package was already installed prior to the execution of my hook script, which is doubly confusing.

Debugging Attempt

In order to test what was happening I added a command to the repository-task hook script to write to a new file. Here is the new hook script:


# /srv/fai/config/hooks/repository.SOFTPROPCOMM

echo "Testing repository-task hook script"
echo "Writing to file /test"
echo "Success" > /test
echo "Checking contents of /test"
cat /test

The output from the installation process includes the following block for the repository-task hook:

Calling hook: repository.SOFTPROPCOMM
Testing repository-task hook script
Writing to file /test
Checking contents of /test

But then when I enter the chroot the file isn't there.

  • Could you indicate whether you solved the issue? – 030 Dec 23 '19 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.