[dwm] PKGBUILD autorisant la config personnalisée (résolu)
Le script :
— crée un répertoire /home/$USER/.config/$PROGNAME
— y télécharge les sources
— intègre le nécessaire pour appliquer des patches
— vérifie que le binaire est bien installé dans /home/$USER/bin
— vérifie que /home/$USER/bin est bien dans le $PATH de l'utilisateur
— fait la promotion de la configuration via config.h et application de patches
Voici le code :
Code : Tout sélectionner
#!/bin/bash
### Soft settings
SOFT="dwm"
VERSION="6.1"
### Collection of OS dependent paths
X11INC=/usr/include/X11
X11LIB=/usr/lib/X11
FREETYPEINC=/usr/include/freetype2
####################################################################
## Initialization
if [ $USER == "root" ]; then
echo "Current User == $USER"
echo "This script should be run as simple user"
exit 1
fi
## Creation of relevant directory tree
mkdir -p /home/$USER/bin
PROGNAME=$(basename $0)
CONFIGDIR=/home/$USER/.config/$PROGNAME
mkdir -p $CONFIGDIR/patchs/sources
cd $CONFIGDIR
####################################################################
## Download and compilation
## Download sources
if [ ! -f $SOFT-$VERSION.tar.gz ]; then
wget http://git.suckless.org/$SOFT/snapshot/$SOFT-$VERSION.tar.gz
fi
## Untar des sources
rm -rf $SOFT-$VERSION
tar xvfz $SOFT-$VERSION.tar.gz
## Patching
cd $SOFT-*
for patch in `\ls $CONFIGDIR/patchs/*.diff`
do
echo "===> $patch <==="
patch -p1 -l < $patch
done
## Personal config
if [ -f $CONFIGDIR/config.h ]; then
cp $CONFIGDIR/config.h config.h
fi
## Compilation
echo "==== MAKE ===="
make X11INC=$X11INC X11LIB=$X11LIB FREETYPEINC=$FREETYPEINC
cp $SOFT /home/$USER/bin
####################################################################
## Final checks
echo "==== FINAL CHECKS ===="
## check presence of /home/$USER/bin/$SOFT
if [ ! -f /home/$USER/bin/$SOFT ]; then
echo "ERROR: /home/$USER/bin/$SOFT cannot be found, please check compilation log"
else
echo "OK: /home/$USER/bin/$SOFT exists"
fi
## check $PATH contains /home/$USER/bin
case $(echo :$PATH: | grep -c /home/$USER/bin) in
0)
echo "WARNING: /home/$USER/bin not in \$PATH"
;;
1)
echo "OK: /home/$USER/bin found in \$PATH"
;;
*)
echo "WARNING : /home/$USER/bin found more than once in \$PATH, something probably dirty"
echo "please run 'echo \$PATH' and check what's wrong"
;;
esac
## check $SOFT path
if [ $(which $SOFT) == "/home/$USER/bin/$SOFT" ]; then
echo "SUCCESS : $SOFT successfully installed at $(which $SOFT)"
else
echo "FAIL : $SOFT not installed correctly
- check whether /home/$USER/bin is in your \$PATH
- check whether /home/$USER/bin/dwm exists"
exit 1
fi
## check personal config.h for config advertisement
if [ ! -f $CONFIGDIR/config.h ]; then
cp config.def.h ../config.h
echo "
== Note : personal config.h has been created : copy from $pwd/config.def.h
Feel free to customize your config and re-run $PROGNAME
To be edited $CONFIGDIR/config.h"
fi
## check patch usage for config advertisement
if [ $(\ls $CONFIGDIR/patchs | grep -e "\.diff$" | wc -l) == 0 ]; then
echo "
== Note: patches could be added as .diff files in patchs to change $SOFT behavior
Please find community patches at http://dwm.suckless.org/patches/
Downloaded patches should be placed in $CONFIGDIR/patchs/sources
Links to them should be found in $CONFIGDIR/patchs/*.diff
(use 'ln -s' to create symbolic links)
Order of .diff links names could influence the success of the patching steps
"
fi
## check current directory and advertise the configdir
if [ $(pwd | grep -e "^$CONFIGDIR" | wc -l) ]; then
echo "
== Note: $SOFT configuration possible editing files in $CONFIGDIR
- modify your $CONFIGDIR/config.h
- add .diff patchs in $CONFIGDIR/patchs
Please find community patches at http://dwm.suckless.org/patches/"
fi