Create_release.sh 0.1
A short shell script, based partly on a script that I have been noodling with for a while and partly on ideas from James Duncan Davidson <http://duncandavidson.com/archives/664>. Use this in a shell script build target that depends on your main build target. Still very rough, needs lots of work.
Size 5.9 kB - File type text/x-shFile contents
# Copyright (c) 2007 ps Enable, Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # Neither the name of the site ps-enable.com nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # This script assumes that you are releasing a drag-into-/Applications package # or have the freeware Iceberg package creation tool installed. It is intended # for use as a shells script step in XCode and thus does not have a #!/bin/sh # at the top. # If you want to create a package, create a subfolder in the top-level project folder # called "Packaging" before running the script. In there, create an Iceberg # .packproj file along with any other files associated with the package (e.g., # postinstall, preflight, etc.). # NOTE (FIXME): There doesn't seem to be any way to propagate the version number # into the Iceberg package project. You will need to adjust it manually for now. # NOTE (FIXME): Check for and build Leopard PackageMaker projects as well. Check on how # to propagate the version number into a PackageMaker project as well. Some other # language (Python, Perl, Ruby?) may be necessary. # Set these variables in your project's xcconfig file # Idea from James Duncan Davidson <http://duncandavidson.com/> # NOTE (FIXME): Need to incorporate a sequential build number as well as the "labeling" # release number, to disambiguate potential pitfalls. # MYAPP_VERSION = release version # SHIP_PRODUCT_NAME = MyApp.app - allows flexibility in what to ship on the DMG # CREATE_SOURCE_TGZ="true" if you want to include the project source in the release # SERVER_LOCATION="hostname.example.com:/Path/to/folder" if you want to auto upload the DMG # set some variables based on the project name, version, and build style # Location of the directory where we will build the disk image contents DMGDIR="$TARGET_TEMP_DIR"/"$PROJECT_NAME $MYAPP_VERSION" # Location of the target disk image file itself DMGPATH="$TARGET_BUILD_DIR"/"$PROJECT_NAME $MYAPP_VERSION".dmg # location of binaries FREEZE="/usr/local/bin/freeze" RM="/bin/rm" MKDIR="/bin/mkdir" MV="/bin/mv" LS="/bin/ls" CP="/bin/cp" DITTO="/usr/bin/ditto" GNUTAR="/usr/bin/gnutar" HDIUTIL="/usr/bin/hdiutil" SCP="/usr/bin/scp" # Only do this if the build style is Release # This prevents link problems in the final product # Idea from James Duncan Davidson <http://duncandavidson.com/> if [ "Release" != "$CONFIGURATION" ]; then echo 'error: Package creation only works for Release builds' exit -1 fi # clean up the dmg path if it exists if [ -e "$DMGDIR" ]; then "$RM" -rf "$DMGDIR" fi # create the disk image root if needed if [ ! -e "$DMGDIR" ]; then "$MKDIR" -p "$DMGDIR" fi # NOTE (FIXME): Need to be able to handle more than one installer package build. # if an Iceberg package project exists, build the package if `"$LS" "$SRCROOT/Packaging/$PROJECT_NAME".packproj > /dev/null 2>&1`; then # run the /usr/local/bin/freeze tool to build the Iceberg project "$FREEZE" -v -d "$TARGET_TEMP_DIR" "$SRCROOT"/Packaging/"$PROJECT_NAME".packproj # move the resulting package into the packaging root to build the .dmg "$MV" "$SRCROOT"/Packaging/build/"$PROJECT_NAME".pkg "$DMGDIR"/ else # Not a package installer, so copy the built result into the DMG temp folder "$DITTO" "$TARGET_BUILD_DIR"/"$SHIP_PRODUCT_NAME" "$DMGDIR"/"$SHIP_PRODUCT_NAME" fi # NOTE (FIXME): Set up something more elegant to handle more complete docs, rtfd's, # other types of files or packages # copy the ReadMe file to the DMG dir if [ -e "$SRCROOT"/Packaging/ReadMe.rtf ]; then "$CP" "$SRCROOT"/Packaging/ReadMe.rtf "$DMGDIR"/ fi # copy the LICENSE.txt file to the DMG dir if [ -e "$SRCROOT"/Packaging/License.rtf ]; then "$CP" "$SRCROOT"/Packaging/License.rtf "$DMGDIR"/ fi # create a clean copy of the sources if the flag is set in xcconfig file # have to do this outside the source tree to prevent infinite recursion if [ "true" == "$CREATE_SOURCE_TGZ" ]; then "$DITTO" "$SRCROOT" /tmp/"$PROJECT_NAME" "$RM" -rf /tmp/"$PROJECT_NAME"/build "$RM" -rf /tmp/"$PROJECT_NAME"/"testing folder" cd /tmp "$GNUTAR" zcf "$DMGDIR"/"$PROJECT_NAME.src.tgz" "$PROJECT_NAME" "$RM" -rf /tmp/"$PROJECT_NAME" fi # clean out the old disk image if [ -e "$DMGPATH" ]; then "$RM" "$DMGPATH" fi # create the disk image "$HDIUTIL" create -srcfolder "$DMGDIR" "$DMGPATH" # copy the disk image up to the deployment server if it is specified # Use scp for now # add other methods (curl, etc.) later # this assumes that you have an ssh identity key pair set up so that you don't need # to type a password to use scp # Idea from James Duncan Davidson <http://duncandavidson.com/> if [ -n "$SERVER_LOCATION" ]; then "$SCP" "$DMGPATH" "$SERVER_LOCATION" fi
Click here to get the file