Re: Disable all catalogues at once ?
Apparently there's a default list of catalogues that gets used when the file is empty. This script will instead create a set of disabled catalogues (rather than an empty file). Save the following code into a file (I'd suggest /usr/bin/set_repositories):
Code:
#!/bin/sh
ACTION=$1
CAT_DIR=/etc/hildon-application-manager
DEF_CAT=catalogues
DISABLED_CAT=catalogues.disabled
ENABLED_CAT=catalogues.enabled
CUR_STATUS=""
move_catalogues() {
NEW_CAT=$1
OLD_CAT=$2
mv "$CAT_DIR/$DEF_CAT" "$CAT_DIR/$OLD_CAT" && mv "$CAT_DIR/$NEW_CAT" "$CAT_DIR/$DEF_CAT"
}
create_empty_catalogue() {
cat > "$CAT_DIR/$DISABLED_CAT" << EOF
<catalogues>
<catalogue>
<file>variant-catalogues</file>
<id>nokia-certified</id>
<disabled/>
</catalogue>
<catalogue>
<file>variant-catalogues</file>
<id>nokia-system</id>
<disabled/>
</catalogue>
<catalogue>
<file>variant-catalogues</file>
<id>ovi</id>
<disabled/>
</catalogue>
<catalogue>
<file>variant-catalogues</file>
<id>maemo-extras</id>
<disabled/>
</catalogue>
</catalogues>
EOF
}
if [ ! -f "$CAT_DIR/$DEF_CAT" ]; then
echo "No primary catalogue file found. Please fix before rerunning."
exit 1
fi
if [ -f "$CAT_DIR/$ENABLED_CAT" ]; then
CUR_STATUS=disabled
fi
if [ -f "$CAT_DIR/$DISABLED_CAT" ]; then
if [ -n "$CUR_STATUS" ]; then
echo "Cannot determine status."
exit 1
fi
CUR_STATUS=enabled
fi
if [ -z "$CUR_STATUS" ]; then
create_empty_catalogue
CUR_STATUS="enabled"
fi
if [ "$ACTION" == "enable" ]; then
if [ "$CUR_STATUS" == "enabled" ]; then
echo "Already enabled"
exit 0
fi
move_catalogues $ENABLED_CAT $DISABLED_CAT
elif [ "$ACTION" == "disable" ]; then
if [ "$CUR_STATUS" == "disabled" ]; then
echo "Already disabled"
exit 0
fi
move_catalogues $DISABLED_CAT $ENABLED_CAT
elif [ "$ACTION" == "status" ]; then
echo $CUR_STATUS
else
echo "Unknown action"
exit 1
fi
exit $?
Then do "chmod 700 /usr/bin/set_repositories" to make it executable. You can then disabled the repositories by running:
Code:
set_repositories disable
Using "enable" instead will re-enable them, and "status" will report whether they're currently enabled or disabled. There's checks in place to prevent you enabling them when they're already enabled (and ditto for disabling) and checks which should prevent the script from ever overwriting the catalogue list by mistake (these would only be needed if the script is stopped mid-way through running, or you mess around with the catalogue files manually).
You'll need to be root to create this script, and to enable/disable the repositories.
Finally, a bit of info on what the script actually does (for those who don't understand shell scripting). It will create a catalogues.disabled file (in /etc/hildon-application-manager) which contains the basic set of repositories, all set as disabled. When asked to disable the repositories, it renames the original list to catalogues.enabled and renames the catalogues.disabled list to be the default (and vice-versa when enabled).
|