build.sh 4.91 KB
Newer Older
Jan Mette's avatar
Jan Mette committed
1
#!/bin/bash
Jan Mette's avatar
Jan Mette committed
2 3 4 5 6 7 8 9 10 11 12 13 14

#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>
Jan Mette's avatar
Jan Mette committed
15 16 17 18

#
# setup
#
Jan Mette's avatar
Jan Mette committed
19
_script_name="build(er)"
Jan Mette's avatar
Jan Mette committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
_build_arch="$_arch"
_cur_repo=`pwd | awk -F '/' '{print $NF}'`
_needed_functions="config_handling messages dependency_handling"
_available_pkglists=`cat _buildscripts/${_cur_repo}-${_build_arch}-pkgs.conf | grep "_" | cut -d "=" -f 1 | awk 'BEGIN {FS="_"} {print $NF}' | sed '/^$/d'`
# load functions
for subroutine in ${_needed_functions}
do
    source _buildscripts/functions/${subroutine}
done

current_repo="$_cur_repo"


#
# main
#
build_it()
{
	_mkpkg_flags=$1
        [ -n "$MODE" ] || error "you need to specify a package list defined in _/buildsystem/${_cur_repo}-${_build_arch}-pkgs.conf\n -> ${_available_pkglists}"

	cd $_build_work

	for module in ${whattodo[*]}
	do
		[[ `echo $module | cut -c1` == '#' ]] && continue
		msg "building $module. makepkg flags: $_mkpkg_flags"
		pushd $module &>/dev/null

			if [ -e "$_build_work/$module/PKGBUILD" ] ; then

				if [ "$_build_autodepends" = "1" ] ; then

					do_makedeps
					do_deps

                    ../makepkg -f $_mkpkg_flags || BUILD_BROKEN="1"

					if [ "$BUILD_BROKEN" = "1" ] ; then
						if [ "$_build_stop" = "1" ] ; then
							echo " "
							echo " "
							echo "ERROR BUILDING $module"
							echo " "
							echo " "
							exit 1
						else
							BROKEN_PKGS="$BROKEN_PKGS $module"
							unset BUILD_BROKEN
						fi
					fi
				else
                    ../makepkg -f $_mkpkg_flags || BUILD_BROKEN="1"

					if [ "$BUILD_BROKEN" = "1" ] ; then
						if [ "$_build_stop" = "1" ] ; then
							echo " "
							echo " "
							echo "ERROR BUILDING $module"
							echo " "
							echo " "
							exit 1
						else
							BROKEN_PKGS="$BROKEN_PKGS $module"
							unset BUILD_BROKEN
						fi
					fi
				fi

			else
				echo " "
				echo "No PKGBUILD found, exiting... :("
				echo " "
				exit 1	
			fi
	
			# Install packages	
			if [ "$_build_autoinstall" = "1" ] ; then
			# Look for the exact package names :

Jan Mette's avatar
Jan Mette committed
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
# 				pushd ${_build_work}/${module} &>/dev/null || exit 1
# 
# 				# get the pkgnames, different for an array and a bare string
# 				if [ `grep -e "^pkgname=" PKGBUILD | cut -d'=' -f2 | cut -c1` == "(" ] ; then
# 					# fetch the array
# 					_module_names=`pcregrep -M "^pkgname=\(.*(\n.*[^\)\n])*" PKGBUILD | sed s/"^[^\']*"//g | sed s/[^\']$//`
# 				else
# 					_module_names=("`grep -e "^pkgname=" PKGBUILD | cut -d'=' -f2`")
# 				fi
# 
# 				# version and rel
# 				#_modver=`grep -e "^pkgver=" PKGBUILD | cut -d'=' -f2`
# 				#_modrel=`grep -e "^pkgrel=" PKGBUILD | cut -d'=' -f2`
# 
# 				popd &>/dev/null
# 
# 				# build a list of packages and install them at once
# 				_packages_to_install=
# 				for _m in $_module_names ; do 
# 					#_pkg_full_name=`eval echo $_m-$_modver-$_modrel-*.pkg.*`
# 					_pkg_full_name=`eval echo $_m-*.pkg.*`
# 					_packages_to_install="$_packages_to_install $PKGDEST/$_pkg_full_name"
# 				done
# 				sudo pacman -Uf $_packages_to_install || exit 1

Jan Mette's avatar
Jan Mette committed
125
				sudo pacman -U ../_repo/build/${module}-*.pkg.*
Jan Mette's avatar
Jan Mette committed
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
			fi

	popd &>/dev/null
	done

	msg "removing debug packages ..."
	sudo pacman -Rcs kdemod-debug --noconfirm &>/dev/null
	echo " "
	echo " "	

}

#
# startup
#
title "${_script_name}"

check_configs
load_configs

MODE=`echo $1`

# we take the repo name + the job/stage to reconstruct the variable name
# in $repo_pkgs.cfg and echo its contents... damn, eval is evil ;)

	if [ "$_cur_repo" = "core" ] ; then
	whattodo=($(eval echo "\${_build_core_${MODE}[@]}"))

	elif [ "$_cur_repo" = "core-testing" ] ; then
	whattodo=($(eval echo "\${_build_core_testing_${MODE}[@]}"))

	elif [ "$_cur_repo" = "platform" ] ; then
	whattodo=($(eval echo "\${_build_platform_${MODE}[@]}"))

	elif [ "$_cur_repo" = "platform-testing" ] ; then
	whattodo=($(eval echo "\${_build_platform_testing_${MODE}[@]}"))

	elif [ "$_cur_repo" = "desktop" ] ; then
	whattodo=($(eval echo "\${_build_desktop_${MODE}[@]}"))

	elif [ "$_cur_repo" = "desktop-testing" ] ; then
	whattodo=($(eval echo "\${_build_desktop_testing_${MODE}[@]}"))

	elif [ "$_cur_repo" = "apps" ] ; then
	whattodo=($(eval echo "\${_build_apps_${MODE}[@]}"))

	elif [ "$_cur_repo" = "apps-testing" ] ; then
	whattodo=($(eval echo "\${_build_apps_testing_${MODE}[@]}"))

	fi

time build_it f

if [ -z "$BROKEN_PKGS" ] ; then 
	title2 "All done"
else
	title2 "All done"
	title2 "SOME PACKAGES WERE NOT BUILT: $BROKEN_PKGS"
fi

newline