Skip to content

Commit

Permalink
Merge pull request #12 from aldochaconc/refactor-package-installations
Browse files Browse the repository at this point in the history
Refactor package installations
  • Loading branch information
aldochaconc authored Mar 8, 2024
2 parents 5358e78 + 22d1890 commit 59899de
Show file tree
Hide file tree
Showing 18 changed files with 163 additions and 324 deletions.
2 changes: 1 addition & 1 deletion archcrystal.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# Script Name: archcrystal.sh
# Version: 1.3.0
# Version: 1.3.1

set -a
BASE_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
Expand Down
11 changes: 0 additions & 11 deletions dotfiles/etc/X11/xorg.conf/10-trackpoint.rules

This file was deleted.

11 changes: 0 additions & 11 deletions dotfiles/etc/X11/xorg.conf/20-thinkpad.rules

This file was deleted.

Empty file.
5 changes: 0 additions & 5 deletions dotfiles/etc/X11/xorg.conf/81-backlight.rules

This file was deleted.

3 changes: 0 additions & 3 deletions dotfiles/etc/environment

This file was deleted.

5 changes: 0 additions & 5 deletions dotfiles/etc/udev/rules.d/99-lowbat.rules

This file was deleted.

4 changes: 0 additions & 4 deletions dotfiles/etc/udev/rules.d/backlight.rules

This file was deleted.

17 changes: 0 additions & 17 deletions dotfiles/home/crystal/.Xresources

This file was deleted.

Empty file.
Empty file.
8 changes: 0 additions & 8 deletions dotfiles/home/crystal/.xinitrc

This file was deleted.

5 changes: 0 additions & 5 deletions dotfiles/home/crystal/.zprofile

This file was deleted.

2 changes: 0 additions & 2 deletions dotfiles/home/crystal/.zshrc

This file was deleted.

110 changes: 42 additions & 68 deletions scripts/0-preinstall.sh
Original file line number Diff line number Diff line change
@@ -1,87 +1,58 @@
#!/usr/bin/env bash

echo -ne "
-------------------------------------------------------------------------
0 - Pre-Install
-------------------------------------------------------------------------
Setting up mirrors for optimal download
"
echo "Setting up installer environment"
source $BASE_DIR/setup.conf
pacman -Sy --noconfirm archlinux-keyring

iso=$(curl -4 ifconfig.co/country-iso)
timedatectl set-ntp true
pacman -S --noconfirm archlinux-keyring #update keyrings to latest to prevent packages failing to install

echo -ne "Enabling parallel downloads"
pacman -S --noconfirm --needed pacman-contrib
sed -i 's/^#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf

echo -ne "Setting up $iso mirrors for faster downloads"
pacman -S --noconfirm --needed reflector rsync grub
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
echo -ne "
Setting up $iso mirrors for faster downloads
"
reflector -a 48 -c "$iso" -f 5 -l 20 --sort rate --save /etc/pacman.d/mirrorlist
mkdir /mnt &>/dev/null # Hiding error message if any
echo -ne "
Installing Prerequisites
mkdir /mnt &>/dev/null

"
echo -ne "Formatting Disk"
pacman -S --noconfirm --needed gptfdisk btrfs-progs glibc
echo -ne "
-------------------------------------------------------------------------
Formating Disk
-------------------------------------------------------------------------
"

umount -A --recursive /mnt # make sure everything is unmounted before we start
# disk prep
sgdisk -Z ${DISK} # zap all on disk
sgdisk -a 2048 -o ${DISK} # new gpt disk 2048 alignment

# create partitions
sgdisk -n 1::+1M --typecode=1:ef02 --change-name=1:'BIOSBOOT' ${DISK} # partition 1 (BIOS Boot Partition)
sgdisk -n 2::+1G --typecode=2:ef00 --change-name=2:'EFIBOOT' ${DISK} # partition 2 (UEFI Boot Partition)
sgdisk -n 3::-0 --typecode=3:8300 --change-name=3:'ROOT' ${DISK} # partition 3 (Root), default start, remaining
if [[ ! -d "/sys/firmware/efi" ]]; then # Checking for bios system
sgdisk -A 1:set:2 ${DISK}
fi
partprobe ${DISK} # reread partition table to ensure it is correct
umount -A --recursive /mnt &>/dev/null

