maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   General (https://talk.maemo.org/forumdisplay.php?f=7)
-   -   Disable all catalogues at once ? (https://talk.maemo.org/showthread.php?t=71797)

AgogData 2011-04-04 15:50

Disable all catalogues at once ?
 
When i'm not at home and there is no wifi i connect to the internet via my supporter (vodafone) and app manager automatically start to update in the background consuming large amount of credit, so wherever i'm outdoor and i wanted to connect i manually disable all catalogues one by one and then connect and when i'm home i check them back.
Is there a command that i can type to disable all catalogues at once and then return them back when i'm offline ?
i'm aware of
Code:

gconftool -s --type int /apps/hildon/update-notifier/check_interval NEW_VALUE
but it only sets the intervals between the updates and its not what i'm looking for.

AgogData 2011-04-05 12:38

Re: Disable all catalogues at once ?
 
so, any1 ?

jedi 2011-04-05 12:45

Re: Disable all catalogues at once ?
 
Set the check interval to a stupidly high number so it's effectively disabled.

Then occasionally do a 'apt-get update' at the command line, and 'apt-get upgrade' if you want to run a upgrade.


Edit - reason: http://talk.maemo.org/showpost.php?p...&postcount=119 - sorry I forgot you don't like my posts.

Rob1n 2011-04-05 12:54

Re: Disable all catalogues at once ?
 
The catalogues are stored in /etc/hildon-application-manager/catalogues, so you could probably do (as root):

Disable all:
Code:

sed -i -e "s/<enabled\/>/<disabled\/>/" /etc/hildon-application-manager/catalogues
Enable all:
Code:

sed -i -e "s/<disabled\/>/<enabled\/>/" /etc/hildon-application-manager/catalogues
I've not tested this myself though, so make sure you take a backup of the files beforehand!

AgogData 2011-04-05 14:55

Re: Disable all catalogues at once ?
 
Quote:

Originally Posted by jedi (Post 981751)
Set the check interval to a stupidly high number so it's effectively disabled.

Then occasionally do a 'apt-get update' at the command line, and 'apt-get upgrade' if you want to run a upgrade.

Edit - reason: http://talk.maemo.org/showpost.php?p...&postcount=119 - sorry I forgot you don't like my posts.

nice memory you have, but lets take a look at what i said

Quote:

Originally Posted by AgogData (Post 981751)
but it only sets the intervals between the updates and its not what i'm looking for.

oh, i said i'm not looking for changing the intervals..so you are right when you said :

Quote:

Originally Posted by jedi (Post 981751)
I forgot you don't like my posts.

---------------------------------------------

Quote:

Originally Posted by Rob1n (Post 982374)
The catalogues are stored in /etc/hildon-application-manager/catalogues, so you could probably do (as root):

Disable all:
Code:

sed -i -e "s/<enabled\/>/<disabled\/>/" /etc/hildon-application-manager/catalogues
Enable all:
Code:

sed -i -e "s/<disabled\/>/<enabled\/>/" /etc/hildon-application-manager/catalogues
I've not tested this myself though, so make sure you take a backup of the files beforehand!

i tried it but didn't work, i suppose its a command to replace all the enables words with disables..if thats so i opened catalogues file and there were no "enable" word there, only disable for a couple of catalogues i disabled before.

jedi 2011-04-05 15:09

Re: Disable all catalogues at once ?
 
Quote:

Originally Posted by AgogData (Post 982472)
nice memory you have, but lets take a look at what i said



oh, i said i'm not looking for changing the intervals..so you are right when you said :

My point was that changing the intervals might actually be the right thing to do to achieve what you want. Just because you've decreed that it shouldn't be part of the solution does not mean it's not valid. Also, didn't you notice the strikeout line right though my 'solution'?

But why am I even bothering to waste my time when you've made it clear that you "don't like my posts".

demolition 2011-04-05 15:25

Re: Disable all catalogues at once ?
 
One way to prevent unwanted automatic updates is to disable all repositories in HAM and use Faster Application Manager (FAM) as your main application manager. Is that an option?

Manually updating software is possible with FAM so long as you have the appropriate repositories set up and enabled but you won't get that little yellow symbol in the status area.

vi_ 2011-04-05 15:28

Re: Disable all catalogues at once ?
 
1. Use ifup/ifdown scripts to enable/disable the the checking depending on the network connection.

2. Use rob1n's method, except use sed to put a '#' infront of everyline.

3. Jedi's solution.


Personally I would opt for Jedi's solution, it is the easiest/most foolproof to implement.

Just accept that maybe once a month you should check for updates with HAM, hell even put a reminder in the calender if it matters that much. Frankly, updates are pretty rare and people useually talk on the forum if there are any. Further more this mitigates the daily PITA that is that stupid update check.

AgogData 2011-04-05 15:30

Re: Disable all catalogues at once ?
 
@demolition : thanks for the advice but i still want to use HAM as my 1ry application manager and i'm sure therer is a command that can edit catalogues file as Rob1n said

vi_ 2011-04-05 15:34

Re: Disable all catalogues at once ?
 
yes there is:

Code:

vi

AgogData 2011-04-05 15:34

Re: Disable all catalogues at once ?
 
Quote:

Originally Posted by vi_ (Post 982491)
1. Use ifup/ifdown scripts to enable/disable the the checking depending on the network connection.

does that mean i can change the checking for update depending on which connection i'm using (wifi / vodafone)


Quote:

Originally Posted by vi_ (Post 982491)
2. Use rob1n's method, except use sed to put a '#' infront of everyline.

how can i do that ?

Rob1n 2011-04-05 16:02

Re: Disable all catalogues at once ?
 
Quote:

Originally Posted by AgogData (Post 982472)
i tried it but didn't work, i suppose its a command to replace all the enables words with disables..if thats so i opened catalogues file and there were no "enable" word there, only disable for a couple of catalogues i disabled before.

You're right - I thought I'd checked for that :(

You could also try creating an empty catalogue file and swapping the two around. The following script will do this, and enable you to switch between them:
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"
}

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
        echo "<catalogues/>" > "$CAT_DIR/$DISABLED_CAT"
        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 $?

It accepts one of three arguments - enable, disable or status (which reports what the current state is).

Rob1n 2011-04-06 08:48

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).

AgogData 2011-04-06 13:07

Re: Disable all catalogues at once ?
 
Rob1n you are the man i can't thank you enough :)

jstokes 2011-04-06 13:19

Re: Disable all catalogues at once ?
 
Quote:

Originally Posted by AgogData (Post 981751)
When i'm not at home and there is no wifi i connect to the internet via my supporter (vodafone) and app manager automatically start to update in the background consuming large amount of credit

This is probably something for the CSSU or a developer, and I haven't tested this (don't have the time to tether my phone to my N800), but if you grab H.A.M.'s source, open the file hildon-application-manager-2.2.71\statusbar\ham-updates-status-menu-item.c and in the function ham_updates_status_menu_item_connection_cb, you can remove the line "|| g_strstr_len (bearer, -1, "GPRS") != NULL" and the statusbar applet (which is the thing that invokes the update operation when asked to by alarmd) shouldn't consider your N900 to be online when using a cellular connection


All times are GMT. The time now is 05:41.

vBulletin® Version 3.8.8