Add emacs-install-fedora43.sh

This commit is contained in:
tar 2026-01-31 20:54:45 +01:00
parent ace65eac1a
commit 2ec3e646a6
1 changed files with 218 additions and 0 deletions

218
emacs-install-fedora43.sh Executable file
View File

@ -0,0 +1,218 @@
#!/usr/bin/env bash
#############################################################
# Author: Taryel Hlontsi, 2025
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>
#############################################################
#############################################################
# SETUP SECTION, use "sudo" to run the script
#############################################################
LOG_DIR="/home/${USER}/Opt"
LOG="${LOG_DIR}/log.txt"
PREFIX="/home/${USER}/Opt/emacs30"
BRANCH="emacs-30"
SOURCE="https://github.com/emacs-mirror/emacs.git"
EMACS_DIR="/home/${USER}/.emacs.d/"
#############################################################
# HELPER FUNCTIONS
#############################################################
info() {
GREEN='\033[1;32m'
NC='\033[0m'
echo -e "${GREEN}$1${NC}"
echo -e "INFO:\t$1" >> $LOG
}
trace() {
YELLOW='\033[1;33m'
NC='\033[0m'
echo -e "${YELLOW}$1${NC}"
echo -e "TRACE:\t$1" >> $LOG
}
warn() {
PURPLE='\033[1;35m'
NC='\033[0m'
echo -e "${PURPLE}$1${NC}"
echo -e "WARN:\t$1" >> $LOG
}
error() {
RED='\033[1;31m'
NC='\033[0m'
echo -e "${RED}$1${NC}"
echo -e "ERROR:\t$1" >> $LOG
}
#############################################################
# 1 - INSTALL ESSENTIAL PACKAGES
#############################################################
install_essential_packages() {
local step_name='STEP 1 Installing essential packages'
warn "Press enter to proceed with $step_name"; read
info "$step_name"
sudo dnf install -y \
git \
apt \
ca-certificates \
curl \
gnupg2-gpg-agent \
unzip \
mupdf
[[ $? -gt 0 ]] && { error "$step_name failed, stopping now"; exit 1; }
info "done"
}
#############################################################
# 2 - INSTALL BUILD DEPENDENCIES FOR EMACS
#############################################################
install_emacs_build_dependencies() {
local step_name='STEP 2 Installing packages for building Emacs'
warn "Press enter to proceed with $step_name"; read
info "$step_name"
sudo dnf install -y \
@c-development \
@development-tools \
autoconf \
automake \
texinfo \
libtool \
gtk3-devel \
gtk2-devel \
libXpm-devel \
libjpeg-turbo-devel \
giflib-devel \
libtiff-devel \
libpng-devel \
librsvg2-devel \
gnutls-devel \
ncurses-devel \
libxml2-devel \
libxml2 \
dbus-devel \
libotf-devel \
m17n-lib-devel \
ImageMagick-devel \
glib2-devel \
gobject-introspection-devel \
libacl-devel \
webkit2gtk4.1-devel \
libtree-sitter-devel \
libgccjit-devel \
jansson \
jansson-devel
[[ $? -gt 0 ]] && { error "$step_name failed, stopping now"; exit 1; }
info "done"
}
#############################################################
# 3 - CLONE AND BUILD EMACS
#############################################################
clone_and_build_emacs() {
local step_name='STEP 3 Building Emacs from source [./configure --help]'
warn "Press enter to proceed with $step_name"; read
info "$step_name"
git clone $SOURCE -b $BRANCH
cd emacs
rm etc/emacsclient.desktop
./autogen.sh
./configure \
--with-native-compilation=aot \
--with-json \
--with-tree-sitter \
--with-imagemagick \
--with-rsvg \
--with-xwidgets \
--with-pgtk \
--with-x-toolkit=gtk3 \
--disable-silent-rules \
--exec_prefix=$PREFIX \
--prefix=$PREFIX
make -j$(nproc)
sudo make install
[[ $? -gt 0 ]] && { error "$step_name failed, stopping now"; exit 1; }
cd ..
info "done"
}
#############################################################
# 4 - CLONE EMACS CONFIG
#############################################################
clone_emacs_config() {
local step_name='STEP 4 Cloning emacs config to ~/.emacs.d'
warn "Press enter to proceed with $step_name"; read
info "$step_name"
if [[ -d $EMACS_DIR ]]; then
rm -rf $EMACS_DIR
fi
mkdir -p $EMACS_DIR && \
git clone https://gittar.crabdance.com/tar/.emacs.d.git $EMACS_DIR
[[ $? -gt 0 ]] && { error 'cloning emacs config failed, stopping now'; exit 1; }
trace "Emacs will throw a lot of compilation warnings on first startup - that's ok"
trace "To install the icons you need to run: M-x nerd-icons-install-fonts"
info "done"
}
#############################################################
# RUN SECTION
#############################################################
user=$(whoami)
if [ $user == root ]; then
error "You are using a root account, start without sudo!"
exit 1
fi
echo $(date +'%Y-%m-%d %H:%M') > $LOG
info "Hiya!"
sudo dnf update
sudo dnf upgrade -y
install_essential_packages
install_emacs_build_dependencies
clone_and_build_emacs
clone_emacs_config
info "Reboot (!) before starting Emacs"
info "Bye!"
info "PS. Log is here: ${LOG}"
warn "M-x nerd-icons-install-fonts"
exit 0