"""
def __init__(self):
+ '''Load filename/date info about previously seen APKs
+
+ Since the appid and date strings both will never have spaces,
+ this is parsed as a list from the end to allow the filename to
+ have any combo of spaces.
+ '''
+
self.path = os.path.join('stats', 'known_apks.txt')
self.apks = {}
if os.path.isfile(self.path):
if len(t) == 2:
self.apks[t[0]] = (t[1], None)
else:
- self.apks[t[0]] = (t[1], datetime.strptime(t[2], '%Y-%m-%d'))
+ appid = t[-2]
+ date = datetime.strptime(t[-1], '%Y-%m-%d')
+ filename = line[0:line.rfind(appid) - 1]
+ self.apks[filename] = (appid, date)
self.changed = False
def writeifchanged(self):
apk is the scanned apk information, and cachechanged is True if the apkcache got changed.
"""
- if ' ' in apkfilename:
- if options.rename_apks:
- newfilename = apkfilename.replace(' ', '_')
- os.rename(os.path.join(repodir, apkfilename),
- os.path.join(repodir, newfilename))
- apkfilename = newfilename
- else:
- logging.critical("Spaces in filenames are not allowed.")
- return True, None, False
-
apk = {}
apkfile = os.path.join(repodir, apkfilename)
copy_apks_into_repo() {
set +x
- for f in `find $APKDIR -name '*.apk' | grep -F -v -e unaligned -e unsigned -e badsig -e badcert -e bad-unicode`; do
- name=$(basename $(dirname `dirname $f`))
+ find $APKDIR -type f -name '*.apk' -print0 | while IFS= read -r -d '' f; do
+ echo $f | grep -F -v -e unaligned -e unsigned -e badsig -e badcert -e bad-unicode || continue
apk=`$aapt dump badging "$f" | sed -n "s,^package: name='\(.*\)' versionCode='\([0-9][0-9]*\)' .*,\1_\2.apk,p"`
- test $f -nt repo/$apk && rm -f repo/$apk # delete existing if $f is newer
+ test "$f" -nt repo/$apk && rm -f repo/$apk # delete existing if $f is newer
if [ ! -e repo/$apk ] && [ ! -e archive/$apk ]; then
echo "$f --> repo/$apk"
- ln $f $1/repo/$apk || \
- rsync -axv $f $1/repo/$apk # rsync if hard link is not possible
+ ln "$f" $1/repo/$apk || \
+ rsync -axv "$f" $1/repo/$apk # rsync if hard link is not possible
fi
done
set -x