mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-14 15:02:51 +03:00
Begin work on better ways to check for updates
This commit is contained in:
parent
af871464f4
commit
fd7278c4ef
10 changed files with 1 additions and 195 deletions
|
@ -1,32 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# checkmarket.py - part of the FDroid server tools
|
|
||||||
# Copyright (C) 2011, Ciaran Gultnieks, ciaran@ciarang.com
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
#Read configuration...
|
|
||||||
repo_name = None
|
|
||||||
repo_description = None
|
|
||||||
repo_icon = None
|
|
||||||
repo_url = None
|
|
||||||
execfile('config.py')
|
|
||||||
|
|
||||||
subprocess.call('./run.sh ' + market_user + ' ' + market_password
|
|
||||||
+ ' ' + market_deviceid,
|
|
||||||
cwd='marketcheck', shell=True)
|
|
||||||
|
|
|
@ -325,6 +325,7 @@ def parse_metadata(metafile, **kw):
|
||||||
thisinfo['Donate'] = None
|
thisinfo['Donate'] = None
|
||||||
thisinfo['Disabled'] = None
|
thisinfo['Disabled'] = None
|
||||||
thisinfo['AntiFeatures'] = None
|
thisinfo['AntiFeatures'] = None
|
||||||
|
thisinfo['Update Check Mode'] = 'Market'
|
||||||
thisinfo['Market Version'] = ''
|
thisinfo['Market Version'] = ''
|
||||||
thisinfo['Market Version Code'] = '0'
|
thisinfo['Market Version Code'] = '0'
|
||||||
thisinfo['Repo Type'] = ''
|
thisinfo['Repo Type'] = ''
|
||||||
|
|
1
marketcheck/.gitignore
vendored
1
marketcheck/.gitignore
vendored
|
@ -1 +0,0 @@
|
||||||
*.class
|
|
|
@ -1,11 +0,0 @@
|
||||||
|
|
||||||
=Libraries=
|
|
||||||
|
|
||||||
androidmarketapi-x.x.jar is Apache 2.0 licensed - source from:
|
|
||||||
|
|
||||||
http://code.google.com/p/android-market-api/
|
|
||||||
|
|
||||||
https://code.google.com/p/protobuf/ is New BSD licensed - source from:
|
|
||||||
|
|
||||||
https://code.google.com/p/protobuf/
|
|
||||||
|
|
Binary file not shown.
|
@ -1,2 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
javac -classpath androidmarketapi-0.6.jar test.java
|
|
Binary file not shown.
|
@ -1,2 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
java -classpath ".:androidmarketapi-0.6.jar" test $1 $2 $3
|
|
|
@ -1,147 +0,0 @@
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import com.gc.android.market.api.MarketSession.Callback;
|
|
||||||
import com.gc.android.market.api.MarketSession;
|
|
||||||
import com.gc.android.market.api.model.Market.App;
|
|
||||||
import com.gc.android.market.api.model.Market.AppsResponse;
|
|
||||||
import com.gc.android.market.api.model.Market.AppsRequest;
|
|
||||||
import com.gc.android.market.api.model.Market.CommentsRequest;
|
|
||||||
import com.gc.android.market.api.model.Market.GetImageRequest;
|
|
||||||
import com.gc.android.market.api.model.Market.GetImageResponse;
|
|
||||||
import com.gc.android.market.api.model.Market.ResponseContext;
|
|
||||||
import com.gc.android.market.api.model.Market.GetImageRequest.AppImageUsage;
|
|
||||||
|
|
||||||
class test {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param args
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
try {
|
|
||||||
if(args.length < 3) {
|
|
||||||
System.out.println("Parameters :\n" +
|
|
||||||
"email password deviceid");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String login = args[0];
|
|
||||||
String password = args[1];
|
|
||||||
String deviceid = args[2];
|
|
||||||
|
|
||||||
// Get a list of apps we want to check - i.e. those that
|
|
||||||
// we have metadata files for...
|
|
||||||
File dir = new File("../metadata");
|
|
||||||
List<String> apps = new ArrayList<String>();
|
|
||||||
String[] metafiles = dir.list();
|
|
||||||
for (int i=0; i<metafiles.length; i++) {
|
|
||||||
String metafile = metafiles[i];
|
|
||||||
if(metafile.endsWith(".txt")) {
|
|
||||||
String pkg = metafile.substring(0,
|
|
||||||
metafile.length() - 4);
|
|
||||||
apps.add(pkg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("Apps to check: " + apps.size());
|
|
||||||
|
|
||||||
MarketSession session = new MarketSession();
|
|
||||||
|
|
||||||
session.getContext().setAndroidId(deviceid);
|
|
||||||
session.getContext().setDeviceAndSdkVersion("sapphire:7");
|
|
||||||
System.out.println("Login...");
|
|
||||||
session.login(login,password);
|
|
||||||
System.out.println("Login done");
|
|
||||||
|
|
||||||
MarketSession.Callback callback = new MarketSession.Callback() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResult(ResponseContext context, Object oresp) {
|
|
||||||
try {
|
|
||||||
AppsResponse response = (AppsResponse)oresp;
|
|
||||||
if(response == null) {
|
|
||||||
System.out.println("No response");
|
|
||||||
}
|
|
||||||
if(response.getAppCount() != 1) {
|
|
||||||
System.out.println("Not in market, or multiple results");
|
|
||||||
} else {
|
|
||||||
App app = response.getAppList().get(0);
|
|
||||||
String filespec = "../metadata/" + app.getPackageName() + ".txt";
|
|
||||||
FileInputStream fi = new FileInputStream(filespec);
|
|
||||||
InputStreamReader isr = new InputStreamReader(fi, "UTF-8");
|
|
||||||
BufferedReader br = new BufferedReader(isr);
|
|
||||||
StringBuilder output = new StringBuilder();
|
|
||||||
boolean changed = false;
|
|
||||||
boolean vercodefound = false;
|
|
||||||
boolean versionfound = false;
|
|
||||||
String line, newline;
|
|
||||||
while (br.ready()) {
|
|
||||||
line = br.readLine();
|
|
||||||
if (line.startsWith("Market Version:")) {
|
|
||||||
versionfound = true;
|
|
||||||
newline="Market Version:" + app.getVersion();
|
|
||||||
if (!newline.equals(line)) {
|
|
||||||
changed = true;
|
|
||||||
line = newline;
|
|
||||||
}
|
|
||||||
} else if (line.startsWith("Market Version Code:")) {
|
|
||||||
vercodefound = true;
|
|
||||||
newline="Market Version Code:" + app.getVersionCode();
|
|
||||||
if (!newline.equals(line)) {
|
|
||||||
changed = true;
|
|
||||||
line = newline;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
output.append(line + "\n");
|
|
||||||
}
|
|
||||||
br.close();
|
|
||||||
isr.close();
|
|
||||||
fi.close();
|
|
||||||
if(!versionfound) {
|
|
||||||
changed = true;
|
|
||||||
output.append("Market Version:" + app.getVersion() + "\n");
|
|
||||||
}
|
|
||||||
if(!vercodefound) {
|
|
||||||
changed = true;
|
|
||||||
output.append("Market Version Code:" + app.getVersionCode() + "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changed) {
|
|
||||||
System.out.println("..updating");
|
|
||||||
FileOutputStream fo = new FileOutputStream(filespec);
|
|
||||||
OutputStreamWriter osr = new OutputStreamWriter(fo, "UTF-8");
|
|
||||||
BufferedWriter wi = new BufferedWriter(osr);
|
|
||||||
wi.write(output.toString());
|
|
||||||
wi.close();
|
|
||||||
osr.close();
|
|
||||||
fo.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
System.out.println("...Exception");
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
for(String pkg : apps) {
|
|
||||||
System.out.println("Checking: " + pkg);
|
|
||||||
AppsRequest appsRequest = AppsRequest.newBuilder()
|
|
||||||
.setQuery("pname:" + pkg)
|
|
||||||
.setStartIndex(0).setEntriesCount(10)
|
|
||||||
.setWithExtendedInfo(true)
|
|
||||||
.build();
|
|
||||||
session.append(appsRequest, callback);
|
|
||||||
session.flush();
|
|
||||||
|
|
||||||
// Pause to avoid rate limit...
|
|
||||||
Thread.sleep(5000);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch(Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue