Improve apt-get update process

This commit is contained in:
VirtuBox
2019-10-11 12:39:00 +02:00
parent e32a2a1102
commit e42eb52bba
2 changed files with 28 additions and 20 deletions

View File

@@ -447,8 +447,8 @@ wo_git_config() {
fi fi
# .gitconfig inital setup # .gitconfig inital setup
#cd /var/lib/wo/tmp/WordOps-install || exit 1 cd /var/lib/wo/tmp/WordOps-install || exit 1
#python3 gitconfig.py python3 gitconfig.py
} }

View File

@@ -19,12 +19,21 @@ class WOAptGet():
try: try:
with open('/var/log/wo/wordops.log', 'a') as f: with open('/var/log/wo/wordops.log', 'a') as f:
proc = subprocess.Popen( proc = subprocess.Popen(
'DEBIAN_FRONTEND=noninteractive apt-get update -qq', 'DEBIAN_FRONTEND=noninteractive apt-get update -qq '
'--allow-releaseinfo-change',
shell=True, stdin=None, stdout=f, shell=True, stdin=None, stdout=f,
stderr=subprocess.PIPE, executable="/bin/bash") stderr=subprocess.PIPE, executable="/bin/bash")
proc.wait() proc.wait()
output, error_output = proc.communicate() output, error_output = proc.communicate()
if "--allow-releaseinfo-change" in str(error_output):
proc = subprocess.Popen(
'DEBIAN_FRONTEND=noninteractive apt-get update -qq',
shell=True,
stdin=None, stdout=f, stderr=f,
executable="/bin/bash")
proc.wait()
output, error_output = proc.communicate()
# Check what is error in error_output # Check what is error in error_output
if "NO_PUBKEY" in str(error_output): if "NO_PUBKEY" in str(error_output):
# Split the output # Split the output
@@ -38,10 +47,11 @@ class WOAptGet():
WORepo.add_key( WORepo.add_key(
self, key, keyserver="hkp://pgp.mit.edu") self, key, keyserver="hkp://pgp.mit.edu")
proc = subprocess.Popen('apt-get update', proc = subprocess.Popen(
shell=True, 'DEBIAN_FRONTEND=noninteractive apt-get update -qq',
stdin=None, stdout=f, stderr=f, shell=True,
executable="/bin/bash") stdin=None, stdout=f, stderr=f,
executable="/bin/bash")
proc.wait() proc.wait()
if proc.returncode == 0: if proc.returncode == 0:
@@ -84,11 +94,11 @@ class WOAptGet():
with open('/var/log/wo/wordops.log', 'a') as f: with open('/var/log/wo/wordops.log', 'a') as f:
proc = subprocess.Popen( proc = subprocess.Popen(
"DEBIAN_FRONTEND=noninteractive " "DEBIAN_FRONTEND=noninteractive "
"apt-get dist-upgrade " "apt-get "
"--option=Dpkg::options::=--force-confdef " "--option=Dpkg::options::=--force-confdef "
"--option=Dpkg::options::=--force-unsafe-io " "--option=Dpkg::options::=--force-unsafe-io "
"--option=Dpkg::options::=--force-confold " "--option=Dpkg::options::=--force-confold "
"--assume-yes --quiet ", "--assume-yes --quiet dist-upgrade",
shell=True, stdin=None, shell=True, stdin=None,
stdout=f, stderr=f, stdout=f, stderr=f,
executable="/bin/bash") executable="/bin/bash")
@@ -111,17 +121,15 @@ class WOAptGet():
all_packages = ' '.join(packages) all_packages = ' '.join(packages)
try: try:
with open('/var/log/wo/wordops.log', 'a') as f: with open('/var/log/wo/wordops.log', 'a') as f:
proc = subprocess.Popen("DEBIAN_FRONTEND=noninteractive " proc = subprocess.Popen(
"apt-get install " "DEBIAN_FRONTEND=noninteractive "
"--option=Dpkg::options::=" "apt-get install "
"--force-confdef " "--option=Dpkg::options::=--force-confdef "
"--option=Dpkg::options::=" "--option=Dpkg::options::=--force-confold "
"--force-confold " "--assume-yes --allow-unauthenticated {0}"
"--assume-yes " .format(all_packages), shell=True,
"--allow-unauthenticated {0}" stdin=None, stdout=f, stderr=f,
.format(all_packages), shell=True, executable="/bin/bash")
stdin=None, stdout=f, stderr=f,
executable="/bin/bash")
proc.wait() proc.wait()
if proc.returncode == 0: if proc.returncode == 0: