Compare commits
No commits in common. "6de966506399583a0caa72871af4ae929a3710a1" and "5610aa03352a3343e77b63e4fe193fcfa1e09699" have entirely different histories.
6de9665063
...
5610aa0335
27
.github/ISSUE_TEMPLATE/bug_report.md
vendored
27
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -1,27 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Please do not open bug reports if you're using Manjaro.
|
||||
ALMA does not support Manjaro. If it works then have fun, but if it doesn't then I won't fix it -->
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
22
.github/ISSUE_TEMPLATE/feature_request.md
vendored
22
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@ -1,22 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Before requesting a feature, note that ALMA isn't intended to be a generic Arch Linux installer. It's an installer focused on creating mutable live environments. In addition, avoid asking for new features which can be easily implemented using the preset system -->
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
31
.github/workflows/rust.yml
vendored
31
.github/workflows/rust.yml
vendored
@ -1,31 +0,0 @@
|
||||
name: Rust
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
profile: minimal
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
- uses: actions-rs/cargo@v1
|
||||
name: Check format
|
||||
with:
|
||||
command: fmt
|
||||
args: --all -- --check
|
||||
- uses: actions-rs/cargo@v1
|
||||
name: Run clippy
|
||||
with:
|
||||
command: clippy
|
||||
args: --all-targets --locked -- -D warnings
|
||||
- uses: actions-rs/cargo@v1
|
||||
name: Run tests
|
||||
with:
|
||||
command: test
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,2 @@
|
||||
/target
|
||||
**/*.rs.bk
|
||||
mjoUSB.img
|
||||
|
@ -1,67 +0,0 @@
|
||||
pipeline:
|
||||
build:
|
||||
image: rust
|
||||
commands:
|
||||
- apt-get update
|
||||
- apt-get install -y libdbus-1-dev --no-install-recommends
|
||||
- cargo build
|
||||
when:
|
||||
event: push
|
||||
|
||||
test:
|
||||
image: rust
|
||||
commands:
|
||||
- apt-get update
|
||||
- apt-get install -y libdbus-1-dev --no-install-recommends
|
||||
- cargo test
|
||||
when:
|
||||
event: push
|
||||
|
||||
build-release-x86_64:
|
||||
image: rust
|
||||
commands:
|
||||
- dpkg --add-architecture amd64
|
||||
- apt-get update
|
||||
- apt-get install -y crossbuild-essential-amd64 libdbus-1-dev:amd64 --no-install-recommends
|
||||
- rustup target add x86_64-unknown-linux-gnu
|
||||
- PKG_CONFIG=x86_64-linux-gnu-pkg-config CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc cargo build --release --target x86_64-unknown-linux-gnu
|
||||
- mv target/x86_64-unknown-linux-gnu/release/alma alma-x86_64
|
||||
when:
|
||||
event: tag
|
||||
|
||||
build-release-arm:
|
||||
image: rust
|
||||
commands:
|
||||
- dpkg --add-architecture armel
|
||||
- apt-get update
|
||||
- apt-get install -y crossbuild-essential-armel libdbus-1-dev:armel --no-install-recommends
|
||||
- rustup target add arm-unknown-linux-gnueabi
|
||||
- PKG_CONFIG=arm-linux-gnueabi-pkg-config CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_LINKER=arm-linux-gnueabi-gcc cargo build --release --target arm-unknown-linux-gnueabi
|
||||
- mv target/arm-unknown-linux-gnueabi/release/alma alma-arm
|
||||
when:
|
||||
event: tag
|
||||
|
||||
build-release-aarch64:
|
||||
image: rust
|
||||
commands:
|
||||
- dpkg --add-architecture arm64
|
||||
- apt-get update
|
||||
- apt-get install -y crossbuild-essential-arm64 libdbus-1-dev:arm64 --no-install-recommends
|
||||
- rustup target add aarch64-unknown-linux-gnu
|
||||
- PKG_CONFIG=aarch64-linux-gnu-pkg-config CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc cargo build --release --target aarch64-unknown-linux-gnu
|
||||
- mv target/aarch64-unknown-linux-gnu/release/alma alma-aarch64
|
||||
when:
|
||||
event: tag
|
||||
|
||||
publish:
|
||||
image: plugins/gitea-release
|
||||
settings:
|
||||
api_key:
|
||||
from_secret: release_token
|
||||
base_url: https://git.spaeth.biz/
|
||||
files:
|
||||
- alma-x86_64
|
||||
- alma-aarch64
|
||||
- alma-arm
|
||||
when:
|
||||
event: tag
|
850
Cargo.lock
generated
850
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
22
Cargo.toml
22
Cargo.toml
@ -1,20 +1,20 @@
|
||||
[package]
|
||||
name = "alma"
|
||||
version = "0.11.0"
|
||||
authors = ["Roey Darwish Dror, PurpleCow"]
|
||||
edition = "2021"
|
||||
version = "0.10.0"
|
||||
authors = ["Roey Darwish Dror"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
which = "4.4"
|
||||
which = "4"
|
||||
log = "0.4"
|
||||
structopt = "0.3"
|
||||
tempfile = "3"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
toml = "0.7"
|
||||
byte-unit = "4.0"
|
||||
nix = "0.26"
|
||||
env_logger = "0.10"
|
||||
pretty_env_logger = "0.5"
|
||||
dialoguer = "0.10"
|
||||
console = "0.15"
|
||||
toml = "0.5"
|
||||
byte-unit = "3"
|
||||
nix = "0.17"
|
||||
env_logger = "0.7"
|
||||
pretty_env_logger = "0.4"
|
||||
dialoguer = "0.6"
|
||||
console = "0.11"
|
||||
anyhow = "1"
|
||||
|
123
README.md
123
README.md
@ -13,50 +13,9 @@ Upgrading your packages is as easy as running `pacman -Syu` (or [Topgrade](https
|
||||
booted. This tool also provides an easy chroot command, so you can keep your live environment up to
|
||||
date without having to boot it. Encrypting the root partition is as easy as providing the `-e` flag
|
||||
|
||||
---
|
||||
###### Index
|
||||
|
||||
- [ALMA - Arch Linux Mobile Appliance](#alma---arch-linux-mobile-appliance)
|
||||
- [Index](#index)
|
||||
- [Installation](#installation)
|
||||
- [Using Arch Linux derivatives](#using-arch-linux-derivatives)
|
||||
- [Usage](#usage)
|
||||
- [Image creation on removable device](#image-creation-on-removable-device)
|
||||
- [Disk encryption](#disk-encryption)
|
||||
- [chroot](#chroot)
|
||||
- [Create raw image and boot in qemu](#create-raw-image-and-boot-in-qemu)
|
||||
- [Presets](#presets)
|
||||
- [Order of execution](#order-of-execution)
|
||||
- [Troubleshooting](#troubleshooting)
|
||||
- [mkinitcpio: /etc/mkinitcpio.d/linux.preset: No such file or directory](#mkinitcpio-etcmkinitcpiodlinuxpreset-no-such-file-or-directory)
|
||||
- [Problem opening /dev/... for reading! Error is 123.](#problem-opening-dev-for-reading-error-is-123)
|
||||
- [Similar projects](#similar-projects)
|
||||
- [Useful Resources](#useful-resources)
|
||||
---
|
||||
|
||||
## Installation
|
||||
|
||||
You can either build the project using cargo build or install the `alma-aur` package.
|
||||
|
||||
Build with cargo from source:
|
||||
``` shell
|
||||
cd src
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
Use makepkg with PKGBUILD and install package:
|
||||
``` shell
|
||||
git clone https://codeberg.org/PurpleCow4u/PKGBUILD.git
|
||||
cd PKGBUILD/alma-aur
|
||||
makepkg -si
|
||||
```
|
||||
|
||||
### Using Arch Linux derivatives
|
||||
|
||||
Using Arch Linux derivatives, such as Manjaro, isn't supported it ALMA. It may work and may not. Please do not open bugs or feature
|
||||
requests if you are not using the official Arch Linux.
|
||||
|
||||
- **current test with manjaro successful**
|
||||
You can either build the project using cargo build or install the `alma` package from AUR.
|
||||
|
||||
## Usage
|
||||
|
||||
@ -101,12 +60,6 @@ Creating a 10GiB raw image, with disk encryption:
|
||||
sudo alma create -e --image 10GiB almatest.img
|
||||
```
|
||||
|
||||
Creating a 10GiB raw image, with disk encryption, with user test (ALMA_USER), with preset xfce-manjaro:
|
||||
|
||||
``` shell
|
||||
sudo ALMA_USER=test alma create -e --image 10GiB almatest.img --presets ./presets/xfce-manjaro
|
||||
```
|
||||
|
||||
If you receive the following error:
|
||||
```
|
||||
Error setting up a loop device: losetup: cannot find an unused loop device
|
||||
@ -160,37 +113,13 @@ If a directory is provided, then all files and subdirectories in the directory a
|
||||
|
||||
```
|
||||
.
|
||||
├── aur_example.toml
|
||||
├── copy_file_example
|
||||
│ └── testfile.txt
|
||||
├── copy_file.toml
|
||||
├── kde.toml
|
||||
├── lxqt-kwin-fhdk
|
||||
│ ├── 01-xorg.toml -> ../xorg.toml
|
||||
│ ├── 02-user.toml -> ../user.toml
|
||||
│ ├── 03-lxqt-kwin-fhdk.toml -> ../lxqt-kwin-fhdk.toml
|
||||
│ └── 06-pamac.toml -> ../pamac.toml
|
||||
├── lxqt-kwin-fhdk.toml
|
||||
├── pamac.toml
|
||||
├── user.toml
|
||||
├── xfce
|
||||
│ ├── 01-xorg.toml -> ../xorg.toml
|
||||
│ ├── 02-user.toml -> ../user.toml
|
||||
│ └── 03-xfce.toml -> ../xfce.toml
|
||||
├── xfce-branding
|
||||
│ └── lightdm-gtk-greeter.conf
|
||||
├── xfce-branding.toml
|
||||
├── xfce-goodies.toml
|
||||
├── xfce-manjaro
|
||||
│ ├── 01-xorg.toml -> ../xorg.toml
|
||||
│ ├── 02-user.toml -> ../user.toml
|
||||
│ ├── 03-xfce.toml -> ../xfce.toml
|
||||
│ ├── 04-xfce-goodies.toml -> ../xfce-goodies.toml
|
||||
│ ├── 05-xfce-branding.toml -> ../xfce-branding.toml
|
||||
│ ├── 06-pamac.toml -> ../pamac.toml
|
||||
│ └── xfce-branding -> ../xfce-branding
|
||||
├── xfce.toml
|
||||
└── xorg.toml
|
||||
├── 00-add_user.toml
|
||||
├── 01-xorg
|
||||
│ ├── 00-install.toml
|
||||
│ └── 01-config.toml
|
||||
└── 02-i3
|
||||
├── 00-install.toml
|
||||
└── 01-copy_dotfiles.toml
|
||||
```
|
||||
|
||||
Example preset TOML:
|
||||
@ -202,45 +131,12 @@ set -eux
|
||||
useradd -m ${ALMA_USER}
|
||||
passwd ${ALMA_USER}
|
||||
usermod -G wheel -a ${ALMA_USER}
|
||||
echo "%wheel ALL=(ALL) ALL" > /etc/sudoers.d/wheel
|
||||
"""
|
||||
environment_variables = ["ALMA_USER"]
|
||||
```
|
||||
|
||||
Note that shared directories in the preset scripts are mounted as bind mounts, so they are *not* mounted read-only. Any changes the custom script makes to the shared directory will be carried out in the preset shared directory of the host system, so be sure to copy (not move) files from the shared directories.
|
||||
|
||||
### Order of execution
|
||||
|
||||
ALMA installs the packages and presets in the following order:
|
||||
|
||||
1. All non-AUR packages are installed
|
||||
2. If AUR packages are present in the toml files, yay (or another
|
||||
specified AUR helper) is installed
|
||||
3. All AUR packages are installed.
|
||||
4. Preset scripts are executed according to their filenames in
|
||||
alphanumeric order.
|
||||
|
||||
Note this may mean you have to workaround some package installations if
|
||||
they depend on preset scripts.
|
||||
|
||||
For example, at the moment you cannot install Rust-based AUR packages in
|
||||
the `aur_packages` array of the Preset TOMLs if you use rustup,
|
||||
since rustup needs to be given the toolchain to
|
||||
install first. This can be worked around by carrying out the AUR
|
||||
package installation inside the preset script itself in these cases.
|
||||
|
||||
## Troubleshooting
|
||||
### mkinitcpio: /etc/mkinitcpio.d/linux.preset: No such file or directory
|
||||
|
||||
Ensure you have both the `linux` and `base` packages installed. Note
|
||||
that only Arch Linux is supported, not Arch Linux derivatives such as
|
||||
Manjaro.
|
||||
|
||||
### Problem opening /dev/... for reading! Error is 123.
|
||||
|
||||
Delete all partitions on the disk first (e.g. with gparted) and try
|
||||
again.
|
||||
|
||||
## Similar projects
|
||||
|
||||
* [NomadBSD](http://nomadbsd.org/)
|
||||
@ -248,5 +144,4 @@ again.
|
||||
## Useful Resources
|
||||
|
||||
* [Arch Wiki: Installing Arch Linux on a USB key](https://wiki.archlinux.org/index.php/Install_Arch_Linux_on_a_USB_key)
|
||||
* [Github - philmmanjaro/alma](https://github.com/philmmanjaro/alma)
|
||||
* [Github - r-darwish/alma](https://github.com/r-darwish/alma)
|
||||
* [ValleyCat's Arch Linux USB guide](http://valleycat.org/linux/arch-usb.html?i=1)
|
||||
|
37
azure-pipelines.yml
Normal file
37
azure-pipelines.yml
Normal file
@ -0,0 +1,37 @@
|
||||
stages:
|
||||
- stage: Check
|
||||
jobs:
|
||||
- job: Check
|
||||
displayName: Sanity Check
|
||||
pool:
|
||||
vmImage: 'ubuntu-16.04'
|
||||
container: 'rust:latest'
|
||||
steps:
|
||||
- script: rustup component add clippy rustfmt
|
||||
displayName: Install clippy and rustfmt
|
||||
- script: cargo fmt -- --check
|
||||
displayName: Check Formatting
|
||||
- script: cargo check --all
|
||||
displayName: Check
|
||||
- script: cargo clippy
|
||||
displayName: Clippy
|
||||
|
||||
- stage: Build
|
||||
jobs:
|
||||
- job: BuildDocker
|
||||
displayName: Build Docker Image
|
||||
pool:
|
||||
vmImage: 'ubuntu-16.04'
|
||||
steps:
|
||||
- task: Docker@2
|
||||
displayName: Login to Dockerhub
|
||||
inputs:
|
||||
command: login
|
||||
containerRegistry: Dockerhub
|
||||
- task: Docker@2
|
||||
displayName: Build and Push
|
||||
inputs:
|
||||
command: buildAndPush
|
||||
repository: darwish/alma
|
||||
tags: |
|
||||
latest
|
@ -1,13 +0,0 @@
|
||||
packages = ["feathernotes", "featherpad", "firefox", "gparted", "gvfs", "udiskie", "udisks2", "konsole", "bash-completion", "dmidecode", "htop", "mc", "micro", "numlockx", "powertop", "xclip", "xsel", "firewalld", "network-manager-applet", "networkmanager-openvpn", "networkmanager-qt", "openssh", "plank", "freetype2", "noto-fonts", "ttf-dejavu", "ttf-hack", "kvantum", "breeze", "breeze-gtk", "breeze-icons", "adwaita-icon-theme", "gnome-icon-theme-extras", "gnome-themes-extra", "hicolor-icon-theme", "oxygen-icons", "oxygen-icons-svg", "xdg-desktop-portal-lxqt", "sddm", "kwin", "systemsettings", "lximage-qt", "lxqt-about", "lxqt-admin", "lxqt-archiver", "lxqt-config", "lxqt-globalkeys", "lxqt-notificationd", "lxqt-openssh-askpass", "lxqt-panel", "lxqt-policykit", "lxqt-powermanagement", "lxqt-qtplugin", "lxqt-runner", "lxqt-session", "lxqt-sudo", "pcmanfm-qt", "alsa-utils", "alsa-firmware", "pavucontrol-qt", "pipewire-alsa", "pipewire", "pipewire-v4l2", "pipewire-zeroconf", "sof-firmware", "accountsservice", "gnome-keyring", "perl-file-mimeinfo", "polkit", "python-pyxdg", "squashfs-tools", "xdg-user-dirs", "xdg-user-dirs-gtk", "xdg-utils", "zlib", "acpilight", "xorg-server", "xorg-server-common", "xorg-server-xephyr", "xorg-twm", "xorg-xinit", "xorg-xinput", "xorg-xkill", "xorg-xprop", "xsettingsd", "xsettings-client", "xscreensaver", "xf86-input-evdev","xf86-input-libinput", "xf86-video-fbdev", "xf86-video-dummy", "qterminal"]
|
||||
script = """
|
||||
set -exu
|
||||
|
||||
systemctl enable NetworkManager
|
||||
systemctl enable sddm
|
||||
systemctl enable firewalld
|
||||
git clone https://github.com/fhdk/lxqt-kwin.git
|
||||
cp -r lxqt-kwin/etc/. /etc/
|
||||
cp -r lxqt-kwin/usr/. /usr/
|
||||
cp -r lxqt-kwin/root/. /root/
|
||||
"""
|
||||
|
@ -1 +0,0 @@
|
||||
../xorg.toml
|
@ -1 +0,0 @@
|
||||
../user.toml
|
@ -1 +0,0 @@
|
||||
../lxqt-kwin-fhdk.toml
|
@ -1 +0,0 @@
|
||||
../pamac.toml
|
@ -1,4 +1,4 @@
|
||||
packages = ["manjaro-xfce-settings", "manjaro-hello", "manjaro-application-utility", "manjaro-settings-manager-notifier", "manjaro-browser-settings", "manjaro-release", "manjaro-pipewire", "manjaro-system"]
|
||||
packages = ["manjaro-xfce-settings", "manjaro-hello", "manjaro-application-utility", "manjaro-settings-manager-notifier", "manjaro-documentation-en", "manjaro-browser-settings", "manjaro-release", "manjaro-firmware", "manjaro-system"]
|
||||
script = """
|
||||
cp /shared_dirs/xfce-branding/lightdm-gtk-greeter.conf /etc/lightdm/lightdm-gtk-greeter.conf
|
||||
"""
|
||||
|
@ -1,2 +1,2 @@
|
||||
packages = ["xfce4-goodies", "xfce4-pulseaudio-plugin", "pipewire", "pipewire-jack", "pavucontrol", "mugshot", "engrampa", "catfish", "firefox", "screenfetch", "thunderbird", "network-manager-applet", "xdg-desktop-portal-gtk"]
|
||||
packages = ["xfce4-goodies", "xfce4-pulseaudio-plugin", "pulseaudio", "pavucontrol", "mugshot", "engrampa", "catfish", "firefox", "screenfetch", "thunderbird", "network-manager-applet"]
|
||||
|
||||
|
12
src/args.rs
12
src/args.rs
@ -38,12 +38,6 @@ pub struct CreateCommand {
|
||||
#[structopt(parse(from_os_str))]
|
||||
pub path: Option<PathBuf>,
|
||||
|
||||
/// Path to a pacman.conf file which will be used to pacstrap packages into the image.
|
||||
///
|
||||
/// This pacman.conf will also be copied into the resulting Arch Linux image.
|
||||
#[structopt(short = "c", long = "pacman-conf", value_name = "pacman_conf")]
|
||||
pub pacman_conf: Option<PathBuf>,
|
||||
|
||||
/// Additional packages to install
|
||||
#[structopt(short = "p", long = "extra-packages", value_name = "package")]
|
||||
pub extra_packages: Vec<String>,
|
||||
@ -52,10 +46,6 @@ pub struct CreateCommand {
|
||||
#[structopt(long = "aur-packages", value_name = "aurpackage")]
|
||||
pub aur_packages: Vec<String>,
|
||||
|
||||
/// Boot partition size in megabytes
|
||||
#[structopt(long = "boot-size")]
|
||||
pub boot_size: Option<u32>,
|
||||
|
||||
/// Enter interactive chroot before unmounting the drive
|
||||
#[structopt(short = "i", long = "interactive")]
|
||||
pub interactive: bool,
|
||||
@ -88,7 +78,7 @@ pub struct CreateCommand {
|
||||
#[structopt(long = "allow-non-removable")]
|
||||
pub allow_non_removable: bool,
|
||||
|
||||
#[structopt(long = "aur-helper", possible_values=&["paru", "yay"], default_value="yay")]
|
||||
#[structopt(long = "aur-helper", possible_values=&["yay"], default_value="yay")]
|
||||
pub aur_helper: AurHelper,
|
||||
}
|
||||
|
||||
|
24
src/aur.rs
24
src/aur.rs
@ -3,7 +3,6 @@ use std::str::FromStr;
|
||||
|
||||
pub struct AurHelper {
|
||||
pub name: String,
|
||||
pub package_name: String,
|
||||
pub install_command: Vec<String>,
|
||||
}
|
||||
|
||||
@ -12,28 +11,8 @@ impl FromStr for AurHelper {
|
||||
|
||||
fn from_str(s: &str) -> anyhow::Result<Self> {
|
||||
match s {
|
||||
"paru" => Ok(Self {
|
||||
name: String::from("paru"),
|
||||
package_name: String::from("paru-bin"),
|
||||
install_command: vec![
|
||||
String::from("paru"),
|
||||
String::from("-S"),
|
||||
String::from("--skipreview"),
|
||||
String::from("--noupgrademenu"),
|
||||
String::from("--useask"),
|
||||
String::from("--removemake"),
|
||||
String::from("--norebuild"),
|
||||
String::from("--nocleanafter"),
|
||||
String::from("--noredownload"),
|
||||
String::from("--mflags"),
|
||||
String::from(""),
|
||||
String::from("--noconfirm"),
|
||||
String::from("--batchinstall"),
|
||||
],
|
||||
}),
|
||||
"yay" => Ok(Self {
|
||||
"yay" => Ok(AurHelper {
|
||||
name: String::from("yay"),
|
||||
package_name: String::from("yay-bin"),
|
||||
install_command: vec![
|
||||
String::from("yay"),
|
||||
String::from("-S"),
|
||||
@ -44,6 +23,7 @@ impl FromStr for AurHelper {
|
||||
String::from("--useask"),
|
||||
String::from("--removemake"),
|
||||
String::from("--norebuild"),
|
||||
String::from("--noconfirm"),
|
||||
String::from("--answeredit"),
|
||||
String::from("None"),
|
||||
String::from("--answerclean"),
|
||||
|
@ -9,8 +9,8 @@ SystemMaxUse=16M
|
||||
|
||||
pub const BASE_PACKAGES: [&str; 9] = [
|
||||
"base",
|
||||
"linux61",
|
||||
"linux61-broadcom-wl",
|
||||
"linux54",
|
||||
"linux54-broadcom-wl",
|
||||
"linux-firmware",
|
||||
"grub",
|
||||
"efibootmgr",
|
||||
|
210
src/main.rs
210
src/main.rs
@ -162,14 +162,12 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
|
||||
info!("Partitioning the block device");
|
||||
debug!("{:?}", disk_path);
|
||||
|
||||
let boot_size = command.boot_size.unwrap_or(450);
|
||||
|
||||
sgdisk
|
||||
.execute()
|
||||
.args(&[
|
||||
"-Z",
|
||||
"-o",
|
||||
&format!("--new=1::+{}M", boot_size),
|
||||
"--new=1::+250M",
|
||||
"--new=2::+1M",
|
||||
"--largest-new=3",
|
||||
"--typecode=1:EF00",
|
||||
@ -188,7 +186,7 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
|
||||
let root_partition_base = storage_device.get_partition(constants::ROOT_PARTITION_INDEX)?;
|
||||
let encrypted_root = if let Some(cryptsetup) = &cryptsetup {
|
||||
info!("Encrypting the root filesystem");
|
||||
EncryptedDevice::prepare(cryptsetup, &root_partition_base)?;
|
||||
EncryptedDevice::prepare(&cryptsetup, &root_partition_base)?;
|
||||
Some(EncryptedDevice::open(
|
||||
cryptsetup,
|
||||
&root_partition_base,
|
||||
@ -227,24 +225,13 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
|
||||
|
||||
packages.extend(presets.packages);
|
||||
|
||||
let aur_pacakges = {
|
||||
let mut p = vec![String::from("shim-signed")];
|
||||
p.extend(presets.aur_packages);
|
||||
p.extend(command.aur_packages);
|
||||
p
|
||||
};
|
||||
|
||||
packages.extend(constants::AUR_DEPENDENCIES.iter().map(|s| String::from(*s)));
|
||||
|
||||
let pacman_conf_path = command
|
||||
.pacman_conf
|
||||
.unwrap_or_else(|| "/etc/pacman.conf".into());
|
||||
if !presets.aur_packages.is_empty() {
|
||||
packages.extend(constants::AUR_DEPENDENCIES.iter().map(|s| String::from(*s)));
|
||||
}
|
||||
|
||||
info!("Bootstrapping system");
|
||||
pacstrap
|
||||
.execute()
|
||||
.arg("-C")
|
||||
.arg(&pacman_conf_path)
|
||||
.arg("-c")
|
||||
.arg(mount_point.path())
|
||||
.args(packages)
|
||||
@ -252,10 +239,6 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
|
||||
.run()
|
||||
.context("Pacstrap error")?;
|
||||
|
||||
// Copy pacman.conf to the image.
|
||||
fs::copy(pacman_conf_path, mount_point.path().join("etc/pacman.conf"))
|
||||
.context("Failed copying pacman.conf")?;
|
||||
|
||||
let fstab = fix_fstab(
|
||||
&genfstab
|
||||
.execute()
|
||||
@ -274,85 +257,84 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
|
||||
.run()
|
||||
.context("Failed to delete the root password")?;
|
||||
|
||||
info!("Setting locale");
|
||||
fs::OpenOptions::new()
|
||||
.append(true)
|
||||
.write(true)
|
||||
.open(mount_point.path().join("etc/locale.gen"))
|
||||
.and_then(|mut locale_gen| locale_gen.write_all(b"en_US.UTF-8 UTF-8\n"))
|
||||
.context("Failed to create locale.gen")?;
|
||||
fs::write(
|
||||
mount_point.path().join("etc/locale.conf"),
|
||||
"LANG=en_US.UTF-8",
|
||||
)
|
||||
.context("Failed to write to locale.conf")?;
|
||||
arch_chroot
|
||||
.execute()
|
||||
.arg(mount_point.path())
|
||||
.arg("locale-gen")
|
||||
.run()
|
||||
.context("locale-gen failed")?;
|
||||
if !presets.aur_packages.is_empty() {
|
||||
arch_chroot
|
||||
.execute()
|
||||
.arg(mount_point.path())
|
||||
.args(&["useradd", "-m", "aur"])
|
||||
.run()
|
||||
.context("Failed to create temporary user to install AUR packages")?;
|
||||
|
||||
info!("Installing AUR packages");
|
||||
arch_chroot
|
||||
.execute()
|
||||
.arg(mount_point.path())
|
||||
.args(&[
|
||||
"sed",
|
||||
"-i",
|
||||
"s/# %wheel ALL=(ALL) NOPASSWD: ALL/aur ALL=(ALL) NOPASSWD: ALL/g",
|
||||
])
|
||||
.arg("/etc/sudoers")
|
||||
.run()
|
||||
.context("Failed to modify sudoers file for AUR packages")?;
|
||||
|
||||
arch_chroot
|
||||
.execute()
|
||||
.arg(mount_point.path())
|
||||
.args(&["useradd", "-m", "aur"])
|
||||
.run()
|
||||
.context("Failed to create temporary user to install AUR packages")?;
|
||||
|
||||
let aur_sudoers = mount_point.path().join("etc/sudoers.d/aur");
|
||||
fs::write(&aur_sudoers, "aur ALL=(ALL) NOPASSWD: ALL")
|
||||
.context("Failed to modify sudoers file for AUR packages")?;
|
||||
|
||||
arch_chroot
|
||||
.execute()
|
||||
.arg(mount_point.path())
|
||||
.args(&["sudo", "-u", "aur"])
|
||||
.arg("git")
|
||||
.arg("clone")
|
||||
.arg(format!(
|
||||
"https://aur.archlinux.org/{}.git",
|
||||
&command.aur_helper.package_name
|
||||
))
|
||||
.arg(format!("/home/aur/{}", &command.aur_helper.name))
|
||||
.run()
|
||||
.context("Failed to clone AUR helper package")?;
|
||||
|
||||
arch_chroot
|
||||
.execute()
|
||||
.arg(mount_point.path())
|
||||
.args(&[
|
||||
"bash",
|
||||
"-c",
|
||||
&format!(
|
||||
"cd /home/aur/{} && sudo -u aur makepkg -s -i --noconfirm",
|
||||
arch_chroot
|
||||
.execute()
|
||||
.arg(mount_point.path())
|
||||
.args(&["sudo", "-u", "aur"])
|
||||
.arg("git")
|
||||
.arg("clone")
|
||||
.arg(format!(
|
||||
"https://aur.archlinux.org/{}.git",
|
||||
&command.aur_helper.name
|
||||
),
|
||||
])
|
||||
.run()
|
||||
.context("Failed to build AUR helper")?;
|
||||
))
|
||||
.arg(format!("/home/aur/{}", &command.aur_helper.name))
|
||||
.run()
|
||||
.context("Failed to clone AUR helper package")?;
|
||||
|
||||
arch_chroot
|
||||
.execute()
|
||||
.arg(mount_point.path())
|
||||
.args(&["sudo", "-u", "aur"])
|
||||
.args(&command.aur_helper.install_command)
|
||||
.args(aur_pacakges)
|
||||
.run()
|
||||
.context("Failed to install AUR packages")?;
|
||||
arch_chroot
|
||||
.execute()
|
||||
.arg(mount_point.path())
|
||||
.args(&[
|
||||
"bash",
|
||||
"-c",
|
||||
&format!(
|
||||
"cd /home/aur/{} && sudo -u aur makepkg -s -i --noconfirm",
|
||||
&command.aur_helper.name
|
||||
),
|
||||
])
|
||||
.run()
|
||||
.context("Failed to build AUR helper")?;
|
||||
|
||||
// Clean up aur user:
|
||||
arch_chroot
|
||||
.execute()
|
||||
.arg(mount_point.path())
|
||||
.args(&["userdel", "-r", "aur"])
|
||||
.run()
|
||||
.context("Failed to delete temporary aur user")?;
|
||||
arch_chroot
|
||||
.execute()
|
||||
.arg(mount_point.path())
|
||||
.args(&["sudo", "-u", "aur"])
|
||||
.args(&command.aur_helper.install_command)
|
||||
.args(presets.aur_packages)
|
||||
.args(&command.aur_packages)
|
||||
.run()
|
||||
.context("Failed to install AUR packages")?;
|
||||
|
||||
fs::remove_file(&aur_sudoers).context("Cannot delete the AUR sudoers temporary file")?;
|
||||
// Clean up aur user:
|
||||
arch_chroot
|
||||
.execute()
|
||||
.arg(mount_point.path())
|
||||
.args(&["userdel", "-r", "aur"])
|
||||
.run()
|
||||
.context("Failed to delete temporary aur user")?;
|
||||
|
||||
arch_chroot
|
||||
.execute()
|
||||
.arg(mount_point.path())
|
||||
.args(&[
|
||||
"sed",
|
||||
"-i",
|
||||
"s/aur ALL=(ALL) NOPASSWD: ALL/# %wheel ALL=(ALL) NOPASSWD: ALL/g",
|
||||
])
|
||||
.arg("/etc/sudoers")
|
||||
.run()
|
||||
.context("Failed to undo sudoers changes")?;
|
||||
}
|
||||
if !presets.scripts.is_empty() {
|
||||
info!("Running custom scripts");
|
||||
}
|
||||
@ -405,7 +387,7 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
|
||||
),
|
||||
)
|
||||
.run()
|
||||
.with_context(|| format!("Failed running preset script:\n{}", script.script_text))?;
|
||||
.context("Failed running preset script")?;
|
||||
}
|
||||
|
||||
info!("Performing post installation tasks");
|
||||
@ -424,6 +406,25 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
|
||||
)
|
||||
.context("Failed to write to journald.conf")?;
|
||||
|
||||
info!("Setting locale");
|
||||
fs::OpenOptions::new()
|
||||
.append(true)
|
||||
.write(true)
|
||||
.open(mount_point.path().join("etc/locale.gen"))
|
||||
.and_then(|mut locale_gen| locale_gen.write_all(b"en_US.UTF-8 UTF-8\n"))
|
||||
.context("Failed to create locale.gen")?;
|
||||
fs::write(
|
||||
mount_point.path().join("etc/locale.conf"),
|
||||
"LANG=en_US.UTF-8",
|
||||
)
|
||||
.context("Failed to write to locale.conf")?;
|
||||
arch_chroot
|
||||
.execute()
|
||||
.arg(mount_point.path())
|
||||
.arg("locale-gen")
|
||||
.run()
|
||||
.context("locale-gen failed")?;
|
||||
|
||||
info!("Generating initramfs");
|
||||
fs::write(
|
||||
mount_point.path().join("etc/mkinitcpio.conf"),
|
||||
@ -433,7 +434,7 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
|
||||
arch_chroot
|
||||
.execute()
|
||||
.arg(mount_point.path())
|
||||
.args(&["mkinitcpio", "-p", "linux61"])
|
||||
.args(&["mkinitcpio", "-P"])
|
||||
.run()
|
||||
.context("Failed to run mkinitcpio - do you have the base and linux packages installed?")?;
|
||||
|
||||
@ -471,23 +472,6 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
|
||||
.arg(format!("grub-install --target=i386-pc --boot-directory /boot {} && grub-install --target=x86_64-efi --efi-directory /boot --boot-directory /boot --removable && grub-mkconfig -o /boot/grub/grub.cfg", disk_path.display()))
|
||||
.run().context("Failed to install grub")?;
|
||||
|
||||
let bootloader = mount_point.path().join("boot/EFI/BOOT/BOOTX64.efi");
|
||||
fs::rename(
|
||||
&bootloader,
|
||||
mount_point.path().join("boot/EFI/BOOT/grubx64.efi"),
|
||||
)
|
||||
.context("Cannot move out grub")?;
|
||||
fs::copy(
|
||||
mount_point.path().join("usr/share/shim-signed/mmx64.efi"),
|
||||
mount_point.path().join("boot/EFI/BOOT/mmx64.efi"),
|
||||
)
|
||||
.context("Failed copying mmx64")?;
|
||||
fs::copy(
|
||||
mount_point.path().join("usr/share/shim-signed/shimx64.efi"),
|
||||
bootloader,
|
||||
)
|
||||
.context("Failed copying shim")?;
|
||||
|
||||
debug!(
|
||||
"GRUB configuration: {}",
|
||||
fs::read_to_string(mount_point.path().join("boot/grub/grub.cfg"))
|
||||
|
@ -33,7 +33,7 @@ fn visit_dirs(dir: &Path, filevec: &mut Vec<PathBuf>) -> Result<(), io::Error> {
|
||||
impl Preset {
|
||||
fn load(path: &Path) -> anyhow::Result<Self> {
|
||||
let data = fs::read_to_string(path).with_context(|| format!("{}", path.display()))?;
|
||||
toml::from_str(&data).with_context(|| format!("{}", path.display()))
|
||||
Ok(toml::from_str(&data).with_context(|| format!("{}", path.display()))?)
|
||||
}
|
||||
|
||||
fn process(
|
||||
@ -41,7 +41,7 @@ impl Preset {
|
||||
packages: &mut HashSet<String>,
|
||||
scripts: &mut Vec<Script>,
|
||||
environment_variables: &mut HashSet<String>,
|
||||
path: &Path,
|
||||
path: &PathBuf,
|
||||
aur_packages: &mut HashSet<String>,
|
||||
) -> anyhow::Result<()> {
|
||||
if let Some(preset_packages) = &self.packages {
|
||||
@ -111,7 +111,7 @@ impl PresetsCollection {
|
||||
// Build vector of paths to files, then sort by path name
|
||||
// Recursively load directories of preset files
|
||||
let mut dir_paths: Vec<PathBuf> = Vec::new();
|
||||
visit_dirs(preset, &mut dir_paths)
|
||||
visit_dirs(&preset, &mut dir_paths)
|
||||
.with_context(|| format!("{}", preset.display()))?;
|
||||
|
||||
// Order not guaranteed so we sort
|
||||
@ -128,11 +128,11 @@ impl PresetsCollection {
|
||||
)?;
|
||||
}
|
||||
} else {
|
||||
Preset::load(preset)?.process(
|
||||
Preset::load(&preset)?.process(
|
||||
&mut packages,
|
||||
&mut scripts,
|
||||
&mut environment_variables,
|
||||
preset,
|
||||
&preset,
|
||||
&mut aur_packages,
|
||||
)?;
|
||||
}
|
||||
@ -151,8 +151,8 @@ impl PresetsCollection {
|
||||
|
||||
Ok(Self {
|
||||
packages,
|
||||
aur_packages,
|
||||
scripts,
|
||||
aur_packages,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ impl LoopDevice {
|
||||
);
|
||||
info!("Mounted {} to {}", file.display(), path.display());
|
||||
|
||||
Ok(Self { path, losetup })
|
||||
Ok(LoopDevice { path, losetup })
|
||||
}
|
||||
|
||||
pub fn path(&self) -> &Path {
|
||||
|
@ -68,7 +68,7 @@ pub fn get_storage_devices(allow_non_removable: bool) -> anyhow::Result<Vec<Devi
|
||||
.context("Could not parse block size to unsigned integer (u128)")?
|
||||
* 512,
|
||||
),
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
Ok(result)
|
||||
|
@ -21,7 +21,7 @@ impl<'a> StorageDevice<'a> {
|
||||
.context("Error querying information about the block device")?;
|
||||
let device_name = path
|
||||
.file_name()
|
||||
.and_then(std::ffi::OsStr::to_str)
|
||||
.and_then(|s| s.to_str())
|
||||
.map(String::from)
|
||||
.ok_or_else(|| anyhow!("Invalid device name: {}", path.display()))?;
|
||||
|
||||
|
@ -2,7 +2,6 @@ mod chroot;
|
||||
mod mount;
|
||||
mod qemu;
|
||||
|
||||
use anyhow::Context;
|
||||
pub use chroot::chroot;
|
||||
pub use mount::mount;
|
||||
pub use qemu::qemu;
|
||||
@ -18,9 +17,7 @@ pub struct Tool {
|
||||
|
||||
impl Tool {
|
||||
pub fn find(name: &'static str) -> anyhow::Result<Self> {
|
||||
Ok(Self {
|
||||
exec: which(name).context(format!("Cannot find {}", name))?,
|
||||
})
|
||||
Ok(Self { exec: which(name)? })
|
||||
}
|
||||
|
||||
pub fn execute(&self) -> Command {
|
||||
|
@ -20,7 +20,7 @@ pub fn mount<'a>(
|
||||
|
||||
info!("Mounting filesystems to {}", mount_path.display());
|
||||
mount_stack
|
||||
.mount(root_filesystem, mount_path.into(), None)
|
||||
.mount(&root_filesystem, mount_path.into(), None)
|
||||
.with_context(|| format!("Error mounting filesystem to {}", mount_path.display()))?;
|
||||
|
||||
let boot_point = mount_path.join("boot");
|
||||
@ -29,7 +29,7 @@ pub fn mount<'a>(
|
||||
}
|
||||
|
||||
mount_stack
|
||||
.mount(boot_filesystem, boot_point, None)
|
||||
.mount(&boot_filesystem, boot_point, None)
|
||||
.context("Error mounting the boot point")?;
|
||||
|
||||
Ok(mount_stack)
|
||||
|
Loading…
x
Reference in New Issue
Block a user