Projects
New Ticket     Wiki     Browse Source     Timeline     Roadmap     Bug Reports     Search

root/contrib/mpab/mpab

Revision 38930, 3.7 KB (checked in by raimue@…, 5 months ago)

Import MPAB from the wiki

  • Property svn:executable set to *
Line 
1#!/bin/sh
2#
3# Copyright (c) 2006,2008 Bryan L Blackburn.  All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright
9#    notice, this list of conditions and the following disclaimer.
10# 2. Redistributions in binary form must reproduce the above copyright
11#    notice, this list of conditions and the following disclaimer in
12#    the documentation and/or other materials provided with the
13#    distribution.
14# 3. Neither the name Bryan L Blackburn, nor the names of any contributors
15#    may be used to endorse or promote products derived from this software
16#    without specific prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
19# AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
22# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
25# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
28# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29#
30
31export PATH=/bin:/usr/bin:/sbin:/usr/sbin
32
33# Base filename for the disk image
34IMGBASENAME="mproot"
35
36# subdir start of the chroot
37CHROOTSUBDIR="mpchroot"
38
39# Name of the file containing all of MacPorts
40MPTARBALL="macports_dist.tar.bz2"
41
42if [[ -n ${MPABDEBUG} ]]; then
43   HDIUTILDEBUG="-verbose"
44else
45   HDIUTILDEBUG="-quiet"
46fi
47export HDIUTILDEBUG
48
49cd `dirname $0`
50baseDir=`pwd -P`
51chrootPath="${baseDir}/${CHROOTSUBDIR}"
52cd - > /dev/null
53
54. ${baseDir}/mpab-functions
55
56command="buildports"
57portlistFile=""
58if [[ -n $1 ]]; then
59   command=$1 && shift
60   if [[ ${command} != "help" && ${command} != "mount" &&
61         ${command} != "umount" && ${command} != "buildmp" &&
62         ${command} != "rebuildmp" && ${command} != "buildports" ]]; then
63      printUsageAndExit
64   fi
65   if [[ ${command} == "buildports" && -n $1 ]]; then
66      portlistFile=$1 && shift
67      if [[ ! -e ${portlistFile} ]]; then
68         echo "File '${portlistFile}' not found" && echo
69         printUsageAndExit
70      fi
71   fi
72   if [[ ${command} == "help" || -n $1 ]]; then
73      printUsageAndExit
74   fi
75fi
76
77checkDependencies ${baseDir} ${MPTARBALL}
78returnValue=$?
79if [[ ${returnValue} != 0 ]]; then
80   exit ${returnValue}
81fi
82
83if [[ ${command} == "umount" ]]; then
84   umountChroot ${chrootPath}
85   exit 0
86fi
87
88if [[ ${command} == "mount" || ${command} == "buildmp" ||
89   ${command} == "rebuildmp" || ${command} == "buildports" ]]; then
90   buildImages ${baseDir} ${chrootPath} ${IMGBASENAME}
91   mountChroot ${baseDir} ${chrootPath} ${IMGBASENAME}
92   if [[ $? == 0 &&
93         ( ${command} == "buildmp" || ${command} == "rebuildmp" ||
94           ${command} == "buildports" ) ]]; then
95      trap "exitFunction ${baseDir} ${chrootPath}" EXIT
96      exitMessage="Stopping..."
97      if [[ ${command} == "rebuildmp" ]]; then
98         rm -rf ${chrootPath}/opt/mports
99         rm -f ${chrootPath}/opt/local/bin/port
100      fi
101      buildMacPorts ${baseDir} ${chrootPath} ${MPTARBALL}
102      exitMessage=""
103      if [[ $? == 0 && ${command} == "buildports" ]]; then
104         if [[ -e ${portlistFile} ]]; then
105            cp -p ${portlistFile} ${chrootPath}/private/var/tmp/portlist
106         fi
107         exitMessage="Stopping..."
108         buildPorts ${baseDir} ${chrootPath}
109         exitMessage=""
110      fi
111   fi
112fi
Note: See TracBrowser for help on using the browser.