diff --git a/build.sh b/build.sh index 8d0922e..532aea4 100644 --- a/build.sh +++ b/build.sh @@ -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" @@ -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 @@ -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 diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..4ac1142 --- /dev/null +++ b/install.sh @@ -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 < $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