lock/unlock packages

This commit is contained in:
Usman Nasir
2020-05-05 17:47:11 +05:00
parent 126c191be2
commit 78ea0835a4
4 changed files with 152 additions and 6 deletions

View File

@@ -731,6 +731,10 @@ def fetchPackages(request):
type = data['type']
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
command = 'apt-mark showhold'
locked = ProcessUtilities.outputExecutioner(command).split('\n')
command = 'apt list --installed'
packages = ProcessUtilities.outputExecutioner(command).split('\n')
packages = packages[4:]
@@ -772,7 +776,12 @@ def fetchPackages(request):
current = nowSplitted[1].split(' ')
upgrade = '%s %s %s' % (current[3], current[4], current[5])
dic = {'package': nowSplitted[0].split('/')[0], 'version': '%s %s' % (nowSplitted[1].split(' ')[1], nowSplitted[1].split(' ')[2]), 'upgrade': upgrade}
if nowSplitted[0].split('/')[0] in locked:
lock = 1
else:
lock = 0
dic = {'package': nowSplitted[0].split('/')[0], 'version': '%s %s' % (nowSplitted[1].split(' ')[1], nowSplitted[1].split(' ')[2]), 'upgrade': upgrade, 'lock': lock}
counter = counter + 1
if checker == 0:
@@ -856,6 +865,39 @@ def updatePackage(request):
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException as msg:
data_ret = {'status': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def lockStatus(request):
try:
userID = request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadError()
data = json.loads(request.body)
package = data['package']
type = data['type']
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
if type == 0:
command = 'apt-mark unhold %s' % (package)
ProcessUtilities.executioner(command)
else:
command = 'apt-mark hold %s' % (package)
ProcessUtilities.executioner(command)
data_ret = {'status': 1}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException as msg:
data_ret = {'status': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)