Merge branch 'improve-unsquash-errors'
This commit is contained in:
commit
3e4f429f35
@ -2,6 +2,10 @@
|
|||||||
#
|
#
|
||||||
# Fetch the Transifex translations for Calamares and incorporate them
|
# Fetch the Transifex translations for Calamares and incorporate them
|
||||||
# into the source tree, adding commits of the different files.
|
# into the source tree, adding commits of the different files.
|
||||||
|
#
|
||||||
|
# Run this (occasionally) at the top-level directory to get
|
||||||
|
# new translations. See also CMakeLists.txt and ci/txstats.py
|
||||||
|
# for update instructions.
|
||||||
|
|
||||||
### INITIAL SETUP
|
### INITIAL SETUP
|
||||||
#
|
#
|
||||||
|
10
ci/txpush.sh
10
ci/txpush.sh
@ -1,7 +1,13 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Fetch the Transifex translations for Calamares and incorporate them
|
# Extract translations from Calamares source and send them
|
||||||
# into the source tree, adding commits of the different files.
|
# to Transifex.
|
||||||
|
#
|
||||||
|
# Run this at the top-level.
|
||||||
|
#
|
||||||
|
# Use the --no-tx option to do the extraction, but not the
|
||||||
|
# pushing-to-Transifex part. This can be useful to check for
|
||||||
|
# new strings or when testing the tools themselves.
|
||||||
|
|
||||||
### INITIAL SETUP
|
### INITIAL SETUP
|
||||||
#
|
#
|
||||||
|
55
src/modules/testpythonrun.sh
Normal file
55
src/modules/testpythonrun.sh
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
### Command-line validation
|
||||||
|
#
|
||||||
|
#
|
||||||
|
SRCDIR=$( dirname "$0" )
|
||||||
|
test -d "$SRCDIR" || { echo "! Can't find source directory." ; exit 1 ; }
|
||||||
|
|
||||||
|
MODULE="$1"
|
||||||
|
test -n "$MODULE" || { echo "! Usage: $0 <module>" ; exit 1 ; }
|
||||||
|
|
||||||
|
### Run-time validation
|
||||||
|
#
|
||||||
|
# .. switch SRCDIR to the module that has been found
|
||||||
|
BINDIR="$SRCDIR" # Keep original SRCDIR
|
||||||
|
SRCDIR="$SRCDIR/$MODULE"
|
||||||
|
XSRCDIR="src/modules/$MODULE" # In builddir
|
||||||
|
TESTDIR="$SRCDIR/tests"
|
||||||
|
|
||||||
|
test -x "$BINDIR/testmodule.py" || { echo "! No support script $BINDIR/testmodule.py" ; exit 1 ; }
|
||||||
|
test -d "$SRCDIR" || { echo "! Source $SRCDIR is not a directory." ; exit 1 ; }
|
||||||
|
test -f "$TESTDIR/1.global" || { echo "! Source $SRCDIR has no tests." ; exit 1 ; }
|
||||||
|
|
||||||
|
test -f "libcalamares.so" || { echo "! Run the tests from the build-directory." ; exit 1 ; }
|
||||||
|
test -d "$XSRCDIR" || { echo "! No module directory $XSRCDIR in build-dir." ; exit 1 ; }
|
||||||
|
|
||||||
|
### Python setup
|
||||||
|
#
|
||||||
|
#
|
||||||
|
export PYTHONPATH=".:$PYTHONPATH"
|
||||||
|
PYTHON=$( which python3 2> /dev/null )
|
||||||
|
if test -z "$PYTHON" ; then
|
||||||
|
PYTHON=$( which python 2> /dev/null )
|
||||||
|
fi
|
||||||
|
test -x "$PYTHON" || { echo "! No suitable Python executable found." ; exit 1 ; }
|
||||||
|
|
||||||
|
### Test-execution
|
||||||
|
#
|
||||||
|
#
|
||||||
|
C=0
|
||||||
|
while true ; do
|
||||||
|
# Might use shell arithmetic, but need other shebang then
|
||||||
|
C=$( expr "$C" + 1 )
|
||||||
|
|
||||||
|
G_CFG="$TESTDIR/$C.global"
|
||||||
|
J_CFG="$TESTDIR/$C.job"
|
||||||
|
|
||||||
|
test -f "$G_CFG" || break
|
||||||
|
if test -f "$J_CFG" ; then
|
||||||
|
$PYTHON "$BINDIR/testmodule.py" "$XSRCDIR" "$G_CFG" "$J_CFG"
|
||||||
|
else
|
||||||
|
$PYTHON "$BINDIR/testmodule.py" "$XSRCDIR" "$G_CFG"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
@ -30,6 +30,15 @@ import tempfile
|
|||||||
|
|
||||||
from libcalamares import *
|
from libcalamares import *
|
||||||
|
|
||||||
|
import gettext
|
||||||
|
_ = gettext.translation("calamares-python",
|
||||||
|
localedir=utils.gettext_path(),
|
||||||
|
languages=utils.gettext_languages(),
|
||||||
|
fallback=True).gettext
|
||||||
|
|
||||||
|
def pretty_name():
|
||||||
|
return _("Installing filesystems.")
|
||||||
|
|
||||||
|
|
||||||
class UnpackEntry:
|
class UnpackEntry:
|
||||||
"""
|
"""
|
||||||
@ -61,6 +70,8 @@ def list_excludes(destination):
|
|||||||
"""
|
"""
|
||||||
lst = []
|
lst = []
|
||||||
extra_mounts = globalstorage.value("extraMounts")
|
extra_mounts = globalstorage.value("extraMounts")
|
||||||
|
if extra_mounts is None:
|
||||||
|
extra_mounts = []
|
||||||
|
|
||||||
for extra_mount in extra_mounts:
|
for extra_mount in extra_mounts:
|
||||||
mount_point = extra_mount["mountPoint"]
|
mount_point = extra_mount["mountPoint"]
|
||||||
@ -138,7 +149,8 @@ def file_copy(source, dest, progress_cb):
|
|||||||
# https://bugzilla.redhat.com/show_bug.cgi?id=868755#c50
|
# https://bugzilla.redhat.com/show_bug.cgi?id=868755#c50
|
||||||
# for the same issue in Anaconda, which uses a similar workaround.
|
# for the same issue in Anaconda, which uses a similar workaround.
|
||||||
if process.returncode != 0 and process.returncode != 23:
|
if process.returncode != 0 and process.returncode != 23:
|
||||||
return "rsync failed with error code {}.".format(process.returncode)
|
utils.warn("rsync failed with error code {}.".format(process.returncode))
|
||||||
|
return _("rsync failed with error code {}.").format(process.returncode)
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -192,11 +204,10 @@ class UnpackOperation:
|
|||||||
|
|
||||||
if entry.sourcefs == "squashfs":
|
if entry.sourcefs == "squashfs":
|
||||||
if shutil.which("unsquashfs") is None:
|
if shutil.which("unsquashfs") is None:
|
||||||
msg = ("Failed to find unsquashfs, make sure you have "
|
utils.warning("Failed to find unsquashfs")
|
||||||
"the squashfs-tools package installed")
|
|
||||||
print(msg)
|
return (_("Failed to unpack image \"{}\"").format(entry.source),
|
||||||
return ("Failed to unpack image",
|
_("Failed to find unsquashfs, make sure you have the squashfs-tools package installed"))
|
||||||
msg)
|
|
||||||
|
|
||||||
fslist = subprocess.check_output(
|
fslist = subprocess.check_output(
|
||||||
["unsquashfs", "-l", entry.source]
|
["unsquashfs", "-l", entry.source]
|
||||||
@ -213,7 +224,7 @@ class UnpackOperation:
|
|||||||
error_msg = self.unpack_image(entry, imgmountdir)
|
error_msg = self.unpack_image(entry, imgmountdir)
|
||||||
|
|
||||||
if error_msg:
|
if error_msg:
|
||||||
return ("Failed to unpack image {}".format(entry.source),
|
return (_("Failed to unpack image \"{}\"").format(entry.source),
|
||||||
error_msg)
|
error_msg)
|
||||||
|
|
||||||
return None
|
return None
|
||||||
@ -261,55 +272,66 @@ class UnpackOperation:
|
|||||||
subprocess.check_call(["umount", "-l", imgmountdir])
|
subprocess.check_call(["umount", "-l", imgmountdir])
|
||||||
|
|
||||||
|
|
||||||
|
def get_supported_filesystems():
|
||||||
|
"""
|
||||||
|
Reads /proc/filesystems (the list of supported filesystems
|
||||||
|
for the current kernel) and returns a list of (names of)
|
||||||
|
those filesystems.
|
||||||
|
"""
|
||||||
|
PATH_PROCFS = '/proc/filesystems'
|
||||||
|
|
||||||
|
if os.path.isfile(PATH_PROCFS) and os.access(PATH_PROCFS, os.R_OK):
|
||||||
|
with open(PATH_PROCFS, 'r') as procfile:
|
||||||
|
filesystems = procfile.read()
|
||||||
|
filesystems = filesystems.replace(
|
||||||
|
"nodev", "").replace("\t", "").splitlines()
|
||||||
|
return filesystems
|
||||||
|
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
"""
|
"""
|
||||||
Unsquash filesystem.
|
Unsquash filesystem.
|
||||||
"""
|
"""
|
||||||
PATH_PROCFS = '/proc/filesystems'
|
|
||||||
|
|
||||||
root_mount_point = globalstorage.value("rootMountPoint")
|
root_mount_point = globalstorage.value("rootMountPoint")
|
||||||
|
|
||||||
if not root_mount_point:
|
if not root_mount_point:
|
||||||
return ("No mount point for root partition in globalstorage",
|
utils.warning("No mount point for root partition")
|
||||||
"globalstorage does not contain a \"rootMountPoint\" key, "
|
return (_("No mount point for root partition"),
|
||||||
"doing nothing")
|
_("globalstorage does not contain a \"rootMountPoint\" key, "
|
||||||
|
"doing nothing"))
|
||||||
|
|
||||||
if not os.path.exists(root_mount_point):
|
if not os.path.exists(root_mount_point):
|
||||||
return ("Bad mount point for root partition in globalstorage",
|
utils.warning("Bad root mount point \"{}\"".format(root_mount_point))
|
||||||
"globalstorage[\"rootMountPoint\"] is \"{}\", which does not "
|
return (_("Bad mount point for root partition"),
|
||||||
"exist, doing nothing".format(root_mount_point))
|
_("rootMountPoint is \"{}\", which does not "
|
||||||
|
"exist, doing nothing").format(root_mount_point))
|
||||||
|
|
||||||
|
supported_filesystems = get_supported_filesystems()
|
||||||
|
|
||||||
unpack = list()
|
unpack = list()
|
||||||
|
|
||||||
for entry in job.configuration["unpack"]:
|
for entry in job.configuration["unpack"]:
|
||||||
source = os.path.abspath(entry["source"])
|
source = os.path.abspath(entry["source"])
|
||||||
|
|
||||||
sourcefs = entry["sourcefs"]
|
sourcefs = entry["sourcefs"]
|
||||||
|
|
||||||
# Get supported filesystems
|
if sourcefs not in supported_filesystems:
|
||||||
fs_is_supported = False
|
utils.warning("The filesystem for \"{}\" ({}) is not supported".format(source, sourcefs))
|
||||||
|
return (_("Bad unsquash configuration"),
|
||||||
if os.path.isfile(PATH_PROCFS) and os.access(PATH_PROCFS, os.R_OK):
|
_("The filesystem for \"{}\" ({}) is not supported").format(source, sourcefs))
|
||||||
with open(PATH_PROCFS, 'r') as procfile:
|
|
||||||
filesystems = procfile.read()
|
|
||||||
filesystems = filesystems.replace(
|
|
||||||
"nodev", "").replace("\t", "").splitlines()
|
|
||||||
|
|
||||||
# Check if the source filesystem is supported
|
|
||||||
for fs in filesystems:
|
|
||||||
if fs == sourcefs:
|
|
||||||
fs_is_supported = True
|
|
||||||
|
|
||||||
if not fs_is_supported:
|
|
||||||
return "Bad filesystem", "sourcefs=\"{}\"".format(sourcefs)
|
|
||||||
|
|
||||||
destination = os.path.abspath(root_mount_point + entry["destination"])
|
destination = os.path.abspath(root_mount_point + entry["destination"])
|
||||||
|
|
||||||
if not os.path.exists(source):
|
if not os.path.exists(source):
|
||||||
return "Bad source", "source=\"{}\"".format(source)
|
utils.warning("The source filesystem \"{}\" does not exist".format(source))
|
||||||
|
return (_("Bad unsquash configuration"),
|
||||||
|
_("The source filesystem \"{}\" does not exist").format(source))
|
||||||
|
|
||||||
if not os.path.isdir(destination):
|
if not os.path.isdir(destination):
|
||||||
return "Bad destination", "destination=\"{}\"".format(destination)
|
utils.warning(("The destination \"{}\" in the target system is not a directory").format(destination))
|
||||||
|
return (_("Bad unsquash configuration"),
|
||||||
|
_("The destination \"{}\" in the target system is not a directory").format(destination))
|
||||||
|
|
||||||
unpack.append(UnpackEntry(source, sourcefs, destination))
|
unpack.append(UnpackEntry(source, sourcefs, destination))
|
||||||
|
|
||||||
|
17
src/modules/unpackfs/runtests.sh
Normal file
17
src/modules/unpackfs/runtests.sh
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
SRCDIR=$( dirname "$0" )
|
||||||
|
|
||||||
|
# For test 3
|
||||||
|
mkdir /tmp/unpackfs-test-run-rootdir3
|
||||||
|
|
||||||
|
# For test 7
|
||||||
|
mkdir /tmp/unpackfs-test-run-rootdir3/realdest
|
||||||
|
|
||||||
|
# Run tests
|
||||||
|
sh "$SRCDIR/../testpythonrun.sh" unpackfs
|
||||||
|
|
||||||
|
# Cleanup test 7
|
||||||
|
rm -rf /tmp/unpackfs-test-run-rootdir3/realdest
|
||||||
|
|
||||||
|
# Cleanup test 3
|
||||||
|
rmdir /tmp/unpackfs-test-run-rootdir3
|
2
src/modules/unpackfs/tests/1.global
Normal file
2
src/modules/unpackfs/tests/1.global
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
bogus: true
|
2
src/modules/unpackfs/tests/2.global
Normal file
2
src/modules/unpackfs/tests/2.global
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
rootMountPoint: /tmp/unpackfs-test-run-rootdir/
|
2
src/modules/unpackfs/tests/3.global
Normal file
2
src/modules/unpackfs/tests/3.global
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
rootMountPoint: /tmp/unpackfs-test-run-rootdir3/
|
2
src/modules/unpackfs/tests/3.job
Normal file
2
src/modules/unpackfs/tests/3.job
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
unpack: []
|
2
src/modules/unpackfs/tests/4.global
Normal file
2
src/modules/unpackfs/tests/4.global
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
rootMountPoint: /tmp/unpackfs-test-run-rootdir3/
|
4
src/modules/unpackfs/tests/4.job
Normal file
4
src/modules/unpackfs/tests/4.job
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
unpack:
|
||||||
|
- source: .
|
||||||
|
sourcefs: bogus
|
2
src/modules/unpackfs/tests/5.global
Normal file
2
src/modules/unpackfs/tests/5.global
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
rootMountPoint: /tmp/unpackfs-test-run-rootdir3/
|
5
src/modules/unpackfs/tests/5.job
Normal file
5
src/modules/unpackfs/tests/5.job
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
unpack:
|
||||||
|
- source: ./fakesource
|
||||||
|
sourcefs: ext4
|
||||||
|
destination: fakedest
|
2
src/modules/unpackfs/tests/6.global
Normal file
2
src/modules/unpackfs/tests/6.global
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
rootMountPoint: /tmp/unpackfs-test-run-rootdir3/
|
5
src/modules/unpackfs/tests/6.job
Normal file
5
src/modules/unpackfs/tests/6.job
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
unpack:
|
||||||
|
- source: .
|
||||||
|
sourcefs: ext4
|
||||||
|
destination: fakedest
|
2
src/modules/unpackfs/tests/7.global
Normal file
2
src/modules/unpackfs/tests/7.global
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
rootMountPoint: /tmp/unpackfs-test-run-rootdir3/
|
5
src/modules/unpackfs/tests/7.job
Normal file
5
src/modules/unpackfs/tests/7.job
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
unpack:
|
||||||
|
- source: .
|
||||||
|
sourcefs: ext4
|
||||||
|
destination: realdest
|
Loading…
Reference in New Issue
Block a user