# make filesystems
echo -ne "
echo "Wiping Disk"
sgdisk -Z ${DISK}
sgdisk -a 2048 -o ${DISK}

Creating Filesystems
echo "Partitioning Disk"
sgdisk -n 1::+1M --typecode=1:ef02 --change-name=1:'BIOSBOOT' ${DISK}
sgdisk -n 2::+1G --typecode=2:ef00 --change-name=2:'EFIBOOT' ${DISK}
sgdisk -n 3::-0 --typecode=3:8300 --change-name=3:'ROOT' ${DISK}
if [[ ! -d "/sys/firmware/efi" ]]; then
sgdisk -A 1:set:2 ${DISK}
fi
partprobe ${DISK}

"
# @description Creates the btrfs subvolumes.
echo -ne "Creating Filesystems"
createsubvolumes() {
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
btrfs subvolume create /mnt/@var
btrfs subvolume create /mnt/@tmp
btrfs subvolume create /mnt/@.snapshots
}

# @description Mount all btrfs subvolumes after root has been mounted.
mountallsubvol() {
mount -o ${MOUNT_OPTIONS},subvol=@home ${partition3} /mnt/home
mount -o ${MOUNT_OPTIONS},subvol=@tmp ${partition3} /mnt/tmp
mount -o ${MOUNT_OPTIONS},subvol=@var ${partition3} /mnt/var
mount -o ${MOUNT_OPTIONS},subvol=@.snapshots ${partition3} /mnt/.snapshots
}

# @description BTRFS subvolulme creation and mounting.
subvolumesetup() {
# create nonroot subvolumes
createsubvolumes
# unmount root to remount with subvolume
umount /mnt
# mount @ subvolume
mount -o ${MOUNT_OPTIONS},subvol=@ ${partition3} /mnt
# make directories home, .snapshots, var, tmp
mkdir -p /mnt/{home,var,tmp,.snapshots}
# mount subvolumes
mountallsubvol
}

Expand All @@ -93,12 +64,10 @@ else
partition3=${DISK}3
fi

# make filesystems EXT4 for / and FAT32 for /boot/efi
mkfs.vfat -F32 -n "EFIBOOT" ${partition2}
mkfs.ext4 -L ROOT ${partition3}
mount -t ext4 ${partition3} /mnt

# mount target
mkdir -p /mnt/boot/efi
mount -t vfat -L EFIBOOT /mnt/boot/

Expand All @@ -109,26 +78,31 @@ if ! grep -qs '/mnt' /proc/mounts; then
echo "Rebooting in 1 Second ..." && sleep 1
reboot now
fi
echo -ne "
Arch Install on Main Drive
"
pacstrap /mnt base base-devel linux linux-firmware linux-headers vim sudo archlinux-keyring wget libnewt --noconfirm --needed
echo -ne "Pacstrapping Archlinux base system"
pacstrap /mnt \
archlinux-keyring \
base \
base-devel \
git \
libnewt \
linux \
linux-firmware \
linux-headers \
sudo \
vim \
wget \
pacman-contrib \
util-linux

--noconfirm --needed

cp -R ${BASE_DIR} /mnt/root/archcrystal
cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist

echo "Generating FSTAB"
genfstab -L /mnt >>/mnt/etc/fstab
echo "
Generated /etc/fstab:
"
cat /mnt/etc/fstab
echo -ne "
-------------------------------------------------------------------------
GRUB BIOS Bootloader Install & Check
-------------------------------------------------------------------------
"

echo "Setting up boot"
if [[ ! -d "/sys/firmware/efi" ]]; then
grub-install --boot-directory=/mnt/boot ${DISK}
else
Expand Down
Loading

0 comments on commit 59899de

Please sign in to comment.