Last active
August 29, 2015 14:05
-
-
Save llllllllll/cef1bbdd2ad89f80aa67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
AUR_DIR=$HOME/aur | |
SUFFIX=-no-hdri | |
print_usage(){ | |
echo "Usage: $0 [-h|AUR-DIR]" | |
} | |
clean_pkgbuild(){ | |
# Remove the config flag that causes the problem. | |
sed -i "s/--enable-hdri//g" PKGBUILD | |
# Allows you to have a seperate imagemagick build. | |
sed -i "s/pkgname=('imagemagick'/pkgname=('imagemagick-no-hdri'/g" PKGBUILD | |
# Replaces the package name | |
sed -i "s/package_imagemagick() {/package_imagemagick-no-hdri () {/g" PKGBUILD | |
} | |
run_with_sudo(){ | |
if [ $# -lt 2 ];then | |
echo "Usage: run_with_sudo PASSWORD COMMAND" | |
exit 1 | |
fi | |
pass=$1 | |
shift | |
echo $pass | sudo -S $@ | |
} | |
main(){ | |
# Check for help or AUR-DIR | |
if [ $# -eq 1 ];then | |
if [ $1 -eq 'h' ];then | |
print_usage | |
0 | |
fi | |
AUR_DIR=$1 | |
fi | |
if [ -d "$AUR_DIR/imagemagick$SUFFIX" ];then | |
read -p "$AUR_DIR/imagemagick$SUFFIX already exists, remove (Y/n): " yn | |
if [[ $yn =~ ^[nN]$ ]];then | |
exit 1 | |
fi | |
rm -r "$AUR_DIR/imagemagick$SUFFIX" | |
fi | |
if [ "$EUID" -eq 0 ];then | |
echo "Do not execute this script as root, this script will prompt for your sudo password." | |
exit -1 | |
fi | |
read -sp "sudo password: " SUDO_PASS | |
start_time=$SECONDS | |
echo "Downloading abs..." | |
run_with_sudo "$SUDO_PASS" pacman -S abs --noconfirm | |
echo "abs installed!" | |
echo "Creating $AUR_DIR/imagemagick/$SUFFIX to install from..." | |
find /var/abs -type d -name imagemagick -exec cp -Rvp {} "$AUR_DIR/imagemagick$SUFFIX" \; | |
cd "$AUR_DIR/imagemagick$SUFFIX" | |
echo "Updating PKGBUILD to account remove --enable-hdri flag and change package name" | |
clean_pkgbuild | |
echo "Building package, this may take a few minutes depending on your system..." | |
makepkg -s | |
for pkg in imagemagick-no-hdri-6.8.9.6-1-x86_64.pkg.tar.xz imagemagick-doc-6.8.9.6-1-x86_64.pkg.tar.xz;do | |
echo "Installing package $pkg..." | |
run_with_sudo "$SUDO_PASS" pacman -U '$pkg' --noconfirm | |
echo "$pkg installed!" | |
done | |
echo "Force installing original imagemagick package to fix issue with emacs -nw" | |
run_with_sudo "$SUDO_PASS" pacman -S imagemagick --force --noconfirm | |
echo "Completed install in $(( SECONDS - start_time )) seconds" | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment