Skip to content

Commit

Permalink
[MERGE #3023 @obastemur] xplat: Packaging shasum check
Browse files Browse the repository at this point in the history
Merge pull request #3023 from obastemur:pkg_fix
  • Loading branch information
obastemur committed May 23, 2017
2 parents 4c0fcf1 + d768d8d commit f105d21
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 23 deletions.
28 changes: 24 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ while [[ $# -gt 0 ]]; do
VALGRIND="-DENABLE_VALGRIND_SH=1"
;;

-y | -Y)
ALWAYS_YES=1
;;

*)
echo "Unknown option $1"
PRINT_USAGE
Expand Down Expand Up @@ -375,10 +379,26 @@ if [[ ${#_VERBOSE} > 0 ]]; then
fi

# if LTO build is enabled and cc-toolchain/clang was compiled, use it instead
if [[ $HAS_LTO == 1 && -f cc-toolchain/build/bin/clang++ ]]; then
SELF=`pwd`
_CXX="$SELF/cc-toolchain/build/bin/clang++"
_CC="$SELF/cc-toolchain/build/bin/clang"
if [[ $HAS_LTO == 1 ]]; then
if [[ -f cc-toolchain/build/bin/clang++ ]]; then
SELF=`pwd`
_CXX="$CHAKRACORE_DIR/cc-toolchain/build/bin/clang++"
_CC="$CHAKRACORE_DIR/cc-toolchain/build/bin/clang"
else
# Linux LD possibly doesn't support LLVM LTO, check.. and compile clang if not
if [[ $OS_LINUX == 1 ]]; then
if [[ ! `ld -v` =~ 'GNU gold' ]]; then
$CHAKRACORE_DIR/tools/compile_clang.sh
if [[ $? != 0 ]]; then
echo -e "tools/compile_clang.sh has failed.\n"
echo "Try with 'sudo' ?"
exit 1
fi
_CXX="$CHAKRACORE_DIR/cc-toolchain/build/bin/clang++"
_CC="$CHAKRACORE_DIR/cc-toolchain/build/bin/clang"
fi
fi
fi
fi

if [ "${HAS_LTO}${OS_LINUX}" == "11" ]; then
Expand Down
70 changes: 53 additions & 17 deletions tools/XPlatInstall/install_ch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ GET_OS()
exit
}


GET_LATEST()
{
GET_OS
Expand All @@ -61,12 +60,13 @@ GET_LATEST()
CHAKRA_VERSION=$(curl -k -s -SL "https://aka.ms/chakracore/version")

if [[ "$CHAKRA_VERSION" == *"Error"* ]]; then
PRINT $ERROR_COLOR "] Download Failed. Do you have an Internet connection?"
PRINT $ERROR_COLOR "] Please ensure you are connected to the internet and try again."
exit 1
fi

PRINT $SUCCESS_COLOR "] Found ChakraCore ${CHAKRA_VERSION//_/.} for ${CURRENT_OS}"
BINARY_NAME="https://aka.ms/chakracore/${BINARY_NAME}_${CHAKRA_VERSION}.tar.gz"
BINARY_NAME="https://aka.ms/chakracore/${BINARY_NAME}_${CHAKRA_VERSION}"
SHASUM_NAME="${BINARY_NAME}_s"
}

PRINT $DEFAULT_COLOR "ChakraCore Installation Script 0.1b\n"
Expand All @@ -75,41 +75,77 @@ PRINT $DEFAULT_COLOR "Visit https://aka.ms/WhatIs/ChakraCore for more informatio
GET_LATEST

PRINT $DEFAULT_COLOR "----------------------------------------------------------------"
PRINT $SUCCESS_COLOR "\nThis script will download ChakraCore from"
PRINT $DEFAULT_COLOR "${BINARY_NAME}\n"
PRINT $SUCCESS_COLOR "\nThis script will download & execute ChakraCore binary"
PRINT $DEFAULT_COLOR "located at ${BINARY_NAME}\n"
PRINT $DEFAULT_COLOR "----------------------------------------------------------------"
PRINT $DEFAULT_COLOR "If you don't agree, press Ctrl+C to terminate"
read -t 10 -p "Hit ENTER to continue (or wait 10 seconds)"
read -t 20 -p "Hit ENTER to continue (or wait 20 seconds)"

if [ -d "./ChakraCoreFiles" ]; then
PRINT $ERROR_COLOR "] Found 'ChakraCoreFiles' folder on the current path."
PRINT $DEFAULT_COLOR "] You should delete that folder or try this script on another path"
exit 1
fi

CHECK_DOWNLOAD_FAIL()
{
if [[ $? != 0 ]]; then
PRINT $ERROR_COLOR "] Download failed."
PRINT $DEFAULT_COLOR "] ${___}"
exit 1
fi
}

PRINT $DEFAULT_COLOR "\n] Downloading ChakraCore"
PRINT $SUCCESS_COLOR "] ${BINARY_NAME}"

___=$(curl -kSL -o "chakracore.tar.gz" "${BINARY_NAME}" 2>&1)
CHECK_DOWNLOAD_FAIL

if [[ $? != 0 ]]; then
PRINT $ERROR_COLOR "] Download failed."
PRINT $DEFAULT_COLOR "] ${___}"
exit 1
fi
PRINT $DEFAULT_COLOR "\n] Downloading ChakraCore shasum"
PRINT $SUCCESS_COLOR "] ${SHASUM_NAME}"
___=$(curl -kSL -o "chakracore_s.tar.gz" "${SHASUM_NAME}" 2>&1)
CHECK_DOWNLOAD_FAIL

PRINT $SUCCESS_COLOR "] Download completed"

___=$(tar -xzf chakracore.tar.gz 2>&1)
CHECK_EXT_FAIL()
{
if [[ $? != 0 ]]; then
PRINT $ERROR_COLOR "] Extracting the compressed file failed."
PRINT $DEFAULT_COLOR "] ${___}"
rm -rf ChakraCoreFiles/
rm -rf chakracore.tar.gz
rm -rf chakracore_s.tar.gz
exit 1
fi
}

if [[ $? != 0 ]]; then
PRINT $ERROR_COLOR "] Extracting the compressed file is failed."
PRINT $DEFAULT_COLOR "] ${___}"
rm -rf ChakraCoreFiles/
___=$(tar -xzf chakracore_s.tar.gz 2>&1)
CHECK_EXT_FAIL

SUM1=`shasum -a 512256 chakracore.tar.gz`
SUM2=`cat ChakraCoreFiles/shasum`
SUM1="${SUM1}@"
SUM2="${SUM2}@"

if [[ ! $SUM1 =~ $SUM2 ]]; then
PRINT $ERROR_COLOR "] Corrupted binary package."
PRINT $DEFAULT_COLOR "] Check your network connection."
PRINT $ERROR_COLOR "] If you suspect there is some other problem,\
https://github.com/Microsoft/ChakraCore#contact-us"
rm -rf chakracore.tar.gz
rm -rf chakracore_s.tar.gz
rm -rf ChakraCoreFiles/
exit 1
fi

rm -rf chakracore_s.tar.gz

PRINT $SUCCESS_COLOR "] ChakraCore package SHASUM matches"

___=$(tar -xzf chakracore.tar.gz 2>&1)
CHECK_EXT_FAIL

rm -rf chakracore.tar.gz

# test ch
Expand Down
13 changes: 11 additions & 2 deletions tools/create_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ echo -e "\n***** Third Party Notices [ for PreBuilt Binaries ] *****\n" >> out/C
cat tools/XPlatInstall/BINARY-DIST-ONLY-NOTICES.txt >> out/ChakraCoreFiles/LICENSE
# sample
cp "tools/XPlatInstall/sample/README.md" out/ChakraCoreFiles/sample/README.md
cp "tools/XPlatInstall/sample/Makefile.txt" out/ChakraCoreFiles/sample/Makefile
cp "tools/XPlatInstall/sample/Makefile" out/ChakraCoreFiles/sample/Makefile
cp "tools/XPlatInstall/sample/sample.cpp.txt" out/ChakraCoreFiles/sample/sample.cpp

## Test
Expand All @@ -97,7 +97,16 @@ IF_ERROR_EXIT $? "CH binary test failed"
pushd out/ > /dev/null
PACKAGE_FILE="cc_${HOST_OS}_x64_${CHAKRA_VERSION}.tar.gz"
tar -czf "${PACKAGE_FILE}" ChakraCoreFiles/
mkdir -p temp/ChakraCoreFiles/
cp "${PACKAGE_FILE}" temp/chakracore.tar.gz
cd temp
SHASUM_FILE="cc_${HOST_OS}_x64_${CHAKRA_VERSION}_s.tar.gz"
shasum -a 512256 chakracore.tar.gz > ChakraCoreFiles/shasum
tar -czf "$SHASUM_FILE" ChakraCoreFiles
mv $SHASUM_FILE ../
cd ..
rm -rf temp/
popd > /dev/null

## Credits
echo -e "\nPackage file is ready at ${GREEN_COLOR}${PACKAGE_FILE}${DEFAULT_COLOR}"
echo -e "\nPackage & Shasum files are ready under ${GREEN_COLOR}out/${DEFAULT_COLOR}"

0 comments on commit f105d21

Please sign in to comment.