Skip to content

Commit

Permalink
feat: generate installer
Browse files Browse the repository at this point in the history
  • Loading branch information
xhcoding committed Dec 10, 2023
1 parent 04c0ec3 commit db59b90
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
9 changes: 8 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ if [[ ! -z $2 ]] ; then
fi

PACK_FILENAME="${PACK_NAME}-${PACK_SYSTEM}.tar.gz"
INSTALLER_FILENAME="${PACK_NAME}-${PACK_SYSTEM}-installer.run"

echo "Emacs dir: $EMACS_DIR"
echo "Pack name: $PACK_FILENAME"
Expand All @@ -31,6 +32,9 @@ guix install -L $LOAD_PATH emacs-git

echo "Start init emacs-config"

GUIX_PROFILE="${HOME}/.guix-profile"
source "${GUIX_PROFILE}/etc/profile"

emacs --init-directory=$EMACS_DIR -Q --batch -l org --eval "(org-babel-tangle-file \"README.org\")"

emacs --init-directory=$EMACS_DIR -Q --batch -l early-init.el -l init.el
Expand All @@ -43,6 +47,9 @@ guix install -L $LOAD_PATH emacs-config

echo "Start pack"

guix pack -L $LOAD_PATH -RR -r $PACK_FILENAME -S /opt/emacs/bin=bin -S /opt/emacs/lib=lib -S /opt/emacs/share=share \
guix pack -L $LOAD_PATH -RR -r $PACK_FILENAME -S /opt/emacs/bin=bin -S /opt/emacs/lib=lib -S /opt/emacs/etc=etc -S /opt/emacs/share=share \
glibc-locales emacs-git emacs-config

echo "Generate installer"

cat install.sh $PACK_FILENAME > $INSTALLER_FILENAME
49 changes: 49 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash
set -e
readonly SCRIPT_LINES=51
readonly TEMP_PATH=/tmp/emacs-x-temp.tar.gz

INSTALL_DIR=/opt/emacs-x
BIN_DIR=/usr/bin

if [[ ! -z $1 ]] ; then
INSTALL_DIR=$1
fi

if [[ ! -z $2 ]] ; then
BIN_DIR=$2
fi

EMACS_X_PATH=$BIN_DIR/emacs-x

if [[ -d $INSTALL_DIR ]] ; then
echo "Error: $INSTALL_DIR exists"
exit 1
fi

mkdir -p $INSTALL_DIR

if [[ -f $TEMP_PATH ]] ; then
rm -f $TEMP_PATH
fi

tail -n +$SCRIPT_LINES $0 > $TEMP_PATH

pushd $INSTALL_DIR

tar -zxvf $TEMP_PATH
chmod -R a+w *

cat <<EOF > $EMACS_X_PATH
#!/bin/bash
export GUIX_LOCPATH=${INSTALL_DIR}/opt/emacs/lib/locale
export PATH=${INSTALL_DIR}/opt/emacs/bin:${PATH}
source ${INSTALL_DIR}/opt/emacs/etc/profile
emacs --init-directory=${INSTALL_DIR}/opt/emacs/share/emacs.d "\$@"
EOF

chmod a+x $EMACS_X_PATH

popd
exit 0

0 comments on commit db59b90

Please sign in to comment.