Last active
March 7, 2021 15:48
-
-
Save Sebastian-Roth/0f705698549a66dfe31092fd86b4d1d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- fos/Buildroot/board/FOG/FOS/rootfs_overlay/bin/fog.upload 2020-09-25 19:06:30.170710100 +0200 | |
+++ mnt/bin/fog.upload 2021-03-07 14:05:20.000000000 +0100 | |
@@ -138,11 +138,28 @@ | |
removePageFile "$part" | |
shrinkPartition "$part" "$imagePath/d1.original.fstypes" "$fixed_size_partitions" | |
done | |
+ local hasgpt=0 | |
+ hasGPT "$hd" | |
+ if [[ $hasgpt -eq 1 ]]; then | |
+ echo " * Moving Partitions on disk $hd" | |
+ debugPause | |
+ saveSfdiskPartitions "$hd" "$imagePath/d1.shrunken.partitions" | |
+ prevPart="" | |
+ for part in $parts; do | |
+ movePartition "$part" "$prevPart" | |
+ prevPart="$part" | |
+ done | |
+ fi | |
echo " * Saving shrunken partition table" | |
debugPause | |
sfdiskminimumpartitionfilename="" | |
sfdiskMinimumPartitionFileName "$imagePath" 1 | |
savePartitionTablesAndBootLoaders "$hd" 1 "$imagePath" "$osid" "$imgPartitionType" "$sfdiskminimumpartitionfilename" | |
+ if [[ $hasgpt -eq 1 ]]; then | |
+ echo " * Moving Partitions back on disk $hd" | |
+ debugPause | |
+ applySfdiskPartitions "$hd" "$imagePath/d1.shrunken.partitions" | |
+ fi | |
echo " * Processing Hard Disk: $hd" | |
for part in $parts; do | |
savePartition "$part" 1 "$imagePath" "$imgPartitionType" | |
--- fos/Buildroot/board/FOG/FOS/rootfs_overlay/usr/share/fog/lib/funcs.sh 2020-11-12 12:18:25.644950511 +0100 | |
+++ mnt/usr/share/fog/lib/funcs.sh 2021-03-07 14:26:43.000000000 +0100 | |
@@ -424,6 +424,41 @@ | |
esac | |
debugPause | |
} | |
+# Moves partitions if possible for upload (resizable images only) | |
+# | |
+# $1 is the partition | |
+# $2 is the previous partition | |
+movePartition() { | |
+ local part="$1" | |
+ local prevPart="$2" | |
+ [[ -z $part ]] && handleError "No partition passed (${FUNCNAME[0]})\n Args Passed: $*" | |
+ # Skip if we don't know about the previous partition, e.g. call on the very first partition | |
+ [[ -z $prevPart ]] && return | |
+ local disk="" | |
+ getDiskFromPartition "$part" | |
+ local tmp_file1="/tmp/move1.$$" | |
+ local tmp_file2="/tmp/move2.$$" | |
+ rm -f /tmp/move{1,2}.* | |
+ saveSfdiskPartitions "$disk" "$tmp_file1" | |
+ prevPartStart=$(grep "$prevPart" $tmp_file1 | cut -d',' -f1 | awk -F'=' '{print $2}' | tr -d ' ') | |
+ prevPartSize=$(grep "$prevPart" $tmp_file1 | cut -d',' -f2 | awk -F'=' '{print $2}' | tr -d ' ') | |
+ newStart=$(calculate "${prevPartStart}+${prevPartSize}") | |
+ currPartStart=$(grep "$part" $tmp_file1 | cut -d',' -f1 | awk -F'=' '{print $2}' | tr -d ' ') | |
+ if [[ $currPartStart -gt $newStart ]]; then | |
+ echo " * Moving $part forward to close gap between end of $prevPart and start of $part." | |
+ debugPause | |
+ processSfdisk "$tmp_file1" move "$part" "$newStart" > "$tmp_file2" | |
+ if [[ $ismajordebug -gt 0 ]]; then | |
+ majorDebugEcho "Partition table *before* moving $part:" | |
+ cat $tmp_file1 | |
+ majorDebugPause | |
+ majorDebugEcho "Partition table *after* before moving $part - will be applied when you hit ENTER:" | |
+ cat $tmp_file2 | |
+ majorDebugPause | |
+ applySfdiskPartitions "$disk" "$tmp_file2" | |
+ fi | |
+ fi | |
+} | |
# Shrinks partitions for upload (resizable images only) | |
# | |
# $1 is the partition | |
--- fos/Buildroot/board/FOG/FOS/rootfs_overlay/usr/share/fog/lib/procsfdisk.awk 2020-09-06 07:57:59.000000000 +0200 | |
+++ mnt/usr/share/fog/lib/procsfdisk.awk 2021-03-07 12:54:26.000000000 +0100 | |
@@ -348,7 +348,7 @@ | |
continue; | |
} | |
# Ensure start postition is aligned properly. | |
- new_start = int(sizePos) / int(SECTOR_SIZE); | |
+ new_start = int(sizePos) + int(SECTOR_SIZE); | |
new_start -= (new_start % int(SECTOR_SIZE)); | |
# If the new_start is less than the MIN_START | |
# ensure the new_start is equal to the min start point. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment