Skip to content

Instantly share code, notes, and snippets.

@rafamanzo
Forked from freethinker/unity-builder.sh
Last active December 18, 2015 13:49
Show Gist options
  • Save rafamanzo/5792635 to your computer and use it in GitHub Desktop.
Save rafamanzo/5792635 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Dirty script to build Unity under ArchLinux
# Thanks for PKGBUILDs, chenxiaolong!
# Valdos Sine <fat0troll at riseup dot net> 2012
# Pratik Sinha <pratik at humbug dot in> 2012
echo "Run it in directory which will be build root ;)"
echo "Make sure you're have sudo without password or you will stuck in every package installation"
echo "GO!"
sudo pacman -Sy
sudo abs
del_old_dirs() {
for dir in $1/*/
do
dir=${dir%*/}
if [ ! -f $dir/PKGBUILD ]; then
rm -rf $1/${dir##*/}
fi
done
}
del_old_packages() {
unset pkgname pkgver pkgrel
if [ -f PKGBUILD ]; then
source PKGBUILD
BUILD=0
for i in ${pkgname[@]}
do
#echo $i # or do whatever with individual element of the array
#echo $i-$pkgver-$pkgrel-$(uname -m).pkg.tar.xz
if [ "$arch" != "any" ]; then
arch=$(uname -m)
fi
if [ "$i" = "xorg-server-devel-ubuntu" ]; then
arch="any";
fi
echo $i-$pkgver-$pkgrel-${arch}.pkg.tar.xz
if [ ! -f $i-$pkgver-$pkgrel-${arch}.pkg.tar.xz ]; then
BUILD=1
fi
done
if [ $BUILD = 1 ]; then
mkdir -p ~/oldpkgs
mv *.pkg.tar.xz ~/oldpkgs
fi
fi
}
pull_changes_unity() {
# Checking main repo...
if [ -d Unity-for-Arch ] ; then
echo "All OK"
cd Unity-for-Arch/
git pull --no-rebase
cd -
del_old_packages Unity-for-Arch
else
echo "There is no PKGBUILD main repo, checking..."
git clone https://github.com/chenxiaolong/Unity-for-Arch.git
fi
}
pull_changes_unity_extra() {
# Checking extra repo...
if [ -d Unity-for-Arch-Extra ] ; then
echo "All EXTRA OK"
cd Unity-for-Arch-Extra/
git pull --no-rebase
cd -
del_old_packages Unity-for-Arch-Extra
else
echo "There is no PKGBUILD extra repo, checking..."
git clone https://github.com/chenxiaolong/Unity-for-Arch-Extra.git
fi
}
containsElement () {
local e
for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
return 1
}
build_main()
{
cd Unity-for-Arch/
MAINPKGS=`cat README | grep [0-9]: | grep -v '*' | cut -d ' ' -f 2`
# Yes, I have removed optional packages. You can build they by adding it in next option
MAINPKGS+=" overlay-scrollbar"
EXCEPTIONS=("fixesproto-ubuntu" "libxfixes-ubuntu" "gsettings-desktop-schemas-ubuntu")
for i in $MAINPKGS ; do
cd $i
del_old_packages
containsElement "$i" "${EXCEPTIONS[@]}"
CONTAINS="$?"
if [ "$CONTAINS" = "1" ]; then
CONFIRM="--noconfirm"
else
unset CONFIRM
fi
#need the NOCONFIRM because there are some places which have questions requiring a numeric input
yes | makepkg -si --nocheck $CONFIRM
if [ "$?" != "0" ]; then
set -e
rm -rf pkg src
yes | makepkg -si $CONFIRM
set +e
fi
cd ../
done
cd ../
}
build_extra()
{
cd Unity-for-Arch-Extra/
# There is hardcoded array, just because README in this git is outdated ;-(
#EXTRAPKGS="humanity-icon-theme ubuntu-mono ubuntu-wallpapers light-themes ubuntu-sounds lightdm-ubuntu accountsservice-ubuntu lightdm-unity-greeter python-defer ubuntu-tweak"
EXTRAPKGS="`cat README | grep [0-9]: | grep -v '*' | cut -d ' ' -f 2`"
for j in $EXTRAPKGS ; do
cd $j
yes | makepkg -si --noconfirm
if [ "$?" != "0" ]; then
set -e
rm -rf pkg src
yes | makepkg -si --noconfirm
set +e
fi
cd ../
done
cd ../
}
repo()
{
ARCH=`uname -m`
rm -rf unity
mkdir -p unity/$ARCH
mkdir -p unity/extra/$ARCH
find Unity-for-Arch -name *.pkg.tar.xz -exec cp '{}' unity/$ARCH/ \;
find Unity-for-Arch-Extra -name *.pkg.tar.xz -exec cp '{}' unity/extra/$ARCH/ \;
pushd unity/$ARCH/
repo-add ./unity.db.tar.gz ./*.pkg.tar.xz
popd
pushd unity/extra/$ARCH/
repo-add ./unity-extra.db.tar.gz ./*.pkg.tar.xz
popd
}
pacman -Q qtwebkit &>/dev/null
if [ "$?" == "0" ]; then
echo "REMOVING QTWEBKIT"
yes | sudo pacman -Rdd --noconfirm qtwebkit
fi
pacman -Q glib2 &>/dev/null
if [ "$?" == "0" ]; then
echo "REMOVING GLib2"
yes | sudo pacman -Rdd --noconfirm glib2
fi
set -e
pull_changes_unity
set +e
build_main
set -e
pull_changes_unity_extra
set +e
build_extra
repo
echo "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment