Skip to content

Commit

Permalink
remove df and free commands + install local dependency only if it doe…
Browse files Browse the repository at this point in the history
…sn't exists on the debian repo
  • Loading branch information
sdepassio committed Dec 19, 2024
1 parent 2b6a3a9 commit 1a764cf
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions .github/workflows/perl-cpan-libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -657,40 +657,35 @@ jobs:
continue
fi
echo "Installing package: $package"
echo $(df -h)
echo $(free -h)
# List dependencies
dependencies=$(dpkg-deb -I $package | grep Depends | sed 's/Depends: //' | sed 's/,//g' | sed 's/(\(.*\)//g') || { echo "$error_output" >> $error_log; echo "Error while listing dependencies of the package $package" >> $error_log; true; }
for dependency in $dependencies; do
# Skip non-perl dependencies
if [[ $dependency != lib*-perl ]]; then
continue
fi
# If the dependency has been built in the same workflow, install it
for dependency_package in $(find . -maxdepth 1 -regex "\.\/${dependency}_[0-9].*all\.deb" -o -regex "\.\/${dependency}_[0-9].*${{ matrix.arch }}\.deb"); do
echo "Installing dependency: $dependency_package"
echo $(dpkg-deb --info $package)
error_output=$(apt-get -o Debug::pkgProblemResolver=true -o Debug::dpkg=true -o Debug::pkgDepCache::Marker=true install -y ./$dependency_package 2>&1) || { echo "$error_output" >> $error_log; echo "Error during installation of the dependency $dependency" >> $error_log; true; }
done
# If the dependency exists in the Debian repository, don't check the local dependencies
dependency_info=$(apt-cache policy $dependency)
if [[ -n $dependency_info ]]; then
echo "Dependency exists in debian repository."
continue
else
# If the dependency has been built in the same workflow, install it
for dependency_package in $(find . -maxdepth 1 -regex "\.\/${dependency}_[0-9].*all\.deb" -o -regex "\.\/${dependency}_[0-9].*${{ matrix.arch }}\.deb"); do
echo "Installing dependency: $dependency_package"
echo $(dpkg-deb --info $package)
error_output=$(apt-get -o Debug::pkgProblemResolver=true -o Debug::dpkg=true -o Debug::pkgDepCache::Marker=true install -y ./$dependency_package 2>&1) || { echo "$error_output" >> $error_log; echo "Error during installation of the dependency $dependency" >> $error_log; true; }
done
fi
done
echo $(df -h)
echo $(free -h)
# Install package, then uninstall it with all his dependencies
echo "Package installation..."
echo $(dpkg-deb --info $package)
error_output=$(apt-get -o Debug::pkgProblemResolver=true -o Debug::dpkg=true -o Debug::pkgDepCache::Marker=true install -y $package 2>&1) || { echo "$error_output" >> $error_log; echo "Error during installation of the package $package" >> $error_log; true; }
echo "Package installation done."
echo $(df -h)
echo $(free -h)
echo "Package uninstallation..."
error_output=$(apt-get autoremove -y --purge $(echo $package | sed 's/_[0-9].*\.deb//' | sed 's/.\///') 2>&1) || { echo "$error_output" >> $error_log; echo "Error during autoremove of the package $package" >> $error_log; true; }
echo "Package uninstallation done."
echo $(df -h)
echo $(free -h)
apt-get clean
apt-get update
echo $(df -h)
echo $(free -h)
done
# If the file error_log exists and is not empty, the workflow is in error
if [[ -s $error_log ]]; then
Expand Down

0 comments on commit 1a764cf

Please sign in to comment.