Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/ch/fhnw/dlcopy/BootConfigUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
51 changes: 33 additions & 18 deletions src/main/java/ch/fhnw/dlcopy/DLCopy.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public class DLCopy {
"NTFS"
};

public static final String ARCHITECTURE = detectArchitecture();

/**
* the label to use for the system partition
*/
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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";
Expand All @@ -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;

Expand Down Expand Up @@ -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<String> 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 <major>.<minor>
Pattern versionPattern = Pattern.compile("(\\p{Digit}*)\\..*");
Expand All @@ -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);
}

Expand Down Expand Up @@ -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) {
Expand All @@ -2231,6 +2245,7 @@ private static StorageDevice getStorageDevice(
List<String> 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);
Expand All @@ -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;
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/ch/fhnw/dlcopy/DebianLiveVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ch/fhnw/dlcopy/RunningSystemSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Loading