mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Add check for package files when adding PPA
This commit is contained in:
parent
9adda12e86
commit
c644f654ce
@ -96,6 +96,21 @@ add_key() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to check if a PPA and its lists exist
|
||||||
|
check_lists() {
|
||||||
|
ppa=$1
|
||||||
|
ppa_search=$2
|
||||||
|
if grep -Eqr "$ppa_search" "$list_dir"; then
|
||||||
|
list_count="$(find /var/lib/apt/lists -name "*${ppa/\//_}*" | wc -l)"
|
||||||
|
if [ "$list_count" = "0" ]; then
|
||||||
|
update_lists "$ppa" "$ppa_search"
|
||||||
|
fi
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Function to add a sources list.
|
# Function to add a sources list.
|
||||||
add_list() {
|
add_list() {
|
||||||
ppa=${1-ondrej/php}
|
ppa=${1-ondrej/php}
|
||||||
@ -104,13 +119,16 @@ add_list() {
|
|||||||
package_dist=${4:-"$VERSION_CODENAME"}
|
package_dist=${4:-"$VERSION_CODENAME"}
|
||||||
branches=${5:-main}
|
branches=${5:-main}
|
||||||
ppa_search="deb .*$ppa_url $package_dist .*$branches"
|
ppa_search="deb .*$ppa_url $package_dist .*$branches"
|
||||||
grep -Eqr "$ppa_search" "$list_dir" && echo "Repository $ppa already exists" && return;
|
if check_lists "$ppa" "$ppa_search"; then
|
||||||
arch=$(dpkg --print-architecture)
|
echo "Repository $ppa already exists";
|
||||||
[ -e "$key_source" ] && key_file=$key_source || key_file="$key_dir"/"${ppa/\//-}"-keyring.gpg
|
else
|
||||||
add_key "$ppa" "$ppa_url" "$package_dist" "$key_source" "$key_file"
|
arch=$(dpkg --print-architecture)
|
||||||
echo "deb [arch=$arch signed-by=$key_file] $ppa_url $package_dist $branches" | sudo tee -a "$list_dir"/"${ppa/\//-}".list >/dev/null 2>&1
|
[ -e "$key_source" ] && key_file=$key_source || key_file="$key_dir"/"${ppa/\//-}"-keyring.gpg
|
||||||
update_lists "$ppa" "$ppa_search"
|
add_key "$ppa" "$ppa_url" "$package_dist" "$key_source" "$key_file"
|
||||||
. /etc/os-release
|
echo "deb [arch=$arch signed-by=$key_file] $ppa_url $package_dist $branches" | sudo tee -a "$list_dir"/"${ppa/\//-}".list >/dev/null 2>&1
|
||||||
|
update_lists "$ppa" "$ppa_search"
|
||||||
|
. /etc/os-release
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to remove a PPA.
|
# Function to remove a PPA.
|
||||||
|
Loading…
Reference in New Issue
Block a user