Reply
Thread Tools
AgogData's Avatar
Posts: 870 | Thanked: 133 times | Joined on Aug 2010
#11
Originally Posted by vi_ View Post
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)


Originally Posted by vi_ View Post
2. Use rob1n's method, except use sed to put a '#' infront of everyline.
how can i do that ?
 
Posts: 3,617 | Thanked: 2,412 times | Joined on Nov 2009 @ Cambridge, UK
#12
Originally Posted by AgogData View Post
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).
 

The Following 3 Users Say Thank You to Rob1n For This Useful Post:
Posts: 3,617 | Thanked: 2,412 times | Joined on Nov 2009 @ Cambridge, UK
#13
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).
 

The Following 3 Users Say Thank You to Rob1n For This Useful Post:
AgogData's Avatar
Posts: 870 | Thanked: 133 times | Joined on Aug 2010
#14
Rob1n you are the man i can't thank you enough
 
Posts: 235 | Thanked: 339 times | Joined on Nov 2010
#15
Originally Posted by AgogData View Post
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
 

The Following User Says Thank You to jstokes For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 09:54.