Skip to content
Snippets Groups Projects
Commit 5459179f authored by Peter Senna Tschudin's avatar Peter Senna Tschudin
Browse files

Improve text messages


This patch remove debug messages, add informative messages, and improve
existing messages for a better usability.

Signed-off-by: default avatarPeter Senna Tschudin <peter.senna@collabora.com>
parent 6007ae6d
No related branches found
No related tags found
No related merge requests found
......@@ -29,7 +29,9 @@ PERSISTENT_ETC_PREFIX = "/home"
def _run(cmd):
""" Print the command and run it"""
print("\nRunning: " + ' '.join(cmd))
# Useful to debug calls to external command line tools
#print("\nRunning: " + ' '.join(cmd))
return subprocess.run(cmd, stdout=subprocess.PIPE)
class ConfigurationAlreadyPersistent(Exception):
......@@ -71,11 +73,13 @@ class Disk:
_run(command)
# Copy contents of /home to MOUNT_POINT
print("Will copy contents of /home to persistent storage...")
command = ["sudo", "cp", "-axv", "/home/.", MOUNT_POINT]
result = _run(command)
print(result.stdout.decode())
# Copy /opt to MOUNT_POINT/opt
print("Will copy contents of /opt to persistent storage...")
command = ["sudo", "cp", "-axv", "/opt", MOUNT_POINT]
result = _run(command)
print(result.stdout.decode())
......@@ -83,6 +87,7 @@ class Disk:
def _format(self):
"""Format the partition using ext4"""
print("Will format the persistent storage partition...")
command = ["sudo", "mkfs.btrfs", "-f", "-L", DISK_LABEL, self.partpath]
result = _run(command)
print(result.stdout.decode())
......@@ -99,10 +104,10 @@ class Disk:
def _part(self):
"""Create a single Linux partition using all disk"""
print("Will partition the persistent storage disk...")
# ,,L means start at 0, use all disk, Linux partition
command = "echo ',,L' | sudo sfdisk --label gpt " + self.diskpath
print("Running: " + command)
subprocess.check_output(command, shell=True)
# Give the kernel a moment to update the partition table
......@@ -123,6 +128,8 @@ class Disk:
if not self.is_empty:
raise Exception("Cannot initialize a disk that is not empty")
print("Initializing the persistent disk...")
self._part()
self._format()
self._mount()
......@@ -289,6 +296,8 @@ def prepare_opt():
def configure_sdk():
"""Configure the SDK to use an already initialized disk"""
print("Configuring the SDK to use the persistent storage...")
old_home_uuid = update_fstab()
systemd_mount_files(old_home_uuid)
prepare_opt()
......@@ -326,10 +335,10 @@ def check_configuration_file(conf_file):
if conf_file_link.startswith("/sys") or \
conf_file_link.startswith("/proc") or \
conf_file_link.startswith("/run"):
print("""{} was a link to {}. Make sure it is ok to replace it by a regular and static
file.""".format(conf_file_abspath, conf_file_link))
print("{} was a link to {}. ".format(conf_file_abspath, conf_file_link) +\
"Make sure it is ok to replace it by a static file.")
else:
print("Original configuration file was a link to " + conf_file_link)
print("{} was a link to {}".format(conf_file_abspath, conf_file_link))
return conf_file_abspath
......@@ -365,6 +374,9 @@ def conf_to_persistent(conf_file):
command = ["sudo", "ln", "-sf", conf_file_persistent_path, conf_file_abspath]
_run(command)
print("Configuration file moved to persistent storage. From now on, " +\
"changes made to {} will be saved on the persistent storage.".format(conf_file_abspath))
def persistent_to_conf(persistent_conf_file):
"""Uses a persistent configuration file that already exists"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment