list all of the files that belong to the native package
[myplc.git] / build.functions
1 # -*-Shell-script-*-
2 #
3 # Common functions for MyPLC build scripts (build_devel.sh and
4 # build.sh)
5 #
6 # Mark Huang <mlhuang@cs.princeton.edu>
7 # Copyright (C) 2006 The Trustees of Princeton University
8 #
9 # $Id:$
10 #
11
12 PATH=/sbin:/bin:/usr/sbin:/usr/bin
13
14 # In both a normal CVS environment and a PlanetLab RPM
15 # build environment, all of our dependencies are checked out into
16 # directories at the same level as us.
17 if [ -d ../build ] ; then
18     PATH=$PATH:../build
19     srcdir=..
20 else
21     echo "Error: Could not find $(cd .. && pwd -P)/build/"
22     exit 1
23 fi
24
25 export PATH
26
27 . build.common
28
29 pl_process_fedora_options $@
30 shiftcount=$?
31 shift $shiftcount
32
33 # XXX Backwards compatibility with old myplc-devel environment
34 # We may be running inside a myplc-devel environment, which can
35 # override these defaults.
36 if [ -f /etc/planetlab/plc_config ] ; then
37     . /etc/planetlab/plc_config
38     [ ! -z "$PLC_DEVEL_FEDORA_RELEASE" ] && pl_FEDORA_RELEASE=$PLC_DEVEL_FEDORA_RELEASE
39     [ ! -z "$PLC_DEVEL_FEDORA_ARCH" ] && pl_FEDORA_ARCH=$PLC_DEVEL_FEDORA_ARCH
40     [ ! -z "$PLC_DEVEL_FEDORA_URL" ] && pl_FEDORA_URL=$PLC_DEVEL_FEDORA_URL
41 fi
42
43 # Do not tolerate errors
44 set -e
45
46 # Be verbose
47 set -x
48
49 # Make a basic chroot at the specified location given the specified
50 # configuration.
51 make_chroot() {
52     root=$1
53     config=$2
54
55     # Get group list
56     groups=
57     while read group ; do
58         groups="$groups -g \"$group\""
59     done < <(./plc-config --groups $config)
60
61     # Get package list
62     packages=
63     while read package ; do
64         packages="$packages -p \"$package\""
65     done < <(./plc-config --packages $config)
66
67     pl_setup_chroot $root $packages $groups
68 }
69
70 # Move specified directories out of the chroot and into a "data"
71 # directory that will be bind mounted on /data inside the chroot.
72 move_datadirs() {
73     root=$1
74     data=$2
75     shift 2
76     pl_move_dirs $root $data /data "$@"
77 }
78
79 # Make loopback filesystem from specified location
80 make_image() {
81     root=$1
82     image=$2
83     pl_make_image $root $image 100000000
84 }