This repository has been archived by the owner on Apr 17, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Powershell Port: Create extract.ps1, partition.ps1, and system.ps1 an…
…d fix others
- Loading branch information
1 parent
6460b2d
commit bb53b74
Showing
6 changed files
with
185 additions
and
6 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
function extractRootfs { | ||
|
||
printq "Extracting the Root Filesystem" | ||
|
||
# READ: Distro dependent step | ||
switch ($DISTRO) { | ||
"arch" { | ||
$DISTRO_ROOTFS_ABSOLUTE=(readlink -f $DISTRO_ROOTFS) | ||
sudo rm -rf /tmp/arch || true | ||
sudo mkdir /tmp/arch | ||
cd /tmp/arch # The -c option doesn't work when using the command below | ||
sudo tar xvpfz $DISTRO_ROOTFS_ABSOLUTE root.x86_64/ --strip-components=1 | ||
cd ~/linux-build | ||
} | ||
"fedora" { | ||
# Make the fedora directory | ||
# If it fails, remove the directory and try to make it again | ||
sudo rm -rf fedora &> /dev/null || true | ||
mkdir fedora | ||
sudo tar xvpf $DISTRO_ROOTFS -C fedora | ||
cp fedora/6c00560306a90bf0718a9a003defbc89a0d6441b8ec719a69416eba6a06c3218/layer.tar rootfs.tar | ||
$DISTRO_ROOTFS_ABSOLUTE=(readlink -f rootfs.tar) | ||
cd $MNT | ||
sudo tar --wildcards -xvpf "$DISTRO_ROOTFS_ABSOLUTE" "./*" | ||
cd ~/linux-build | ||
} | ||
"debian" { | ||
# Debootstrap Debian Unstable | ||
sudo debootstrap unstable $MNT http://deb.debian.org/debian/ | ||
} | ||
Default { | ||
# Assume any other distro has all the root files in the root of the archive | ||
# Extract the rootfs to the USB Drive | ||
sudo tar xvpf $DISTRO_ROOTFS -C $MNT | ||
} | ||
} | ||
|
||
syncStorage | ||
|
||
} | ||
|
||
function extractModules { | ||
|
||
# It is crucial to have MNT defined | ||
# Otherwise, we overwrite the host systems /lib/modules | ||
checkMNT | ||
|
||
sudo mkdir -p ${MNT}/lib/modules | ||
mkdir -p modules || sudo rm -rf modules; sudo mkdir -p modules | ||
sudo tar xvpf modules.tar.xz -C modules | ||
sudo rm -rf ${MNT}/lib/modules/* | ||
sudo cp -rv modules/lib/modules/* ${MNT}/lib/modules | ||
syncStorage | ||
|
||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
# Function for partitioning the USB | ||
function partitionUSB { | ||
|
||
# It's crucial that we have MNT defined by this stage | ||
checkMNT | ||
|
||
# Format the USB with GPT | ||
# READ: https://wiki.gentoo.org/wiki/Creating_bootable_media_for_depthcharge_based_devices | ||
sudo parted -s $USB mklabel gpt | ||
syncStorage | ||
|
||
# Create a 65 Mb kernel partition | ||
# Our kernels are only ~10 Mb though | ||
sudo parted -s -a optimal $USB unit mib mkpart Kernel 1 65 | ||
|
||
# Add a root partition | ||
sudo parted -s -a optimal $USB unit mib mkpart Root 65 100% | ||
|
||
# Make depthcharge know that this is a real kernel partition | ||
sudo cgpt add -i 1 -t kernel -S 1 -T 5 -P 15 $USB | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/bin/bash | ||
|
||
# Source other files to simplify importing this script on more minimal bash scripts | ||
# (e.g. expand.sh or genimg.sh) | ||
DIR=( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | ||
source ${DIR}/functions.sh | ||
|
||
# Determine host system | ||
function whichOperatingSystem { | ||
|
||
$OS=(uname -s) | ||
|
||
# Determine operating system and distro | ||
if ( $OS == Linux ) { | ||
|
||
# Debian | ||
if (Test-Path /etc/debian_version ) { | ||
DIST="Debian" | ||
# Arch | ||
} elseif (Test-Path /etc/arch-release ) { | ||
DIST="Arch" | ||
# Fedora | ||
} elseif (Test-Path /etc/fedora-release ) { | ||
DIST="Fedora" | ||
} | ||
# Other | ||
else { | ||
printerr "This distribution is not supported, exiting!" | ||
exit | ||
} | ||
|
||
} else { | ||
printerr "$OS is not supported, exiting!" | ||
exit | ||
} | ||
|
||
} | ||
|
||
# Install dependencies based on distro | ||
function installDependencies { | ||
|
||
# NOTE: "$*" is used to call all function arguments | ||
|
||
# Identify the distro if it is undefined | ||
if ( $null -eq $DIST ) { | ||
whichOperatingSystem | ||
} | ||
|
||
echo "Installing $args" | ||
|
||
# Download dependencies based on distribution | ||
switch ($DIST) { | ||
"Debian" { | ||
sudo apt install -y "$args" | ||
} | ||
"Arch" { | ||
if (Test-Path "/usr/bin/yay") { | ||
# Install dependencies on an Arch host system | ||
foreach ($package in $args) { | ||
# Replace package names relevant to distro | ||
switch ($package) { | ||
"vboot-kernel-utils" { $package = "vboot-utils" } | ||
"cloud-guest-utils" { $package = "growpartfs" } | ||
"cgpt" { Clear-Variable package } # Included in vboot-utils | ||
Default {} | ||
} | ||
|
||
yay -S --noconfirm $package | ||
} | ||
} else { | ||
# Yay not istalled, exit | ||
printerr "Please install yay(https://aur.archlinux.org/yay.git) to continue installation, exiting!" | ||
exit | ||
} | ||
} | ||
"Fedora" { | ||
# Install dependencies on a Fedora host system | ||
foreach ($package in $args) { | ||
# Replace package names relevant to distro | ||
switch ($package) { | ||
"vboot-kernel-utils" { $package = "vboot-utils" } | ||
"cloud-guest-utils" { $package = "cloud-utils-growpart" } | ||
"cgpt" { Clear-Variable package } # Included in vboot-utils | ||
Default {} | ||
} | ||
|
||
sudo dnf install $package --assumeyes | ||
} | ||
} | ||
Default {} | ||
} | ||
} |