Skip to content
Snippets Groups Projects
Commit db1605b8 authored by Christopher Spinrath's avatar Christopher Spinrath
Browse files

Merge branch 'master' of fs-gitlab:osak/lipstick

parents 9623685e 79f1f360
No related branches found
No related tags found
No related merge requests found
......@@ -4,11 +4,83 @@
import sys, os, io, subprocess
import json
import apt
from PyQt5 import QtWidgets, QtGui, QtCore, QtDBus
import dbus
import traceback
import tempfile
from PyQt5 import QtWidgets, QtGui, QtCore
from collections import OrderedDict
cache = apt.cache.Cache()
def get_devices():
devices = []
bus = dbus.SystemBus()
udisks_manager = bus.get_object("org.freedesktop.UDisks2", "/org/freedesktop/UDisks2")
manager_iface = dbus.Interface(udisks_manager, "org.freedesktop.DBus.ObjectManager")
try:
for k,v in manager_iface.GetManagedObjects().items():
drive_info = v.get("org.freedesktop.UDisks2.Block", {})
if drive_info.get("IdUsage") == "filesystem":
label = str(drive_info.get("IdLabel"))
device = bytearray(drive_info.get("Device")).replace(b"\x00",b"").decode("utf-8")
fs_info = v.get("org.freedesktop.UDisks2.Filesystem")
dbus_mpoints = fs_info.get("MountPoints")
mpoints = [bytearray(mpoint).replace(b"\x00",b"").decode("utf-8") for mpoint in dbus_mpoints]
devices.append((label, device, mpoints))
except Exception as ex:
traceback.print_exc(ex)
print("No devices found")
return devices
def mount_stick(dev):
bus = dbus.SystemBus()
udisks = bus.get_object("org.freedesktop.UDisks2", "/org/freedesktop/UDisks2/block_devices/%s"%(dev,))
iface = dbus.Interface(udisks, "org.freedesktop.UDisks2.Filesystem")
res = None
try:
res = bytearray(iface.Mount()).replace(b"\x00",b"").decode("utf-8")
except Exception as ex:
traceback.print_exc(ex)
print("Could not mount %s"%(dev,))
return res
def find_lipstick():
devices = get_devices()
stick = None
for device in devices:
if device[0].lower()=="lipstick":
stick = device
return stick
def enable_offline_repo(gui):
try_again = True
stick = None
while True:
stick = find_lipstick()
if stick is not None:
if len(stick[2])<1:
mount_stick(stick[1])
stick = find_lipstick()
if stick is None or (type(stick) is tuple and len(stick[2])<=0):
choice = QtWidgets.QMessageBox.question(gui, 'LIPStick nicht gefunden!', "Möchtest du noch einmal versuchen den LIPStick zu finden?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
if choice == QtWidgets.QMessageBox.No:
try_again = False
else:
try_again = False
if not try_again:
break
if stick is None:
QtWidgets.QMessageBox.critical(gui, "Kein LIPStick gefunden", "Es wird ohne LIPStick weiter gemacht")
return
subprocess_wrap(['/bin/bash', basedir+"/liprepoctl.sh", "on", stick[2][0]])
def disable_offline_repo():
subprocess_wrap(['/bin/bash', basedir+"/liprepoctl.sh", "off"])
def subprocess_wrap(what):
proc = subprocess.Popen(what, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while True:
......@@ -115,11 +187,13 @@ def installProcess():
window.ui.progressBar.show()
window.ui.progressBar.setRange(0,0)
pkglist = getPackagelistTree()
enable_offline_repo(window)
installPackages(pkglist)
#window.ui.progressBar.setRange(0,1)
#window.ui.progressBar.setValue(1)
makeDoku(pkglist)
showSuccBox()
disable_offline_repo()
def showSuccBox():
succBox = QtWidgets.QMessageBox()
......@@ -163,8 +237,7 @@ def checkIfRoot():
def installPackages(strlist):
global pkglist
cache.update(sources_list='')
cache.update()
cache.open(None)
for pkg in pkglist:
......@@ -175,20 +248,18 @@ def installPackages(strlist):
cache.commit(apt.progress.text.AcquireProgress(), apt.progress.base.InstallProgress())
except Exception as ex:
print("Error during install",ex)
def enableFirewall():
command=['ufw', 'enable']
subprocess_wrap(command)
def mountStick():
command=[basedir+"/infuse_offline_repo.sh"]
command=['/bin/bash', basedir+"/infuse_offline_repo.sh"]
subprocess_wrap(command)
def makeDoku(stringlist):
global pkglist
#command=["echo", "./makeDoku.sh", basedir, " ".join(stringlist)]
command=["./makeDoku.sh", basedir+"/", " ".join(pkglist)]
command=['/bin/bash', basedir+"/makeDoku.sh", basedir+"/", " ".join(pkglist)]
subprocess_wrap(command)
def getPackagelist():
......@@ -256,11 +327,10 @@ def fillTreeView(inputDataJson, treeView):
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
basepath=os.path.realpath(__file__)
basedir=os.path.dirname(basepath)
basedir=os.path.dirname(os.path.realpath(__file__))
checkIfRoot()
chooseFirewall()
mountStick()
#mountStick()
window = Main()
window.setWindowTitle("Linux Install Party Software Installer")
with open(basedir+'/../offline_repo.json', 'r') as inputfile:
......
......@@ -418,7 +418,7 @@ create_doc()
USER_HOME=$(getent passwd "${SUDO_USER:-$USER}" | cut -d ':' -f6)
cp "${WORKING_DIR}/DOCUMENTATION.gen.pdf" "${USER_HOME}/Deine-LIP-Dokumentation.pdf"
RC=$?
pressenter "Dokummentation der von dir installierten Paktete wurde in deinem Benutzerverzeichnis ($HOME) als 'Deine-LIP-Dokumentation.pdf' abegelegt."
pressenter "Eine Dokumentation der von dir installierten Paktete wurde in deinem Benutzerverzeichnis ($HOME) als 'Deine-LIP-Dokumentation.pdf' abegelegt."
return $RC
}
......
......@@ -11,19 +11,20 @@ else
shift
fi
if [ ! -f "$DOCUDIR/HEADER.tex" ]; then #HEADER muss ex. sonst kommt auf keinen Fall was sinnvolles bei rum
echo "Leider ist keine Dokumentation auf dem LIP-Stick vorhanden..."
exit 0 #linuxparty.sh soll auch ohne Doku Verzeichnis laufen
fi
if [ $# -eq 0 ]
then
echo "No packages supplied"
exit 1
else
PACKAGELIST=$@
PACKAGELIST="$@ FOOTER"
echo $PACKAGELIST
fi
if [ ! -f "$DOCUDIR/HEADER.tex" ]; then #HEADER muss ex. sonst kommt auf keinen Fall was sinnvolles bei rum
echo "Leider ist keine Dokumentation auf dem LIP-Stick vorhanden..."
exit 0 #linuxparty.sh soll auch ohne Doku Verzeichnis laufen
fi
WORKING_DIR=$(mktemp -d)
cp -a "$DOCUDIR/." "$WORKING_DIR"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment