Base
This commit is contained in:
commit
6ebc482236
87
apkdroid.py
Normal file
87
apkdroid.py
Normal file
@ -0,0 +1,87 @@
|
||||
import requests
|
||||
import logging
|
||||
import re
|
||||
import os
|
||||
import shutil
|
||||
|
||||
repo_url = "https://fdroid.lsd.cat"
|
||||
repo_name = "lsd.cat Proprietary Apps Repo"
|
||||
repo_icon = "fdroid-icon.png"
|
||||
repo_description = """
|
||||
This is a repository to install proprietary apps via fdroid
|
||||
"""
|
||||
|
||||
repo_original_url = "https://MyFirstFDroidRepo.org/fdroid/repo"
|
||||
repo_original_name = "My First F-Droid Repo Demo"
|
||||
repo_original_icon = "fdroid-icon.png"
|
||||
repo_original_description = """
|
||||
This is a repository of apps to be used with F-Droid. Applications in this
|
||||
repository are either official binaries built by the original application
|
||||
developers, or are binaries built from source by the admin of f-droid.org
|
||||
using the tools on https://gitlab.com/u/fdroid.
|
||||
"""
|
||||
|
||||
keystore = None
|
||||
keystorepass = None
|
||||
|
||||
repo = 'fdroid/'
|
||||
urls = [
|
||||
"https://www.whatsapp.com/android/",
|
||||
"https://help.netflix.com/en/node/57688",
|
||||
"https://download.spotify.com/android/SpotifyAndroid.apk",
|
||||
"https://updates.signal.org/android/latest.json",
|
||||
"https://wire.com/en/download/"
|
||||
]
|
||||
|
||||
def get_apk(baseurl):
|
||||
page = requests.get(baseurl)
|
||||
if page.headers['content-type'] == 'application/vnd.android.package-archive':
|
||||
name = baseurl.rsplit('/', 1)[-1]
|
||||
logging.info('Downloading ' + name)
|
||||
with open('repo/' + name, 'wb') as handle:
|
||||
for block in page.iter_content(1024):
|
||||
handle.write(block)
|
||||
else:
|
||||
url = re.findall('https\:\/\/(.*)\.apk', page.text)[0]
|
||||
get_apk('https://' + url + '.apk')
|
||||
|
||||
def check_env(repo):
|
||||
if not shutil.which('fdroid'):
|
||||
logging.error('Please install fdroidserver')
|
||||
sys.exit(1)
|
||||
|
||||
if os.path.isdir(repo) is False:
|
||||
try:
|
||||
os.mkdir(repo)
|
||||
except:
|
||||
logging.error('Cannot create repository directory')
|
||||
|
||||
|
||||
if ('repo' or 'config.py') not in os.listdir(repo):
|
||||
logging.info('Initializing a new repository')
|
||||
os.chdir(repo)
|
||||
os.system('fdroid init')
|
||||
|
||||
with open('config.py', 'r') as file :
|
||||
filedata = file.read()
|
||||
|
||||
filedata = filedata.replace(repo_original_url, repo_url)
|
||||
filedata = filedata.replace(repo_original_name, repo_name)
|
||||
filedata = filedata.replace(repo_original_description, repo_description)
|
||||
|
||||
with open('config.py', 'w') as file:
|
||||
file.write(filedata)
|
||||
|
||||
else:
|
||||
os.chdir(repo)
|
||||
logging.info('Repo already exists')
|
||||
# TODO import keystore and check keys
|
||||
|
||||
def build(repo):
|
||||
os.system('fdroid update -c')
|
||||
|
||||
|
||||
check_env(repo)
|
||||
for i in urls:
|
||||
get_apk(i)
|
||||
build(repo)
|
Loading…
Reference in New Issue
Block a user