diff --git a/debian/control b/debian/control index 4cf2a3d8..a4477641 100644 --- a/debian/control +++ b/debian/control @@ -29,10 +29,29 @@ Description: an application to copy Debian Live to other storage media This is the version for the Lernstick exam environment distribution. Package: dlcopy-common -Architecture: all +Architecture: any +Multi-Arch: allowed Replaces: dlcopy (<< 201403091913) Breaks: dlcopy (<< 201403091913) -Depends: auto-gdk-scale, java8-runtime, squashfs-tools, cpio, xorriso, syslinux, extlinux, syslinux-common, dbus, libdbus-java, libmatthew-debug-java, libunixsocket-java, parted, policykit-1, exfatprogs, fatattr, isolinux, btrfs-progs +Depends: + auto-gdk-scale, + java8-runtime, + squashfs-tools, + cpio, + xorriso, + syslinux [amd64], + extlinux [amd64], + syslinux-common [amd64], + dbus, + libdbus-java, + libmatthew-debug-java, + libunixsocket-java, + parted, + policykit-1, + exfatprogs, + fatattr, + isolinux [amd64], + btrfs-progs Description: an application to copy Debian Live to other storage media This is a small application that copies Debian Live to other storage media like USB flash drives, USB hard drives or SD memory cards. It has hot-plug support diff --git a/src/main/java/ch/fhnw/dlcopy/BootConfigUtil.java b/src/main/java/ch/fhnw/dlcopy/BootConfigUtil.java index 9feefeed..350af4ba 100644 --- a/src/main/java/ch/fhnw/dlcopy/BootConfigUtil.java +++ b/src/main/java/ch/fhnw/dlcopy/BootConfigUtil.java @@ -90,7 +90,10 @@ public static DataPartitionMode getDataPartitionMode(String imagePath) { public static void setDataPartitionMode( DataPartitionMode destinationDataPartitionMode, String imagePath) { - setDataPartitionModeXmlBoot(destinationDataPartitionMode, imagePath); + if (!DLCopy.ARCHITECTURE.equals("aarch64")) { + setDataPartitionModeXmlBoot(destinationDataPartitionMode, imagePath); + } + setDataPartitionModeGrub(destinationDataPartitionMode, imagePath); } diff --git a/src/main/java/ch/fhnw/dlcopy/DLCopy.java b/src/main/java/ch/fhnw/dlcopy/DLCopy.java index 63f813dd..18190665 100644 --- a/src/main/java/ch/fhnw/dlcopy/DLCopy.java +++ b/src/main/java/ch/fhnw/dlcopy/DLCopy.java @@ -100,6 +100,8 @@ public class DLCopy { "NTFS" }; + public static final String ARCHITECTURE = detectArchitecture(); + /** * the label to use for the system partition */ @@ -181,6 +183,14 @@ public static PartitionState getPartitionState( } } + /** + * returns the current architecture + * @return the architecture the program is currently running on + */ + private static String detectArchitecture() { + return System.getProperty("os.arch"); + } + /** * moves a file * @@ -450,10 +460,13 @@ public static void copyToStorageDevice(SystemSource source, copyPersistence(source, installerOrUpgrader, destinationDataPartition, dlCopyGUI); - // make storage device bootable - installerOrUpgrader.showWritingBootSector(); - makeBootable(source, device, destinationBootPartition); + if (!DLCopy.ARCHITECTURE.equals("aarch64")) { + // make storage device bootable + installerOrUpgrader.showWritingBootSector(); + makeBootable(source, device, destinationBootPartition); + } + if (!umount(destinationBootPartition, dlCopyGUI)) { String errorMessage = "could not umount destination boot partition"; throw new IOException(errorMessage); @@ -1312,7 +1325,6 @@ private static void createPartitions(StorageDevice storageDevice, mkpart(partedCommandList, "0%", efiBorder); mkpart(partedCommandList, efiBorder, "100%"); setFlag(partedCommandList, "1", "boot", "on"); - setFlag(partedCommandList, "1", "lba", "on"); break; case PERSISTENCE: @@ -1324,7 +1336,6 @@ private static void createPartitions(StorageDevice storageDevice, mkpart(partedCommandList, efiBorder, persistenceBorder); mkpart(partedCommandList, persistenceBorder, "100%"); setFlag(partedCommandList, "1", "boot", "on"); - setFlag(partedCommandList, "1", "lba", "on"); break; case EXCHANGE: @@ -1337,8 +1348,6 @@ private static void createPartitions(StorageDevice storageDevice, mkpart(partedCommandList, efiBorder, persistenceBorder); mkpart(partedCommandList, persistenceBorder, "100%"); setFlag(partedCommandList, "1", "boot", "on"); - setFlag(partedCommandList, "1", "lba", "on"); - } else { // first two partitions: efi, exchange efiBorder = EFI_PARTITION_SIZE + "MiB"; @@ -1359,8 +1368,6 @@ private static void createPartitions(StorageDevice storageDevice, secondBorder, persistenceBorder); mkpart(partedCommandList, persistenceBorder, "100%"); } - setFlag(partedCommandList, "1", "lba", "on"); - setFlag(partedCommandList, "2", "lba", "on"); } break; @@ -1835,14 +1842,23 @@ public static void formatExchangePartition(String device, * returns the major Debian version * * @return the major Debian version - * @throws IOException if reading or parsing /etc/debian_version fails + * @throws IOException if reading or parsing /etc/os-release fails */ public static int getMajorDebianVersion() throws IOException { - String debianVersionPath = "/etc/debian_version"; + String debianVersionPath = "/etc/os-release"; + String versionIDPrefix = "VERSION_ID="; List debianVersionFile = LernstickFileTools.readFile( new File(debianVersionPath)); - String versionString = debianVersionFile.get(0); + + String versionString = ""; + for (String line: debianVersionFile) { + if (line.startsWith(versionIDPrefix)) { + // Strip prefix and quotation + versionString = line.substring(versionIDPrefix.length() + 1 , line.length() - 1); + break; + } + } // first try pattern . Pattern versionPattern = Pattern.compile("(\\p{Digit}*)\\..*"); @@ -1864,11 +1880,8 @@ public static int getMajorDebianVersion() throws IOException { return majorDebianVersion; } - // maybe a testing version with codenames? - if (versionString.startsWith("bullseye")) { - return 11; - } - + LOGGER.log(Level.WARNING, "Could not extract Debian version from: {0}", + versionString); throw new IOException("could not parse " + debianVersionPath); } @@ -2212,6 +2225,7 @@ private static StorageDevice getStorageDevice( String busName; Boolean isDrive = null; Boolean isLoop = null; + Boolean isNVMeNamespace = null; long size; String deviceFile; if (DbusTools.DBUS_VERSION == DbusTools.DbusVersion.V1) { @@ -2231,6 +2245,7 @@ private static StorageDevice getStorageDevice( List interfaceNames = DbusTools.getInterfaceNames(path); isDrive = !interfaceNames.contains(prefix + "Partition"); isLoop = interfaceNames.contains(prefix + "Loop"); + isNVMeNamespace = interfaceNames.contains(prefix + "NVMe.Namespace"); } catch (IOException | SAXException | ParserConfigurationException ex) { LOGGER.log(Level.SEVERE, "", ex); @@ -2245,7 +2260,7 @@ private static StorageDevice getStorageDevice( // early return for non-drives // (partitions, loop devices, empty optical drives, ...) - if ((!isDrive) || isLoop || (size <= 0)) { + if ((!isDrive) || isLoop || (size <= 0) || isNVMeNamespace) { logPath(path, isDrive, isLoop, size, deviceFile, false/*accepted*/); return null; } diff --git a/src/main/java/ch/fhnw/dlcopy/DebianLiveVersion.java b/src/main/java/ch/fhnw/dlcopy/DebianLiveVersion.java index 47b6e02a..8eac7ac7 100644 --- a/src/main/java/ch/fhnw/dlcopy/DebianLiveVersion.java +++ b/src/main/java/ch/fhnw/dlcopy/DebianLiveVersion.java @@ -54,13 +54,14 @@ public String getMbrFilePath() { /** * tries to detect the running Debian Live version * + * @param architecture the system runs on * @return the detected Debian Live version */ - public static DebianLiveVersion getRunningVersion() { + public static DebianLiveVersion getRunningVersion(String architecture) { for (DebianLiveVersion version : values()) { File liveDir = new File(version.liveSystemPath); File mbrFile = new File(version.mbrFilePath); - if (liveDir.exists() && mbrFile.exists()) { + if (liveDir.exists() && (architecture.equals("aarch64") || mbrFile.exists())) { return version; } } diff --git a/src/main/java/ch/fhnw/dlcopy/RunningSystemSource.java b/src/main/java/ch/fhnw/dlcopy/RunningSystemSource.java index 9f9a8e16..1b75bec8 100644 --- a/src/main/java/ch/fhnw/dlcopy/RunningSystemSource.java +++ b/src/main/java/ch/fhnw/dlcopy/RunningSystemSource.java @@ -45,7 +45,7 @@ public final class RunningSystemSource extends SystemSource { public RunningSystemSource(ProcessExecutor processExecutor) throws DBusException, IOException { this.processExecutor = processExecutor; - runningVersion = DebianLiveVersion.getRunningVersion(); + runningVersion = DebianLiveVersion.getRunningVersion(DLCopy.ARCHITECTURE); if (runningVersion == null) { throw new IllegalArgumentException( "Unable to detect running system version");