Compare commits
No commits in common. "4402e6b2e336045aafe41e96ccfad2218e237cbf" and "dd469dbf65ae78c0573015424e4f340b85ff7314" have entirely different histories.
4402e6b2e3
...
dd469dbf65
@ -12,13 +12,12 @@ CLI script to rearrange pdf pages for printing book signatures and foldable zine
|
|||||||
- [`venv`](https://docs.python.org/3/library/venv.html) (might be installed)
|
- [`venv`](https://docs.python.org/3/library/venv.html) (might be installed)
|
||||||
- check with `python3 -m venv --help`
|
- check with `python3 -m venv --help`
|
||||||
|
|
||||||
```bash
|
```
|
||||||
#!/bin/bash
|
|
||||||
PREFIX="$HOME/.local"
|
PREFIX="$HOME/.local"
|
||||||
LIBDIR=$PREFIX/lib
|
LIBDIR=$PREFIX/lib
|
||||||
BINDIR=$PREFIX/bin
|
BINDIR=$PREFIX/bin
|
||||||
SRCDIR=$LIBDIR/pdf2book.git
|
SRCDIR=$LIBDIR/pdf2book.git
|
||||||
mkdir -p $LIBDIR $BINDIR
|
mkdir -p $LIBDIR
|
||||||
git clone https://git.wlankabel.at/onipa/pdf2book.git $SRCDIR
|
git clone https://git.wlankabel.at/onipa/pdf2book.git $SRCDIR
|
||||||
python3 -m venv $SRCDIR/.venv
|
python3 -m venv $SRCDIR/.venv
|
||||||
. $SRCDIR/.venv/bin/activate
|
. $SRCDIR/.venv/bin/activate
|
||||||
|
121
install.sh
121
install.sh
@ -1,121 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
## INSTALL pdf2book in Linux or macOS
|
|
||||||
### Dependencies:
|
|
||||||
# - bash: check with `bash --version`
|
|
||||||
# - python3: check with `python3 --version`
|
|
||||||
#- venv: check with `python3 -m venv --help`
|
|
||||||
#
|
|
||||||
# check dependencies
|
|
||||||
set -e
|
|
||||||
bash --version > /dev/null
|
|
||||||
python3 --version > /dev/null
|
|
||||||
python3 -m venv --help > /dev/null
|
|
||||||
set +e
|
|
||||||
#
|
|
||||||
PREFIX="$HOME/.local"
|
|
||||||
HELP="""
|
|
||||||
$0: install pdf2book with its virtual environment
|
|
||||||
usage:
|
|
||||||
-h|--help show this help message and exti
|
|
||||||
-d|--delete remove pdf2book
|
|
||||||
-f|--force force overwriting of PREFIX/lib/pdf2book.git
|
|
||||||
can be used for upgrading
|
|
||||||
-p|--prefix PREFIX install into PREFIX/lib and PREFIX/bin
|
|
||||||
-v|--verbose print more info (set -x)
|
|
||||||
-y|--yes don't ask for confimation of prefix
|
|
||||||
"""
|
|
||||||
# OPTIONS
|
|
||||||
# Iterate through each argument
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
case "$1" in
|
|
||||||
--delete|-d)
|
|
||||||
DELETE=1
|
|
||||||
;;
|
|
||||||
--force|-f)
|
|
||||||
FORCE=1
|
|
||||||
;;
|
|
||||||
--help|-h)
|
|
||||||
echo "$HELP"
|
|
||||||
# Add help instructions here
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
--prefix|-p)
|
|
||||||
PSET=1
|
|
||||||
PREFIX=$2
|
|
||||||
shift 1
|
|
||||||
;;
|
|
||||||
--verbose|-v)
|
|
||||||
set -x
|
|
||||||
;;
|
|
||||||
--yes|-y)
|
|
||||||
PSET=1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unknown option: $1"
|
|
||||||
echo "HELP"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift 1 # Move to the next argument
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ $PSET != 1 ]]
|
|
||||||
then
|
|
||||||
echo -n """Where to do you want to install 'pdf2book'?
|
|
||||||
PREFIX [$PREFIX] :
|
|
||||||
"""
|
|
||||||
read userprefix
|
|
||||||
if [[ -n $userprefix ]]
|
|
||||||
then
|
|
||||||
PREFIX=$userprefix
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
LIBDIR=$PREFIX/lib
|
|
||||||
BINDIR=$PREFIX/bin
|
|
||||||
SRCDIR=$LIBDIR/pdf2book.git
|
|
||||||
if [[ -d $SRCDIR ]]
|
|
||||||
then
|
|
||||||
if [[ -z $FORCE ]]
|
|
||||||
then
|
|
||||||
echo -n """Directory '$SRCDIR' already exist.
|
|
||||||
Do you want to overwrite? [y/N] """
|
|
||||||
read confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || echo "... exiting ..." && exit 1
|
|
||||||
fi
|
|
||||||
rm -rf $SRCDIR
|
|
||||||
fi
|
|
||||||
mkdir -p $LIBDIR $BINDIR
|
|
||||||
git clone https://git.wlankabel.at/onipa/pdf2book.git $SRCDIR
|
|
||||||
python3 -m venv $SRCDIR/.venv
|
|
||||||
. $SRCDIR/.venv/bin/activate
|
|
||||||
pip3 install pypdf
|
|
||||||
echo -n '''#!/bin/bash
|
|
||||||
SRCDIR='$SRCDIR'
|
|
||||||
VENVDIR=$SRCDIR/.venv
|
|
||||||
. $VENVDIR/bin/activate
|
|
||||||
python3 $SRCDIR/pdf2book.py $@
|
|
||||||
deactivate
|
|
||||||
'''> $BINDIR/pdf2book
|
|
||||||
chmod +x $BINDIR/pdf2book
|
|
||||||
echo "pdf2book is installed into '$(realpath $BINDIR)'"
|
|
||||||
#check if $BINDIR is in $PATH
|
|
||||||
INPATH=$(echo $PATH | tr : '\n' | grep $(realpath $BINDIR) | wc -l )
|
|
||||||
if [[ $INPATH -lt 1 ]]
|
|
||||||
then
|
|
||||||
if [[ $(uname) == "Darwin" ]]
|
|
||||||
then
|
|
||||||
RCFILE='.zshrc'
|
|
||||||
else
|
|
||||||
RCFILE=".bashrc"
|
|
||||||
fi
|
|
||||||
echo "WARNING! '$BINDIR' is not in \$PATH"
|
|
||||||
echo -n """Do you want to add '$BINDIR' to \$PATH (via ~/$RCFILE)? [Y/n] """
|
|
||||||
read confirm
|
|
||||||
if [[ $confirm == [yY] || $confirm == [yY][eE][sS] || -z $confirm ]]
|
|
||||||
then
|
|
||||||
echo 'export PATH=$PATH:'$(realpath $BINDIR) >> $HOME/$RCFILE
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
#echo inpath: $INPATH
|
|
||||||
echo "you might need to restart your shell"
|
|
||||||
#echo prefix: $PREFIX
|
|
Loading…
Reference in New Issue
Block a user