source: ocsinventory-agent/trunk/fuentes/tools/macosx/BUILDME.sh @ 468

Last change on this file since 468 was 468, checked in by mabarracus, 4 years ago

Copyt trusty code

  • Property svn:executable set to *
File size: 3.9 KB
Line 
1#!/bin/bash
2
3#Use this script to build OCS Inventory NG MacOSX agent
4#Run 'sh BUILDME.sh -release' to build official released agent
5
6
7OCSNG_PATH="OCSNG.app"
8PATCHES_PATH="patches"
9TOOLS_PATH="tools/macosx"
10FINAL_PKG_NAME="unified_unix_agent-macosx"
11
12if [ "$1" == "-release" ]; then
13        RELEASE=1 
14fi
15
16if [ ! -x ../../inc ]; then
17        echo "You're probably building from BZR, you're missing the "inc" directory in ../../"
18        exit 1;
19fi
20
21if [ ! -x ./darwin-perl-lib ]; then
22        if [ ! -e ./scripts/macosx-perl-lib-dep-snapshot.tar.gz ]; then
23                echo "You're missing the darwin-perl-lib directory, did you run the create-darwin-perl-lib_fromCPAN.pl script?"
24                exit 1;
25        else
26                echo 'extracting from snapshot perl-lib deps to ./'
27                tar -zxvf ./scripts/macosx-perl-lib-dep-snapshot.tar.gz
28        fi
29fi
30
31if [ -x $OCSNG_PATH ]; then
32        echo "removing old $OCSNG_PATH"
33        sudo rm -R -f $OCSNG_PATH
34fi
35
36if [ -x package-root ]; then
37        echo 'removing old package-root'
38        sudo rm -R -f package-root
39fi
40
41echo "Building OS X App"
42cd ocsng_app-xcode/
43xcodebuild -alltargets
44cp ./build/UninstalledProducts/ocscontact ./build/UninstalledProducts/OCSNG.app/Contents/Resources
45cp -R ./build/UninstalledProducts/OCSNG.app ../
46xcodebuild clean
47cd ../
48mkdir $OCSNG_PATH/Contents/Resources/lib
49
50echo "Creating default config"
51cp ../../etc/ocsinventory-agent/modules.conf ./modules.conf
52
53echo "server=http://ocsinventory-ng/ocsinventory" > ./ocsinventory-agent.cfg
54echo "tag=DEFAULT" >> ./ocsinventory-agent.cfg
55echo "logfile=/var/log/ocsng.log" >> ./ocsinventory-agent.cfg
56
57echo 'Touching cacert.pem'
58echo "Make sure you replace me with your real cacert.pem" > cacert.pem
59
60echo "Buidling unified source"
61cd ../../
62
63echo 'removing non-MacOS/Generic backend modules'
64cd ./lib/Ocsinventory/Agent/Backend/OS/
65rm -R -f `ls -l | grep -v MacOS | grep -v CVS | grep -v Generic`
66cd ../../../../../
67
68echo "Building Makefile.pl...."
69perl Makefile.PL
70make
71cp -R blib/lib ./$TOOLS_PATH/$OCSNG_PATH/Contents/Resources
72cp ocsinventory-agent ./$TOOLS_PATH/
73make clean
74
75echo 'patching main perl script for OSX'
76cd ./$TOOLS_PATH/
77patch -N ./ocsinventory-agent ./$PATCHES_PATH/ocsinventory-agent-darwin.patch
78cp ocsinventory-agent $OCSNG_PATH/Contents/Resources/
79
80echo 'copying down darwin-dep libs'
81cp -R darwin-perl-lib/ $OCSNG_PATH/Contents/Resources/lib/
82
83echo 'copying uninstall script'
84cp scripts/uninstaller.sh $OCSNG_PATH/Contents/Resources/
85
86#Only for custom agent
87if [ ! "$RELEASE" == 1 ]; then
88        echo 'creating package-root for building .pkg under'
89        mkdir -p ./package-root/Applications
90       
91        echo 'copying .app to package-root'
92        sudo cp -R $OCSNG_PATH ./package-root/Applications/
93
94        echo 'setting default permissions on ./package-root/Applications'
95        sudo chown root:admin ./package-root/Applications
96        sudo chmod 775 ./package-root/Applications
97
98        # package maker might spit out some permissions errors if the app or it's folders are on your system already, this is usually OK, read them to make sure
99        echo "building package"
100        sudo rm -R -f ./OCSNG.pkg
101        sudo /Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker -build -proj OCSNG.pmproj -p ./OCSNG.pkg
102
103        FILES="ocsinventory-agent README INSTALL launchfiles OCSNG.pkg scripts ocsinventory-agent.cfg modules.conf cacert.pem"
104
105        mkdir $FINAL_PKG_NAME
106        cp -R $FILES $FINAL_PKG_NAME/
107        zip -r $FINAL_PKG_NAME $FINAL_PKG_NAME/ -x \*CVS\* -x \*svn\*
108        rm -R -f $FINAL_PKG_NAME
109
110else
111        if [ ! -d ./installer_gui/iceberg/plugins ]; then
112                mkdir ./installer_gui/iceberg/plugins/
113        fi
114
115        cd ./installer_gui/ocs_agent_config/
116        xcodebuild -alltargets
117        cp -R ./build/Release/ocs_agent_config.bundle ../iceberg/plugins/
118        xcodebuild clean
119        cd ../ocs_agent_daemon_options/
120        xcodebuild -alltargets
121        cp -R ./build/Release/ocs_agent_daemon_options.bundle ../iceberg/plugins/
122        xcodebuild clean
123        cd ../../
124        cp ./scripts/installer.sh installer_gui/iceberg/scripts/
125
126        echo "moving $OCSNG_PATH...enter your password if needed"       
127        sudo mv $OCSNG_PATH ./installer_gui/iceberg/
128
129        echo 'Now you can build final gui installer using iceberg'
130fi 
131
132echo "done"
Note: See TracBrowser for help on using the repository browser.