mirror of
https://github.com/pratiktri/dotfiles.git
synced 2026-02-04 08:41:43 +05:30
feat(install): Make install ditro-agnostic
- Auto detect and use apt, dnf & yum
This commit is contained in:
14
Dockerfile
14
Dockerfile
@@ -1,14 +0,0 @@
|
|||||||
#FROM kdeneon/plasma
|
|
||||||
FROM debian:11-slim
|
|
||||||
#FROM debian:12-slim
|
|
||||||
#FROM ubuntu:20.04
|
|
||||||
#FROM ubuntu:22.04
|
|
||||||
#FROM ubuntu:22.10
|
|
||||||
#FROM ubuntu:23.04
|
|
||||||
#TODO: Fedora
|
|
||||||
#TODO: openSUSE
|
|
||||||
#TODO: Arch
|
|
||||||
WORKDIR /scripts
|
|
||||||
RUN apt-get update -y && apt-get install sudo -y
|
|
||||||
COPY scripts .
|
|
||||||
CMD [ "bash", "install.sh" ]
|
|
||||||
61
scripts/install-brew-packages.sh
Executable file
61
scripts/install-brew-packages.sh
Executable file
@@ -0,0 +1,61 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
BREW_PACKAGE_FILE=package-list-brew
|
||||||
|
|
||||||
|
input_file_check() {
|
||||||
|
if [ ! -f "$BREW_PACKAGE_FILE" ]; then
|
||||||
|
echo "File not found: $BREW_PACKAGE_FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
install_brew() {
|
||||||
|
yes | bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||||
|
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
|
||||||
|
|
||||||
|
# Required for installing fonts
|
||||||
|
brew tap homebrew/linux-fonts
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install packages listed on "brew-package-list" file
|
||||||
|
install_brew_packages() {
|
||||||
|
not_found_packages=""
|
||||||
|
found_packages=""
|
||||||
|
|
||||||
|
# Read the package names from the file
|
||||||
|
while IFS= read -r brew_package; do
|
||||||
|
# Skip lines that start with #
|
||||||
|
case "$brew_package" in
|
||||||
|
\#*) continue ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Check if the package exists in the Homebrew repository
|
||||||
|
if brew search "$brew_package" | grep -q "^$brew_package\$"; then
|
||||||
|
echo "Available: $brew_package"
|
||||||
|
found_packages="$found_packages $brew_package"
|
||||||
|
else
|
||||||
|
not_found_packages="$not_found_packages $brew_package"
|
||||||
|
echo "Unavailable: $brew_package"
|
||||||
|
fi
|
||||||
|
done < "$BREW_PACKAGE_FILE"
|
||||||
|
|
||||||
|
brew install $found_packages
|
||||||
|
}
|
||||||
|
|
||||||
|
print_summary() {
|
||||||
|
# Print the list of packages that were not found
|
||||||
|
echo
|
||||||
|
if [ -n "$2" ]; then
|
||||||
|
echo "The following $1 packages were not found in the repository:"
|
||||||
|
echo "$2"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
input_file_check
|
||||||
|
install_brew
|
||||||
|
install_brew_packages
|
||||||
|
print_summary "Brew" "$not_found_packages"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
78
scripts/install-os-packages.sh
Executable file
78
scripts/install-os-packages.sh
Executable file
@@ -0,0 +1,78 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
OS_PACKAGE_FILE=package-list-os
|
||||||
|
|
||||||
|
OS_INSTALL_COMMAND=""
|
||||||
|
OS_PKG_CHECK_COMMAND=""
|
||||||
|
|
||||||
|
os_check() {
|
||||||
|
# TODO: Apply pre-processing to each.
|
||||||
|
# - Install apt specific things: apt-transport-https, sudo apt-get update && sudo apt-get upgrade -y
|
||||||
|
# - Improve dnf download speed by pre-applying required config
|
||||||
|
# Detect package manager and set package manager commands
|
||||||
|
if command -v apt-get > /dev/null 2>&1; then
|
||||||
|
OS_INSTALL_COMMAND="apt-get update && sudo apt-get upgrade -y && sudo apt-get"
|
||||||
|
OS_PKG_CHECK_COMMAND="apt-cache show"
|
||||||
|
elif command -v yum > /dev/null 2>&1; then
|
||||||
|
OS_INSTALL_COMMAND="yum"
|
||||||
|
OS_PKG_CHECK_COMMAND="yum list available"
|
||||||
|
elif command -v dnf > /dev/null 2>&1; then
|
||||||
|
OS_INSTALL_COMMAND="dnf"
|
||||||
|
OS_PKG_CHECK_COMMAND="dnf list available"
|
||||||
|
else
|
||||||
|
log "Unsupported package manager. This script supports apt, yum, and dnf."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
input_file_check() {
|
||||||
|
if [ ! -f "$OS_PACKAGE_FILE" ]; then
|
||||||
|
echo "File not found: $OS_PACKAGE_FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install packages listed on "os-package-list" file
|
||||||
|
install_os_packages() {
|
||||||
|
os_not_found_packages=""
|
||||||
|
os_found_packages=""
|
||||||
|
|
||||||
|
echo "Checking package availability..."
|
||||||
|
|
||||||
|
# Loop through each package name in the file
|
||||||
|
while IFS= read -r os_package; do
|
||||||
|
# Skip lines that start with #
|
||||||
|
case "$os_package" in
|
||||||
|
\#*) continue ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Check if the package exists in the APT repository
|
||||||
|
if eval "$OS_PKG_CHECK_COMMAND" "$os_package" > /dev/null 2>&1; then
|
||||||
|
echo "Available: $os_package"
|
||||||
|
os_found_packages="$os_found_packages $os_package"
|
||||||
|
else
|
||||||
|
echo "Unavailable: $os_package"
|
||||||
|
os_not_found_packages="$os_not_found_packages $os_package"
|
||||||
|
fi
|
||||||
|
done < "$OS_PACKAGE_FILE"
|
||||||
|
|
||||||
|
eval sudo "$OS_INSTALL_COMMAND" install -y "$os_found_packages"
|
||||||
|
}
|
||||||
|
|
||||||
|
print_summary() {
|
||||||
|
# Print the list of packages that were not found
|
||||||
|
echo
|
||||||
|
if [ -n "$2" ]; then
|
||||||
|
echo "The following $1 packages were not found in the repository:"
|
||||||
|
echo "$2"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
os_check
|
||||||
|
input_file_check
|
||||||
|
install_os_packages
|
||||||
|
print_summary "OS" "$os_not_found_packages"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
@@ -1,34 +1,15 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
# - brave, vs-code, cursor, kitty, libreoffice, mattermost-desktop, skypedesktop, ulauncher, code, dotnet8, dotnet8-sdk8.0, aspnetcore-runtime-8.0, sublime-text, AppImage Launcher Settings, Jetbrains Toolbox, Obsidian, Postman, firefox, zen, zoho, zoho-workdrive
|
# - Update `bootstrap-dotfiles.sh` to work from its parent directory & ignore "scripts" directory
|
||||||
# - `tee` logs to a file
|
# - Integrate with `bootstrap-dotfiles.sh` -> do dotfiles 1st, then install
|
||||||
# - README.md
|
# - README.md
|
||||||
# - Integrate with `bootstrap.sh`
|
# - Needs manual installation: appimagelauncher, firefox, brave, vs-code, cursor, kitty, mattermost-desktop, skypedesktop, ulauncher, dotnet8, dotnet8-sdk8.0, aspnetcore-runtime-8.0, Jetbrains Toolbox, Obsidian, Postman, firefox, zen, zoho, zoho-workdrive, nala
|
||||||
|
# - Available on some, not on others; may need manual installation: libreoffice, sublime-text, kitty-terminfo
|
||||||
# Install packages listed on "os-package-list" file
|
|
||||||
install_os_packages() {
|
|
||||||
# Ignore lines that start with #
|
|
||||||
OS_PACKAGES=$(sed "/^#/d" os-package-list | tr "\n\r" " ")
|
|
||||||
sudo apt-get update -y && sudo apt-get upgrade -y && sudo apt-get install $OS_PACKAGES -y
|
|
||||||
}
|
|
||||||
|
|
||||||
# Install packages listed on "brew-package-list" file
|
|
||||||
install_brew_packages() {
|
|
||||||
yes | bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
||||||
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
|
|
||||||
|
|
||||||
# Required for installing fonts
|
|
||||||
brew tap homebrew/linux-fonts
|
|
||||||
|
|
||||||
# Ignore lines that start with #
|
|
||||||
BREW_PACKAGES=$(sed "/^#/d" brew-package-list | tr "\n\r" " ")
|
|
||||||
brew install $BREW_PACKAGES
|
|
||||||
}
|
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
install_os_packages
|
./install-os-packages.sh
|
||||||
install_brew_packages
|
./install-brew-packages.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# Lines that start with # are ignored
|
# Lines that start with # are ignored
|
||||||
# TODO: use apt to check if the package is available. if not, remove them from list before installing
|
|
||||||
apt-transport-https
|
apt-transport-https
|
||||||
bash
|
bash
|
||||||
bleachbit
|
bleachbit
|
||||||
@@ -17,9 +16,12 @@ gdb
|
|||||||
git
|
git
|
||||||
gparted
|
gparted
|
||||||
htop
|
htop
|
||||||
imagemagick
|
#imagemagick
|
||||||
kde-spectacle
|
kde-spectacle
|
||||||
kdeconnect
|
kdeconnect
|
||||||
|
kitty
|
||||||
|
kitty-terminfo
|
||||||
|
libreoffice
|
||||||
llvm
|
llvm
|
||||||
make
|
make
|
||||||
net-tools
|
net-tools
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# Prune, build and run docker
|
|
||||||
main() {
|
|
||||||
docker container prune -f && echo "Removed old Docker containers"
|
|
||||||
docker build -f ../Dockerfile -t dotfile-install-test:latest .. && echo "Docker build success"
|
|
||||||
docker run -it dotfile-install-test:latest
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@"
|
|
||||||
@@ -104,3 +104,5 @@ README.md
|
|||||||
.gitignore
|
.gitignore
|
||||||
.prettierrc
|
.prettierrc
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
|
test/
|
||||||
14
scripts/test/Dockerfile
Normal file
14
scripts/test/Dockerfile
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#FROM kdeneon/plasma
|
||||||
|
#FROM debian:11-slim
|
||||||
|
#FROM debian:12-slim
|
||||||
|
#FROM ubuntu:20.04
|
||||||
|
#FROM ubuntu:22.04
|
||||||
|
#FROM ubuntu:22.10
|
||||||
|
#FROM ubuntu:23.04
|
||||||
|
FROM fedora:40
|
||||||
|
#TODO: Arch
|
||||||
|
WORKDIR /scripts
|
||||||
|
#RUN apt-get update -y && apt-get install sudo -y # for debian distros
|
||||||
|
RUN dnf install sudo -y # for fedora and its derivatives
|
||||||
|
COPY . .
|
||||||
|
CMD [ "sh", "install.sh" ]
|
||||||
11
scripts/test/run-test.sh
Executable file
11
scripts/test/run-test.sh
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Prune, build and run docker
|
||||||
|
main() {
|
||||||
|
cd .. # change docker build context to 1 directory up
|
||||||
|
docker container prune -f && echo "Removed old Docker containers"
|
||||||
|
docker build -t dotfile-install-test:latest -f test/Dockerfile . && echo "Docker build success"
|
||||||
|
docker run -it dotfile-install-test:latest
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
Reference in New Issue
Block a user