mulle-bootstrap-init.sh
5de2fbd6
 #! /bin/sh
 #
 #   Copyright (c) 2015 Nat! - Mulle kybernetiK
 #   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 Mulle kybernetiK 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 HOLDER 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.
 
40fe269d
 . mulle-bootstrap-local-environment.sh
5de2fbd6
 
 #
 # this script creates a .bootstrap folder with some
 # demo files.
 #
3be635de
 if [ "$1" = "-h" -o "$1" = "--help" ]
 then
40fe269d
    echo "usage: init" >&2
    exit 1
3be635de
 fi
 
5de2fbd6
 BOOTSTRAP_SUBDIR=.bootstrap
 
28ed6b30
 
 CREATE_DEFAULT_FILES="`read_config_setting "create_default_files" "YES"`"
 CREATE_EXAMPLE_FILES="`read_config_setting "create_example_files" "YES"`"
5de2fbd6
 
 
 if [ -d "${BOOTSTRAP_SUBDIR}" ]
 then
28ed6b30
    log_warning "\"${BOOTSTRAP_SUBDIR}\" already exists"
5de2fbd6
    exit 1
 fi
 
40fe269d
 main()
 {
    project=""
    for i in *.xcodeproj/project.pbxproj
    do
       if [ -f "$i" ]
       then
         if [ "$project" != "" ]
         then
28ed6b30
            fail "more than one xcodeproj found, cant' deal with it"
40fe269d
         fi
         project="$i"
       fi
    done
 
 
28ed6b30
    log_fluff "Create \"${BOOTSTRAP_SUBDIR}\""
    mkdir_if_missing "${BOOTSTRAP_SUBDIR}"
40fe269d
 
28ed6b30
    if [ "${CREATE_DEFAULT_FILES}" = "YES" ]
5de2fbd6
    then
28ed6b30
       log_fluff "Create default files"
 
40fe269d
       exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/brews"
5de2fbd6
 # add projects that should be installed by brew
 # e.g.
 # zlib
 EOF
 
 #cat <<EOF > "${BOOTSTRAP_SUBDIR}/pips"
 # add projects that should be installed by pip
 # try to avoid it, since it needs sudo (uncool)
 # mod-pbxproj
 #EOF
 
40fe269d
       exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/gits"
5de2fbd6
 # add projects that should be cloned with git in order
 # of their inter-dependencies
 #
28ed6b30
 # some possible types of repository specifications:
5de2fbd6
 # http://www.mulle-kybernetik.com/repositories/MulleScion
 # git@github.com:mulle-nat/MulleScion.git
 # ../MulleScion
 # /Volumes/Source/srcM/MulleScion
 #
 EOF
40fe269d
    fi
5de2fbd6
 
28ed6b30
    if [ "${CREATE_EXAMPLE_FILES}" = "YES" ]
40fe269d
    then
28ed6b30
      log_fluff "Create example repository settings"
 
       mkdir_if_missing "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/bin"
5de2fbd6
 
40fe269d
       exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/tag"
5de2fbd6
 # specify a tag or branch for a project named MulleScion
 # leave commented out or delete file for default branch (usually master)
 # v1848.5.p3
 EOF
 
40fe269d
       exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/Release.map"
5de2fbd6
 # map configuration Release in project MulleScion to DebugRelease
 # leave commented out or delete file for no mapping
 # DebugRelease
 EOF
 
40fe269d
       exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/project"
28ed6b30
 # Specify a xcodeproj to compile in project MulleScion instead of the default
5de2fbd6
 # leave commented out or delete file for default project
 # mulle-scion
 EOF
 
40fe269d
       exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/scheme"
28ed6b30
 # Specify a scheme to compile in project MulleScion instead of the default
5de2fbd6
 # Might bite itself with TARGET, so only specify one.
 # leave commented out or delete file for default scheme
 # mulle-scion
 EOF
 
40fe269d
       exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/target"
28ed6b30
 # Specify a target to compile in project MulleScion instead of the default.
5de2fbd6
 # Might bite itself with SCHEME, so only specify one.
 # leave commented out or delete file for default scheme
 # mulle-scion
 EOF
 
40fe269d
       exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/bin/post-install.sh"
5de2fbd6
 # Run some commands after installing project MulleScion
 # leave commented out or delete file for no action
 # chmod 755 ${BOOTSTRAP_SUBDIR}/MulleScion.example/bin/post-install.sh
 # to make it work
 # echo "1848"
 EOF
 #chmod 755 "${BOOTSTRAP_SUBDIR}/MulleScion.example/bin/post-install.sh"
 
40fe269d
       exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/bin/post-update.sh"
5de2fbd6
 # Run some commands after upgrading project MulleScion
 # leave commented out or delete file for no action
 # chmod 755 ${BOOTSTRAP_SUBDIR}/MulleScion.example/bin/post-update.sh
 # to make it work
 # echo "1848"
 EOF
 #chmod 755 "${BOOTSTRAP_SUBDIR}/MulleScion.example/bin/post-upgrade.sh"
 
28ed6b30
   fi
5de2fbd6
 
28ed6b30
   log_info "${BOOTSTRAP_SUBDIR} folder has been set up. Now add your gits to ${BOOTSTRAP_SUBDIR}/gits"
5de2fbd6
 
28ed6b30
   local open
 
   open="`read_config_setting "open_gits_file" "ASK"`"
   if [ "${open}" = "ASK" ]
   then
     user_say_yes "Edit the \"gits\" file now ?"
     if [ $? -eq 0 ]
     then
        open="YES"
     fi
   fi
 
   if [ "${open}" = "YES" ]
   then
      local editor
 
      editor="`read_config_setting "editor" "${EDITOR:-vi}"`"
      exekutor $editor "${BOOTSTRAP_SUBDIR}/gits"
   fi
40fe269d
 }
5de2fbd6
 
40fe269d
 main "$@"