root/dbs64/trunk/buildall.sh

Revision 2009, 4.0 KB (checked in by saxa, 3 years ago)

Comitted version 0.1.2 of buildall.sh, which should be working now.

  • Property svn:executable set to *
Line 
1#!/bin/bash
2# Copyright 2008 Sasa Ostrouska <saxa@droplinegnome.org>
3# This script is distributed under GNU licence, is free and you can use it, modify it , redistribute it freely as you want.
4#
5# Purpose: to issue a single command to build all packages from the DBS.
6# Probably this is stupid, but its helpful when you need to do it alone or by hand :)
7#
8# * version 0.1.2 - 14-03-2009
9#
10# Added a check for space in the variable $installedpkg in check_installed_pkg()
11# Hopefully this one now should work better than the version 0.1.1
12#
13# * version 0.1.1 - 08-03-2009
14#
15# Added a function to check the installed package and compare it with the one
16# we want to build. In case its same the function calls again the update_bld_list
17# to get a new package name. Will this work ? On some packages is a mess to get the
18# correct name out as it has too many dashes in the name.
19#
20# * version 0.1 - 07-03-2009
21#
22# This should be a first version of buildall.sh which theoretically should be funcional,
23# unless after few minutes I see that it doesnt work :)
24#
25##############
26#
27
28
29function usage()
30{
31        cat << EOF
32
33        Welcome to the buildall for DBS !
34       
35        This script is used to build the dropline GNOME desktop with a single command.
36        If you want to do that you must have all the necessary scripts and source available.
37        You also need superuser privileges to run this script.
38
39        If you want to omit some packages you dont want to build please remove them or
40        comment them out in the compile-order file.
41
42        Thanks for using buildall.
43
44        Written by Sasa Ostrouska <saxa@droplinegnome.org>
45        Distributed under the GPL licence.
46
47EOF
48}
49
50if [ "$1" == "--help" ]; then
51        usage
52        exit 1
53fi
54
55#USER='whoami'
56#if [ "$USER" != "root" ]; then
57#       echo ""
58#       echo "[ERROR] You must must be root to run this script !"
59#       echo ""
60#       usage
61#       exit 1
62#fi
63
64function get_pkg_name()
65{
66        PKG_NAME=`head -n1 $BUILD_LIST`
67        echo $PKG_NAME
68        if [ "$PKG_NAME" == "" ]; then
69                exit 1
70        fi
71
72}
73
74function check_installed_pkg()
75{
76        cd /var/log/packages
77        local installedpkg=`ls $PKG_NAME-* | rev | cut -d "-" -f4- | rev`
78
79        # We need to be sure that installedpkg has only one name in it.
80        if [[ "$installedpkg" = *[[:space:]]* ]]; then 
81                local installedpkg=`echo $installedpkg | cut -d " " -f1`
82        fi
83
84        if [ "$PKG_NAME" == "$installedpkg" ]; then
85                update_bld_list
86                get_pkg_name
87#       else
88#               echo "There is no package named $installedpkg in /var/log/packages !"
89#               return 0
90#               exit 1
91        fi
92        cd $DLG_ROOT
93}
94
95function build_pkg()
96{
97        echo "---------------------------------------------------------"
98        echo "|                                                       |"
99        echo "|Building $PKG_NAME"
100        echo "|                                                       |"
101        echo "---------------------------------------------------------"
102
103        ($BUILD_CMD $PKG_NAME) || exit 1
104       
105}
106
107function pkg_install()
108{
109        echo "---------------------------------------------------------"
110        echo "|                                                       |"
111        echo "|Installing $PKG_NAME"
112        echo "|                                                       |"
113        echo "---------------------------------------------------------"
114
115        $UPGRADEPKG ${PKGS_DIR}/${PKG_NAME}*-[0-9]dl.tgz 2>/dev/null
116
117}
118
119function update_bld_list()
120{
121        local tmp_build_list="$DLG_ROOT/tmp_list.txt"
122        sed -e '1d' $BUILD_LIST > $tmp_build_list
123        rm $BUILD_LIST
124        cp $tmp_build_list $BUILD_LIST
125}
126
127
128# Main loop begins here
129
130DLG_ROOT=${DLG_ROOT:=`pwd`}
131SCRIPTS_DIR=$DLG_ROOT/SCRIPTS
132BUILD_CMD=$DLG_ROOT/build
133BUILD_ORDER=$DLG_ROOT/compile-order
134PKGS_DIR=${DLG_ROOT}/../DLG/PACKAGES/dropline-2.26
135UPGRADEPKG='/sbin/upgradepkg --reinstall --install-new'
136LOGFILE=`touch $DLG_ROOT/buildall_log.txt`
137
138PKG_NAME="1"
139
140# We need to backup the build order to not loose it.
141BUILD_LIST="$DLG_ROOT/compile-order-tmp"
142cp $BUILD_ORDER $BUILD_LIST
143# After that we clean the build order from the commented lines
144grep -v '^#' $BUILD_ORDER > $BUILD_LIST
145
146while [ "$PKG_NAME" != "" ]; do
147        get_pkg_name
148        check_installed_pkg
149#       if [ -z check_installed_pkg ]; then
150                build_pkg
151                pkg_install
152                update_bld_list
153#       fi
154done
155
Note: See TracBrowser for help on using the browser.