PPA Launchpad smart feature#156
Open
FrankiePustorino wants to merge 1 commit intoUtappia:masterfrom
Open
Conversation
1. Availability check – CHECK_LAUNCHPAD
bash
function CHECK_LAUNCHPAD {
if curl -4 -s --max-time 8 --connect-timeout 5 --head --fail \
"https://ppa.launchpad.net" >/dev/null 2>&1; then
return 0
fi
return 1
}
It verifies whether ppa.launchpad.net is reachable before attempting apt update.
2. Disable / Restore functions
DISABLE_LAUNCHPAD_SOURCES – Finds all .list and .sources files in /etc/apt/sources.list.d that reference ppa.launchpad.net and renames them to *.ucare_disabled. It also comments out any ppa.launchpad.net lines in /etc/apt/sources.list with a marker.
RESTORE_LAUNCHPAD_SOURCES – Reverses both operations, restoring the original files and commenting.
3. Usage in the maintenance flow
Inside the MAINTENANCE function:
bash
echo -e "${YELLOW} • Checking ppa.launchpad.net availability...${ENDCOLOR}"
if ! CHECK_LAUNCHPAD; then
echo -e "${YELLOW}⚠ ppa.launchpad.net appears to be unreachable ...${ENDCOLOR}"
DISABLE_LAUNCHPAD_SOURCES
_UCARE_PPA_EXCLUDED=1
else
echo -e "${CYAN} ✓ ppa.launchpad.net is reachable ...${ENDCOLOR}"
fi
# ... then apt update runs ...
# After the update, sources are restored unconditionally:
if [ "$_UCARE_PPA_EXCLUDED" -eq 1 ]; then
echo -e "${GREEN}▸ Restoring temporarily disabled PPA sources${ENDCOLOR}"
RESTORE_LAUNCHPAD_SOURCES
echo -e "${YELLOW}⚠ Note: PPA packages were not updated this run.${ENDCOLOR}"
fi
Therefore, the script fully validates and implements a “skip/disable Launchpad PPA when unreachable” mechanism, and automatically restores them after the update run.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Availability check – CHECK_LAUNCHPAD bash
function CHECK_LAUNCHPAD {
if curl -4 -s --max-time 8 --connect-timeout 5 --head --fail
"https://ppa.launchpad.net" >/dev/null 2>&1; then
return 0
fi
return 1
}
It verifies whether ppa.launchpad.net is reachable before attempting apt update.
Disable / Restore functions DISABLE_LAUNCHPAD_SOURCES – Finds all .list and .sources files in /etc/apt/sources.list.d that reference ppa.launchpad.net and renames them to *.ucare_disabled. It also comments out any ppa.launchpad.net lines in /etc/apt/sources.list with a marker.
RESTORE_LAUNCHPAD_SOURCES – Reverses both operations, restoring the original files and commenting.
bash
echo -e "${YELLOW} • Checking ppa.launchpad.net availability...${ENDCOLOR}" if ! CHECK_LAUNCHPAD; then
echo -e "${YELLOW}⚠ ppa.launchpad.net appears to be unreachable ...${ENDCOLOR}"
DISABLE_LAUNCHPAD_SOURCES
_UCARE_PPA_EXCLUDED=1
else
echo -e "${CYAN} ✓ ppa.launchpad.net is reachable ...${ENDCOLOR}"
fi
... then apt update runs ...
After the update, sources are restored unconditionally: if [ "$_UCARE_PPA_EXCLUDED" -eq 1 ]; then
fi
Therefore, the script fully validates and implements a “skip/disable Launchpad PPA when unreachable” mechanism, and automatically restores them after the update run.