Ticket #36156: XcodeLegacy.sh

File XcodeLegacy.sh, 6.4 KB (added by devernay (Frédéric Devernay), 12 years ago)

updated the script, and made it available on http://devernay.free.fr/hacks/xcodelegacy/

Line 
1#!/bin/sh -x
2# XCodeLegacy.sh
3#
4# Author: Frederic Devernay <frederic.devernay@m4x.org>
5# License: Creative Commons BY-NC-SA 2.5 http://creativecommons.org/licenses/by-nc-sa/2.5/
6
7if [ $# != 1 ]; then
8    echo "Usage: $0 buildpackages|install|cleanpackages|uninstall"
9    echo "Description: Extracts / installs / cleans / uninstalls the following components from Xcode 3.2.6,"
10    echo "which are not available in Xcode >= 4.2:"
11    echo "- GCC 4.0 Xcode plugin"
12    echo "- PPC assembler"
13    echo "- GCC 4.0 and 4.2"
14    echo "- Mac OS X SDK 10.4u, 10.5 and 10.6"
15    exit
16fi
17
18XCODEDIR="/Developer"
19PLUGINDIR="$XCODEDIR/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins"
20GCCDIR="$XCODEDIR"
21SDKDIR="$XCODEDIR"
22if [ -d "$PLUGINDIR" ]; then
23    echo "Info: found Xcode <= 4.2.1"
24else
25    PLUGINDIR="/Applications/Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins"
26    if [ ! -d "$PLUGINDIR" ]; then
27        echo "Info: could not find Xcode 4.2 in /Developer nor Xcode 4.3 in /Applications/Xcode.app"
28    fi
29    echo "Info: found Xcode >= 4.3"
30    GCCDIR="/Applications/Xcode.app/Contents/Developer"
31    SDKDIR="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer"
32fi
33
34case $1 in
35    buildpackages)
36        #######################
37        # PHASE 1: PACKAGING
38        #
39        if [ ! -f xcode_3.2.6_and_ios_sdk_4.3.dmg ]; then
40            echo "you should download Xcode 3.2.6 from:"
41            echo " http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?bundleID=20792"
42            echo "or"
43            echo " http://adcdownload.apple.com/Developer_Tools/xcode_3.2.6_and_ios_sdk_4.3__final/xcode_3.2.6_and_ios_sdk_4.3.dmg"
44            exit
45        fi
46        # you should download Xcode 3.2.6 from:
47        # http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?bundleID=20792
48        hdiutil attach xcode_3.2.6_and_ios_sdk_4.3.dmg
49        rm -rf /tmp/XC3
50        pkgutil --expand /Volumes/Xcode\ and\ iOS\ SDK/Packages/DeveloperTools.pkg /tmp/XC3
51        (cd /tmp/XC3;gzip -dc Payload  |cpio -i)
52        ((cd /tmp/XC3/Library/Xcode/Plug-ins; tar cf - "GCC 4.0.xcplugin") |gzip -c > XcodePluginGCC40.tar.gz) && echo "created XcodePluginGCC40.tar.gz in directory "`pwd`
53        # should be untarred in /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins
54        # gzip -dc XcodePluginGCC40.tar.gz | (cd /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins; sudo tar xvf -)
55
56        rm -rf /tmp/XC3
57        pkgutil --expand /Volumes/Xcode\ and\ iOS\ SDK/Packages/DeveloperToolsCLI.pkg /tmp/XC3
58       
59        (cd /tmp/XC3;gzip -dc Payload  |cpio -i --quiet)
60        ((cd /tmp/XC3; tar cf - usr/libexec/gcc/darwin/ppc usr/libexec/gcc/darwin/ppc64) |gzip -c > XcodePPCas.tar.gz) ||  echo "created XcodePPCas.tar.gz in directory "`pwd`
61
62        (cp /Volumes/Xcode\ and\ iOS\ SDK/Packages/gcc4.0.pkg  xcode_3.2.6_gcc4.0.pkg) && echo "created xcode_3.2.6_gcc4.0.pkg in directory "`pwd`
63        (cp /Volumes/Xcode\ and\ iOS\ SDK/Packages/gcc4.2.pkg  xcode_3.2.6_gcc4.2.pkg) && echo "created xcode_3.2.6_gcc4.2.pkg in directory "`pwd`
64
65        rm -rf /tmp/XC3
66        pkgutil --expand /Volumes/Xcode\ and\ iOS\ SDK/Packages/MacOSX10.4.Universal.pkg /tmp/XC3
67        (cd /tmp/XC3;gzip -dc Payload  |cpio -i)
68        # should we install more than these? (fixed includes?)
69        ((cd /tmp/XC3; tar cf - SDKs/MacOSX10.4u.sdk) |gzip -c > Xcode104SDK.tar.gz) && echo "created Xcode104SDK.tar.gz in directory "`pwd`
70
71        rm -rf /tmp/XC3
72        pkgutil --expand /Volumes/Xcode\ and\ iOS\ SDK/Packages/MacOSX10.5.pkg /tmp/XC3
73        (cd /tmp/XC3;gzip -dc Payload  |cpio -i)
74        # should we install more than these? (fixed includes?)
75        ((cd /tmp/XC3; tar cf - SDKs/MacOSX10.5.sdk) |gzip -c > Xcode105SDK.tar.gz) && echo "created Xcode105SDK.tar.gz in directory "`pwd`
76
77        rm -rf /tmp/XC3
78        pkgutil --expand /Volumes/Xcode\ and\ iOS\ SDK/Packages/MacOSX10.6.pkg /tmp/XC3
79        (cd /tmp/XC3;gzip -dc Payload  |cpio -i)
80        # should we install more than these? (fixed includes?)
81        ((cd /tmp/XC3; tar cf - SDKs/MacOSX10.6.sdk) |gzip -c > Xcode106SDK.tar.gz) && echo "created Xcode106SDK.tar.gz in directory "`pwd`
82
83        rm -rf /tmp/XC3
84        ;;
85
86    install)
87        #######################
88        # PHASE 2: INSTALLING
89        #
90        if [ ! -d "$PLUGINDIR" ]; then
91            echo "Error: could not find Xcode 4.2 in /Developer nor Xcode 4.3 in /Applications/Xcode.app, cannot install"
92            exit
93        fi
94        if [ ! -d "$PLUGINDIR/GCC 4.0.xcplugin" ]; then
95            (gzip -dc XcodePluginGCC40.tar.gz | (cd "$PLUGINDIR"; sudo tar xf -)) && echo "installed XcodePluginGCC40.tar.gz"
96        fi
97
98        if [ ! -f "$GCCDIR/usr/libexec/gcc/darwin/ppc/as" ]; then
99            (gzip -dc XcodePPCas.tar.gz | (cd "$GCCDIR"; sudo tar xf -)) && echo "installed XcodePPCas.tar.gz"
100        fi
101        for v in 4.0 4.2; do
102            for i in c++ cpp g++ gcc gcov; do
103                if [ ! -f "$GCCDIR"/usr/bin/${i}-${v} ]; then
104                    sudo ln -sf /usr/bin/${i}-${v} "$GCCDIR"/usr/bin/${i}-${v}
105                fi
106            done
107        done
108
109        if [ ! -d "$SDKDIR/SDKs/MacOSX10.4u.sdk" ]; then
110            (gzip -dc Xcode104SDK.tar.gz | (cd "$SDKDIR"; sudo tar xf -)) && echo "installed Xcode104SDK.tar.gz"
111        fi
112        if [ ! -d "$SDKDIR/SDKs/MacOSX10.5.sdk" ]; then
113            (gzip -dc Xcode105SDK.tar.gz | (cd "$SDKDIR"; sudo tar xf -)) && echo "installed Xcode105SDK.tar.gz"
114        fi
115        if [ ! -d "$SDKDIR/SDKs/MacOSX10.6.sdk" ]; then
116            (gzip -dc Xcode106SDK.tar.gz | (cd "$SDKDIR"; sudo tar xf -)) && echo "installed Xcode106SDK.tar.gz"
117        fi
118
119        if [ ! -f /usr/bin/gcc-4.0 ]; then
120            echo "Installing GCC 4.0"
121            sudo installer -pkg xcode_3.2.6_gcc4.0.pkg -target /
122        fi
123        if [ ! -f /usr/bin/gcc-4.2 ]; then
124            echo "Installing GCC 4.2"
125            sudo installer -pkg xcode_3.2.6_gcc4.2.pkg -target /
126        fi
127        ;;
128
129    cleanpackages)
130        #######################
131        # PHASE 3: CLEANING
132        #
133
134        rm XcodePluginGCC40.tar.gz XcodePPCas.tar.gz xcode_3.2.6_gcc4.0.pkg xcode_3.2.6_gcc4.2.pkg Xcode104SDK.tar.gz Xcode105SDK.tar.gz Xcode106SDK.tar.gz
135
136        ;;
137
138    uninstall)
139        #######################
140        # PHASE 4: UNINSTALLING
141        #
142
143        sudo rm -rf "$PLUGINDIR/GCC 4.0.xcplugin"
144        sudo rm -rf "$GCCDIR/usr/libexec/gcc/darwin/ppc" "$GCCDIR/usr/libexec/gcc/darwin/ppc64"
145        sudo rm -rf "$GCCDIR/usr/bin/*4.0" "$GCCDIR/usr/lib/gcc/i686-apple-darwin10" "$GCCDIR/usr/lib/gcc/powerpc-apple-darwin10" "$GCCDIR/usr/libexec/gcc/powerpc-apple-darwin10" "$GCCDIR/usr/libexec/gcc/i686-apple-darwin10"
146        sudo rm -rf "$SDKDIR/SDKs/MacOSX10.4u.sdk"
147        sudo rm -rf "$SDKDIR/SDKs/MacOSX10.5u.sdk"
148        ;;
149
150esac