この比較の残りの部分を読み込んでいます。

Untitled diff

作成日 差分は期限切れになりません
3 削除
595 行
3 追加
595 行
#!/bin/bash
#!/bin/bash
# Patch apllying tool template
# Patch apllying tool template
# v0.1.2
# v0.1.2
# (c) Copyright 2013. Magento Inc.
# (c) Copyright 2013. Magento Inc.
#
#
# DO NOT CHANGE ANY LINE IN THIS FILE.
# DO NOT CHANGE ANY LINE IN THIS FILE.


# 1. Check required system tools
# 1. Check required system tools
_check_installed_tools() {
_check_installed_tools() {
local missed=""
local missed=""


until [ -z "$1" ]; do
until [ -z "$1" ]; do
type -t $1 >/dev/null 2>/dev/null
type -t $1 >/dev/null 2>/dev/null
if (( $? != 0 )); then
if (( $? != 0 )); then
missed="$missed $1"
missed="$missed $1"
fi
fi
shift
shift
done
done


echo $missed
echo $missed
}
}


REQUIRED_UTILS='sed patch'
REQUIRED_UTILS='sed patch'
MISSED_REQUIRED_TOOLS=`_check_installed_tools $REQUIRED_UTILS`
MISSED_REQUIRED_TOOLS=`_check_installed_tools $REQUIRED_UTILS`
if (( `echo $MISSED_REQUIRED_TOOLS | wc -w` > 0 ));
if (( `echo $MISSED_REQUIRED_TOOLS | wc -w` > 0 ));
then
then
echo -e "Error! Some required system tools, that are utilized in this sh script, are not installed:\nTool(s) \"$MISSED_REQUIRED_TOOLS\" is(are) missed, please install it(them)."
echo -e "Error! Some required system tools, that are utilized in this sh script, are not installed:\nTool(s) \"$MISSED_REQUIRED_TOOLS\" is(are) missed, please install it(them)."
exit 1
exit 1
fi
fi


# 2. Determine bin path for system tools
# 2. Determine bin path for system tools
CAT_BIN=`which cat`
CAT_BIN=`which cat`
PATCH_BIN=`which patch`
PATCH_BIN=`which patch`
SED_BIN=`which sed`
SED_BIN=`which sed`
PWD_BIN=`which pwd`
PWD_BIN=`which pwd`
BASENAME_BIN=`which basename`
BASENAME_BIN=`which basename`


BASE_NAME=`$BASENAME_BIN "$0"`
BASE_NAME=`$BASENAME_BIN "$0"`


# 3. Help menu
# 3. Help menu
if [ "$1" = "-?" -o "$1" = "-h" -o "$1" = "--help" ]
if [ "$1" = "-?" -o "$1" = "-h" -o "$1" = "--help" ]
then
then
$CAT_BIN << EOFH
$CAT_BIN << EOFH
Usage: sh $BASE_NAME [--help] [-R|--revert] [--list]
Usage: sh $BASE_NAME [--help] [-R|--revert] [--list]
Apply embedded patch.
Apply embedded patch.


-R, --revert Revert previously applied embedded patch
-R, --revert Revert previously applied embedded patch
--list Show list of applied patches
--list Show list of applied patches
--help Show this help message
--help Show this help message
EOFH
EOFH
exit 0
exit 0
fi
fi


# 4. Get "revert" flag and "list applied patches" flag
# 4. Get "revert" flag and "list applied patches" flag
REVERT_FLAG=
REVERT_FLAG=
SHOW_APPLIED_LIST=0
SHOW_APPLIED_LIST=0
if [ "$1" = "-R" -o "$1" = "--revert" ]
if [ "$1" = "-R" -o "$1" = "--revert" ]
then
then
REVERT_FLAG=-R
REVERT_FLAG=-R
fi
fi
if [ "$1" = "--list" ]
if [ "$1" = "--list" ]
then
then
SHOW_APPLIED_LIST=1
SHOW_APPLIED_LIST=1
fi
fi


# 5. File pathes
# 5. File pathes
CURRENT_DIR=`$PWD_BIN`/
CURRENT_DIR=`$PWD_BIN`/
APP_ETC_DIR=`echo "$CURRENT_DIR""app/etc/"`
APP_ETC_DIR=`echo "$CURRENT_DIR""app/etc/"`
APPLIED_PATCHES_LIST_FILE=`echo "$APP_ETC_DIR""applied.patches.list"`
APPLIED_PATCHES_LIST_FILE=`echo "$APP_ETC_DIR""applied.patches.list"`


# 6. Show applied patches list if requested
# 6. Show applied patches list if requested
if [ "$SHOW_APPLIED_LIST" -eq 1 ] ; then
if [ "$SHOW_APPLIED_LIST" -eq 1 ] ; then
echo -e "Applied/reverted patches list:"
echo -e "Applied/reverted patches list:"
if [ -e "$APPLIED_PATCHES_LIST_FILE" ]
if [ -e "$APPLIED_PATCHES_LIST_FILE" ]
then
then
if [ ! -r "$APPLIED_PATCHES_LIST_FILE" ]
if [ ! -r "$APPLIED_PATCHES_LIST_FILE" ]
then
then
echo "ERROR: \"$APPLIED_PATCHES_LIST_FILE\" must be readable so applied patches list can be shown."
echo "ERROR: \"$APPLIED_PATCHES_LIST_FILE\" must be readable so applied patches list can be shown."
exit 1
exit 1
else
else
$SED_BIN -n "/SUP-\|SUPEE-/p" $APPLIED_PATCHES_LIST_FILE
$SED_BIN -n "/SUP-\|SUPEE-/p" $APPLIED_PATCHES_LIST_FILE
fi
fi
else
else
echo "<empty>"
echo "<empty>"
fi
fi
exit 0
exit 0
fi
fi


# 7. Check applied patches track file and its directory
# 7. Check applied patches track file and its directory
_check_files() {
_check_files() {
if [ ! -e "$APP_ETC_DIR" ]
if [ ! -e "$APP_ETC_DIR" ]
then
then
echo "ERROR: \"$APP_ETC_DIR\" must exist for proper tool work."
echo "ERROR: \"$APP_ETC_DIR\" must exist for proper tool work."
exit 1
exit 1
fi
fi


if [ ! -w "$APP_ETC_DIR" ]
if [ ! -w "$APP_ETC_DIR" ]
then
then
echo "ERROR: \"$APP_ETC_DIR\" must be writeable for proper tool work."
echo "ERROR: \"$APP_ETC_DIR\" must be writeable for proper tool work."
exit 1
exit 1