mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-19 21:30:10 +01:00
mirror: if index is verified, save a copy in the local mirror
This commit is contained in:
parent
00f5ff8762
commit
77db3ea709
@ -87,7 +87,8 @@ def main():
|
||||
|
||||
def _get_index(section, etag=None):
|
||||
url = _append_to_url_path(section)
|
||||
return index.download_repo_index(url, etag=etag)
|
||||
data, etag = index.download_repo_index(url, etag=etag)
|
||||
return data, etag, _append_to_url_path(section, 'index-v1.jar')
|
||||
else:
|
||||
def _get_index(section, etag=None):
|
||||
import io
|
||||
@ -99,7 +100,7 @@ def main():
|
||||
with zipfile.ZipFile(io.BytesIO(content)) as zip:
|
||||
jsoncontents = zip.open('index-v1.json').read()
|
||||
data = json.loads(jsoncontents.decode('utf-8'))
|
||||
return data, etag
|
||||
return data, etag, None # no verified index file to return
|
||||
|
||||
ip = None
|
||||
try:
|
||||
@ -138,14 +139,16 @@ def main():
|
||||
for section in sections:
|
||||
sectiondir = os.path.join(basedir, section)
|
||||
|
||||
data, etag = _get_index(section)
|
||||
urls = []
|
||||
data, etag, index_url = _get_index(section)
|
||||
if index_url:
|
||||
urls.append(index_url)
|
||||
|
||||
os.makedirs(sectiondir, exist_ok=True)
|
||||
os.chdir(sectiondir)
|
||||
for icondir in icondirs:
|
||||
os.makedirs(os.path.join(sectiondir, icondir), exist_ok=True)
|
||||
|
||||
urls = []
|
||||
for packageName, packageList in data['packages'].items():
|
||||
for package in packageList:
|
||||
to_fetch = []
|
||||
|
@ -1254,6 +1254,39 @@ if which apksigner; then
|
||||
fi
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
echo_header 'test mirroring a repo'
|
||||
|
||||
if which wget; then
|
||||
REPOROOT=`create_test_dir`
|
||||
cd $WORKSPACE/tests
|
||||
test -d archive || mkdir archive
|
||||
cp repo/index-v1.json $REPOROOT/
|
||||
$fdroid signindex
|
||||
mv $REPOROOT/index-v1.json repo/index-v1.json
|
||||
|
||||
port=321${RANDOM:3}
|
||||
timeout 5m python3 -m http.server $port --bind 127.0.0.1 > http.server.log 2>&1 &
|
||||
http_server_pid=$!
|
||||
|
||||
cd $REPOROOT
|
||||
http_proxy= HTTP_PROXY= $fdroid mirror http://127.0.0.1:${port}/
|
||||
test -e 127.0.0.1\:${port}/repo/souch.smsbypass_9.apk
|
||||
test -e 127.0.0.1\:${port}/repo/icons-640/souch.smsbypass.9.png
|
||||
# the index shouldn't be saved unless it was verified
|
||||
! test -e 127.0.0.1\:${port}/repo/index-v1.jar
|
||||
! http_proxy= HTTP_PROXY= $fdroid mirror "http://127.0.0.1:${port}/?fingerprint=asdfasdf"
|
||||
! test -e 127.0.0.1\:${port}/repo/index-v1.jar
|
||||
http_proxy= HTTP_PROXY= $fdroid mirror "http://127.0.0.1:${port}/?fingerprint=F49AF3F11EFDDF20DFFD70F5E3117B9976674167ADCA280E6B1932A0601B26F6"
|
||||
test -e 127.0.0.1\:${port}/repo/index-v1.jar
|
||||
|
||||
# clean up
|
||||
kill -9 $http_server_pid
|
||||
rm -f 127.0.0.1\:${port}/repo/*.apk 127.0.0.1\:${port}/repo/*/*/*/*.png
|
||||
else
|
||||
echo "WARNING: wget not installed, skipping"
|
||||
fi
|
||||
|
||||
#------------------------------------------------------------------------------#
|
||||
|
||||
# remove this to prevent git conflicts and complaining
|
||||
|
Loading…
Reference in New Issue
Block a user