Fix #47: Support /dev/sd* as sdcard device
* The check for valid sdcard paths has been removed (because it doesn't make sense for /dev/sd*, this might as well be a real harddrive) * New check: abort if any partition of the sdcard is mounted * Automatically detect if the partitions are called "p1", "p2" etc. or just "1", "2" etc. (/dev/sda1 vs. /dev/mmcblk0p1) * pmb.helpers.mount.ismount(): check the source (new) and the target path in /proc/mounts
This commit is contained in:
parent
1f96439a84
commit
9d4bc61545
|
@ -166,10 +166,6 @@ install_device_packages = [
|
|||
install_size_image = "835M"
|
||||
install_size_boot = "100M"
|
||||
|
||||
# fnmatch-patterns, that the sdcard patch must match. Otherwise the
|
||||
# installer will refuse to format the device.
|
||||
install_valid_sdcard_devices = ["/dev/mmcblk*", "/dev/loop*"]
|
||||
|
||||
|
||||
#
|
||||
# FLASH
|
||||
|
|
|
@ -31,6 +31,8 @@ def ismount(folder):
|
|||
words = line.split()
|
||||
if len(words) >= 2 and words[1] == folder:
|
||||
return True
|
||||
if words[0] == folder:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
|
|||
"""
|
||||
import logging
|
||||
import os
|
||||
import glob
|
||||
import pmb.helpers.mount
|
||||
import pmb.install.losetup
|
||||
import pmb.helpers.cli
|
||||
|
@ -25,13 +26,6 @@ import pmb.config
|
|||
import fnmatch
|
||||
|
||||
|
||||
def sdcard_validate_path(args):
|
||||
for pattern in pmb.config.install_valid_sdcard_devices:
|
||||
if fnmatch.fnmatch(args.sdcard, pattern):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def mount_sdcard(args):
|
||||
# Sanity checks
|
||||
if args.deviceinfo["external_disk_install"] != "true":
|
||||
|
@ -40,9 +34,10 @@ def mount_sdcard(args):
|
|||
if not os.path.exists(args.sdcard):
|
||||
raise RuntimeError("The sdcard device does not exist: " +
|
||||
args.sdcard)
|
||||
if not sdcard_validate_path(args):
|
||||
raise RuntimeError("The sdcard path does not look valid. We will"
|
||||
" not attempt to format this!")
|
||||
for path in glob.glob(args.sdcard + "*"):
|
||||
if pmb.helpers.mount.ismount(path):
|
||||
raise RuntimeError(path + " is mounted! We will not attempt"
|
||||
" to format this!")
|
||||
if pmb.helpers.cli.ask(args, "EVERYTHING ON " + args.sdcard + " WILL BE"
|
||||
" ERASED! CONTINUE?") != "y":
|
||||
raise RuntimeError("Aborted.")
|
||||
|
|
|
@ -16,6 +16,7 @@ GNU General Public License for more details.
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
import os
|
||||
import logging
|
||||
import pmb.chroot
|
||||
import pmb.config
|
||||
|
@ -30,9 +31,21 @@ def partitions_mount(args):
|
|||
if not args.sdcard:
|
||||
img_path = "/home/user/rootfs/" + args.device + ".img"
|
||||
prefix = pmb.install.losetup.device_by_back_file(args, img_path)
|
||||
for suffix in ["p1", "p2"]:
|
||||
pmb.helpers.mount.bind_blockdevice(args, prefix + suffix,
|
||||
args.work + "/chroot_native/dev/install" + suffix)
|
||||
|
||||
partition_prefix = None
|
||||
for symbol in ["p", ""]:
|
||||
if os.path.exists(prefix + symbol + "1"):
|
||||
partition_prefix = symbol
|
||||
if not partition_prefix:
|
||||
raise RuntimeError("Unable to find the partition prefix,"
|
||||
" expected the first partition of " +
|
||||
prefix + " to be located at " + prefix
|
||||
+ "1 or " + prefix + "p1!")
|
||||
|
||||
for i in [1, 2]:
|
||||
source = prefix + partition_prefix + str(i)
|
||||
target = args.work + "/chroot_native/dev/installp" + str(i)
|
||||
pmb.helpers.mount.bind_blockdevice(args, source, target)
|
||||
|
||||
|
||||
def partition(args):
|
||||
|
|
Loading…
Reference in New Issue