Skip to content

Instantly share code, notes, and snippets.

@freethinker
Forked from anonymous/unity-builder.sh.txt
Created October 17, 2012 17:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save freethinker/3906721 to your computer and use it in GitHub Desktop.
Save freethinker/3906721 to your computer and use it in GitHub Desktop.
unity-builder.sh
#!/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 $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
set -e
pull_changes_unity
set +e
build_main
set -e
pull_changes_unity_extra
set +e
build_extra
repo
echo "Done"
@rafamanzo
Copy link

Hello, I've tried it today, and found some minor isses:

If glib2 already is installed it will conflict with the ubuntu one, so I've added some lines to remove it.

There is something wrong with the compilation of TEST packages, so I've added the --nocheck flag. I know this is not the right fix, but I'm also not sure about how to fix the packages generation. This is just something to make it work until someone doesn't find the right fix.

I've made the fixes available here:
https://gist.github.com/rafamanzo/5792635

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment