[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [patch] buildcross trivial cleanup



On Fri, Mar 28, 2008 at 11:50:02PM +0100, Hector Oron wrote:
>Hello Bernhard,
>
>  I hope you do not mind if I CC to debian-embedded :-)
np
>
>  Let me explain a bit what buildcross is about. As i did not know
>much about toolchains, i started to do my own experiments, so i coded
>buildcross. Now, buildcross is meant to build cross toolchains for
>emdebian.org, all official arches.
>
>  Buildcross method
>  ---------------------------
>
>  Buildcross builds libraries (libc6, libc6-dev, libgcc1,
>gcc-4.x-base) using apt-cross (dpkg-cross). Then it builds binutils
>from source and finally gcc from source. The tricky part is to update
>Debian build system with tested patches so all cross toolchains build
>without errors. Right now, all 32/64bit arches (including triarch
>mips(el)) are borked.

Right now, are they just borked for 4.3, i.e. does 4.2 work?

>
>  If you plan to update buildcross, please use branch/ code instead
>trunk/, there are still some ugly parts that can be reworked and
>finished.

Ok, please consider attached cleanup then..

>
>  Some other interesting scripts are emchain that is meant to build a
>user toolchain following buildcross method but for the arch that the
>user wants.

Ok, I'll get to this later.
Index: buildcross/branch/buildcross
===================================================================
--- buildcross/branch/buildcross	(revision 3261)
+++ buildcross/branch/buildcross	(working copy)
@@ -1,7 +1,7 @@
-#!/bin/bash
+#!/bin/sh
 # $Header: /var/emdebian/svn/tools/buildcross/branch/buildcross,v 0.3 2007/07/18 01:10:03 zumbi Exp $
 #
-#  Copyright (C) 2000, 2007  Emdebian <debian-embedded@lists.debian.org>
+#  Copyright (C) 2000, 2007, 2008  Emdebian <debian-embedded@lists.debian.org>
 #
 #  This program should call buildcross to build a certain outdated
 #  package. It runs buildcross in a modular way. This program should
@@ -36,26 +36,52 @@
 #  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 #
 #
-# Distributed under the terms of the GNU General Public License v2
+# Distributed under the terms of the GNU General Public License v2 or, at your opinion, any later version.
 
 source conf_vars.sh
 
-if [ ! -d $LOGPATH ]; then
-        mkdir -p $LOGPATH
-fi
+print_help=0
+print_version=0
+do_quiet=0
+do_background=0
+ME=`echo $0 | sed -e 's/.*\///'`
 
-usage(){
-        echo "Usage: ${0##*/} [OPTION]"
+while [ -n "$1" ]; do
+	case $1 in
+		-v)
+			print_version=1
+			shift
+			;;
+		-b)
+			do_background=1
+			shift
+			;;
+		-c)
+			do_quiet=1
+			shift
+			;;
+		-d)
+			# normal mode
+			shift
+			;;
+		*)
+			print_help=1
+			shift
+			;;
+	esac
+done
+if [ $print_help -eq 1 ]; then
+        echo "Usage: $ME [OPTION]"
         echo "Build Debian cross toolchain system."
-        echo
-        cat << EOF
-        -h      displays this help
-        -v      displays version number
-        -b      no output, runs completely on background
+        cat <<-EOF
+
+        -h      display this help
+        -v      display version number
+        -b      no output, runs completely in the background
                 WARNING: You can not stop it, just using kill.
-                         If you are in a chroot beware proc is mounted.
-        -c      no output mode
-        -d      Show output. Recommended for first time.
+                         If you are in a chroot make sure proc is mounted.
+        -c      Be quiet, no output
+        -d      Show output. Recommended for first time. This is the default.
 
         Check log.html file (bug: libs always is marked as failed)
         All log info is under logs/
@@ -66,39 +92,25 @@
                           3: package built
 
 EOF
-}
+	exit 0
+elif [ $print_version -eq 1 ]; then
+	echo "@VERSION@"
+	exit 0
+fi
 
+if [ ! -d $LOGPATH ]; then
+        mkdir -p $LOGPATH
+fi
 
-if [ $# != 0 ]; then
-	while true; do
-		case $1 in
-			 -h)
-				usage
-				exit 0
-				;;
-			 -v)
-			 	echo "Version: 0.2-v"
-				shift
-				;;
-			 -b)
-				echo "Buildcross has no output with -b option, so it runs on background."
-				echo "Check file.html when time is displayed"
-			#	time ./em_wrap.sh &> $LOGPATH/build.log &
-				shift
-				;;
-			 -c)
-			#	time ./em_wrap.sh &> $LOGPATH/build.log 
-			 	echo "Version: 0.2-c"
-				shift
- 				;;
-			 -d)
-			#	time ./em_wrap.sh | tee $LOGPATH/build.log 
-			 	echo "Version: 0.2-d"
-				shift
-			 	;;
-			*)
-				break
-				;;
-		esac
-	done
+if [ $do_background -ne 0 ]; then
+	echo "Running in the background."
+	echo "Check file.html when time is displayed"
+	time ./em_wrap.sh &> $LOGPATH/build.log &
+elif [ $do_quiet -ne 0 ]; then
+	time ./em_wrap.sh 2>&1 >& $LOGPATH/build.log
+	exit $?
+else
+	time ./em_wrap.sh 2>&1 >&1 | tee $LOGPATH/build.log
+	exit $?
 fi
+
Index: buildcross/branch/Makefile
===================================================================
--- buildcross/branch/Makefile	(revision 3261)
+++ buildcross/branch/Makefile	(working copy)
@@ -14,6 +14,6 @@
 
 
 	sed 's/@VERSION@/$(VERSION)/g' buildcross >$(DESTDIR)/usr/sbin/buildcross
-	chown root:root $(DESTDIR)/usr/sbin/buildcross
+	chown 0:0 $(DESTDIR)/usr/sbin/buildcross
 	chmod 0755 $(DESTDIR)/usr/sbin/buildcross
 

Reply to: