Improve updating lists

This commit is contained in:
Shivam Mathur 2020-07-12 05:20:08 +05:30
parent 8dee767b82
commit 7a59874419
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A

View File

@ -25,9 +25,20 @@ read_env() {
[ "$runner" = false ] && [[ -n ${RUNNER} ]] && runner="${RUNNER}" [ "$runner" = false ] && [[ -n ${RUNNER} ]] && runner="${RUNNER}"
} }
# Function to backup and cleanup package lists.
cleanup_lists() {
if [ ! -e /etc/apt/sources.list.d.save ]; then
sudo mv /etc/apt/sources.list.d /etc/apt/sources.list.d.save
sudo mkdir /etc/apt/sources.list.d
sudo mv /etc/apt/sources.list.d.save/*ondrej*.list /etc/apt/sources.list.d/
trap "sudo mv /etc/apt/sources.list.d.save/*.list /etc/apt/sources.list.d/" exit
fi
}
# Function to update the package lists. # Function to update the package lists.
update_lists() { update_lists() {
if [ "$lists_updated" = "false" ]; then if [ "$lists_updated" = "false" ]; then
cleanup_lists
sudo "$debconf_fix" apt-get update >/dev/null 2>&1 sudo "$debconf_fix" apt-get update >/dev/null 2>&1
lists_updated="true" lists_updated="true"
fi fi
@ -36,6 +47,7 @@ update_lists() {
# Function to add ppa:ondrej/php. # Function to add ppa:ondrej/php.
add_ppa() { add_ppa() {
if ! apt-cache policy | grep -q ondrej/php; then if ! apt-cache policy | grep -q ondrej/php; then
cleanup_lists
LC_ALL=C.UTF-8 sudo apt-add-repository ppa:ondrej/php -y LC_ALL=C.UTF-8 sudo apt-add-repository ppa:ondrej/php -y
if [ "$DISTRIB_RELEASE" = "16.04" ]; then if [ "$DISTRIB_RELEASE" = "16.04" ]; then
sudo "$debconf_fix" apt-get update sudo "$debconf_fix" apt-get update