setup: Disable install/upgrade when dpkg/apt is running

Show a warning message that a package manager is running. This prevents users
from getting an installation error just because another installation/upgrade is
running.

Closes: #625.
This commit is contained in:
Johannes Keyser authored and Sunil Mohan Adapa committed 2017-04-19 16:50:00 +05:30
1 parent 6a53dd015e
commit 76a63d102b
5 files changed
+49 -17

No files matched your search

+12
View File
@@ -28,6 +28,8 @@ import sys
from plinth import cfg
LOCK_FILE = '/var/lib/dpkg/lock'
def parse_arguments():
"""Return parsed command line arguments as dictionary."""
@@ -41,6 +43,8 @@ def parse_arguments():
'module', help='name of module for which package is being installed')
subparser.add_argument(
'packages', nargs='+', help='list of packages to install')
subparsers.add_parser('is-package-manager-busy',
help='Return whether package manager is busy')
subparsers.required = True
return parser.parse_args()
@@ -94,6 +98,14 @@ def _assert_managed_packages(module, packages):
assert package in module.managed_packages
def subcommand_is_package_manager_busy(_):
"""Return whether package manager is busy."""
try:
subprocess.check_output(['lsof', LOCK_FILE])
except subprocess.CalledProcessError:
sys.exit(-1)
def main():
"""Parse arguments and perform all duties."""
arguments = parse_arguments()
-11
View File
@@ -28,7 +28,6 @@ import sys
CONF_FILE = '/etc/apt/apt.conf.d/50unattended-upgrades'
AUTO_CONF_FILE = '/etc/apt/apt.conf.d/20auto-upgrades'
LOCK_FILE = '/var/lib/dpkg/lock'
LOG_FILE = '/var/log/unattended-upgrades/unattended-upgrades.log'
@@ -42,8 +41,6 @@ def parse_arguments():
help='Check if automatic upgrades are enabled')
subparsers.add_parser('enable-auto', help='Enable automatic upgrades')
subparsers.add_parser('disable-auto', help='Disable automatic upgrades.')
subparsers.add_parser('is-package-manager-busy',
help='Return whether package manager is busy')
subparsers.add_parser('get-log', help='Print the automatic upgrades log')
subparsers.required = True
@@ -129,14 +126,6 @@ def setup():
conffile.write(' "origin=Debian";\n')
def subcommand_is_package_manager_busy(_):
"""Return whether package manager is busy."""
try:
subprocess.check_output(['lsof', LOCK_FILE])
except subprocess.CalledProcessError:
sys.exit(-1)
def subcommand_get_log(_):
"""Print the automatic upgrades log."""
try: