update msys packaging scripts (#332)

- make it machine-independent
- simplify 7z package
- fail fast
This commit is contained in:
Cyano Hao 2024-03-28 15:01:37 +08:00 committed by GitHub
parent 63b31ddda6
commit b6eed0a00f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 216 additions and 127 deletions

View File

@ -1,30 +1,91 @@
#!/bin/bash #!/bin/bash
TARGET_DIR="/r/" set -euxo pipefail
BUILD_DIR="${TEMP}/redpandacpp-build"
PACKAGE_DIR="${TEMP}/RedPanda-CPP"
GCC_DIR="/mingw32"
PATH="${GCC_DIR}/bin:${PATH}"
QMAKE="${GCC_DIR}/qt5-static/bin/qmake"
NSIS="/d/Program Files (x86)/NSIS/bin/makensis.exe"
SOURCE_DIR=`pwd`
MINGW="/e/Workspaces/contributes/MinGW/MinGW32"
MINGW_NAME="MinGW32"
rm -rf "${BUILD_DIR}" # Usage:
test -z "${BUILD_DIR}" | mkdir "${BUILD_DIR}" # packages/msys/build-i686.sh [-c|--clean] [-nd|--no-deps] [-t|--target-dir <dir>]
rm -rf "${PACKAGE_DIR}"
mkdir "${PACKAGE_DIR}"
echo "Building..." if [[ ! -v MSYSTEM || ${MSYSTEM} != "MINGW32" ]]; then
echo "This script must be run in a MinGW32 shell"
exit 1
fi
CLEAN=0
CHECK_DEPS=1
TARGET_DIR="$(pwd)/dist"
while [[ $# -gt 0 ]]; do
case $1 in
-c|--clean)
CLEAN=1
shift
;;
-nd|--no-deps)
CHECK_DEPS=0
shift
;;
-t|--target-dir)
TARGET_DIR="$2"
shift 2
;;
*)
echo "Unknown argument: $1"
exit 1
;;
esac
done
BUILD_DIR="${TEMP}/redpanda-mingw-${MSYSTEM}-build"
PACKAGE_DIR="${TEMP}/redpanda-mingw-${MSYSTEM}-pkg"
QMAKE="${MINGW_PREFIX}/qt5-static/bin/qmake"
NSIS="/mingw32/bin/makensis"
SOURCE_DIR="$(pwd)"
MINGW_ARCHIVE="mingw32.7z"
function fn_print_progress() {
echo -e "\e[1;32;44m$1\e[0m"
}
## check deps
if [[ ${CHECK_DEPS} -eq 1 ]]; then
deps=(
${MINGW_PACKAGE_PREFIX}-{gcc,make,qt5-static,7zip}
mingw-w64-i686-nsis
git
)
for dep in ${deps[@]}; do
pacman -Q ${dep} &>/dev/null || {
echo "Missing dependency: ${dep}"
exit 1
}
done
fi
if [[ ! -f "${SOURCE_DIR}/assets/${MINGW_ARCHIVE}" ]]; then
echo "Missing ${MINGW_ARCHIVE}"
exit 1
fi
## prepare dirs
if [[ ${CLEAN} -eq 1 ]]; then
rm -rf "${BUILD_DIR}"
rm -rf "${PACKAGE_DIR}"
fi
mkdir -p "${BUILD_DIR}" "${PACKAGE_DIR}" "${TARGET_DIR}"
## build
fn_print_progress "Building..."
pushd . pushd .
cd "${BUILD_DIR}" cd "${BUILD_DIR}"
make distclean
"$QMAKE" PREFIX="${PACKAGE_DIR}" -o Makefile "${SOURCE_DIR}\Red_Panda_Cpp.pro" -r -spec win32-g++ "$QMAKE" PREFIX="${PACKAGE_DIR}" -o Makefile "${SOURCE_DIR}\Red_Panda_Cpp.pro" -r -spec win32-g++
make -j16 mingw32-make -j$(nproc)
make install mingw32-make install
popd popd
## prepare packaging resources
echo "Making no-compiler installer ..." echo "Making no-compiler installer ..."
pushd . pushd .
cd "${PACKAGE_DIR}" cd "${PACKAGE_DIR}"
@ -33,59 +94,45 @@ cp "${SOURCE_DIR}/platform/windows/qt.conf" .
cp "${SOURCE_DIR}/platform/windows/installer-scripts/lang.nsh" . cp "${SOURCE_DIR}/platform/windows/installer-scripts/lang.nsh" .
cp "${SOURCE_DIR}/platform/windows/installer-scripts/redpanda-i686-nocompiler.nsi" . cp "${SOURCE_DIR}/platform/windows/installer-scripts/redpanda-i686-nocompiler.nsi" .
cp "${SOURCE_DIR}/platform/windows/installer-scripts/redpanda-i686.nsi" .
"${NSIS}" redpanda-i686-nocompiler.nsi
rm -f lang.nsh
rm -f config32.nsh
rm -f config.nsh
rm -f config-clang.nsh
rm -f redpanda-i686-nocompiler.nsi
SETUP_NAME=`ls *.Setup.exe`
PORTABLE_NAME=`echo $SETUP_NAME | sed 's/Setup.exe/Portable.7z/'`
mv "$SETUP_NAME" "${TARGET_DIR}"
popd popd
pushd . ## make no-compiler package
cd "${TARGET_DIR}"
echo "Making no-compiler Portable Package..."
7z a -mmt8 -mx9 "${PORTABLE_NAME}" "${PACKAGE_DIR}"
popd
# we need reinstall config32.nsh
pushd .
cd "${BUILD_DIR}"
make install
popd
echo "Making installer..."
pushd . pushd .
cd "${PACKAGE_DIR}" cd "${PACKAGE_DIR}"
ln -s "${MINGW}" $MinGW_NAME fn_print_progress "Making no-compiler installer ..."
"${NSIS}" redpanda-i686-nocompiler.nsi
cp "${SOURCE_DIR}/platform/windows/installer-scripts/lang.nsh" . SETUP_NAME="$(ls *.Setup.exe)"
cp "${SOURCE_DIR}/platform/windows/installer-scripts/redpanda-i686.nsi" . PORTABLE_NAME="$(echo $SETUP_NAME | sed 's/Setup.exe/Portable.7z/')"
"${NSIS}" redpanda-i686.nsi fn_print_progress "Making no-compiler Portable Package..."
rm -f lang.nsh 7z x "${SETUP_NAME}" -o"RedPanda-CPP" -xr'!$PLUGINSDIR' -x"!uninstall.exe"
rm -f config32.nsh 7z a -mmt -mx9 -ms=on -mqs=on -mf=BCJ2 "${PORTABLE_NAME}" "RedPanda-CPP"
rm -f config.nsh rm -rf "RedPanda-CPP"
rm -f config-clang.nsh
rm -f redpanda-i686.nsi
SETUP_NAME=`ls *.Setup.exe`
PORTABLE_NAME=`echo $SETUP_NAME | sed 's/Setup.exe/Portable.7z/'`
mv "$SETUP_NAME" "${TARGET_DIR}"
mv "${SETUP_NAME}" "${TARGET_DIR}"
mv "${PORTABLE_NAME}" "${TARGET_DIR}"
popd popd
## make mingw package
pushd . pushd .
cd "${TARGET_DIR}" cd "${PACKAGE_DIR}"
echo "Making Portable Package..." fn_print_progress "Making installer..."
7z a -mmt8 -mx9 "${PORTABLE_NAME}" "${PACKAGE_DIR}" [[ ! -d mingw32 ]] && 7z x "${SOURCE_DIR}/assets/${MINGW_ARCHIVE}" -o"${PACKAGE_DIR}"
"${NSIS}" redpanda-i686.nsi
SETUP_NAME="$(ls *.Setup.exe)"
PORTABLE_NAME="$(echo $SETUP_NAME | sed 's/Setup.exe/Portable.7z/')"
fn_print_progress "Making Portable Package..."
7z x "${SETUP_NAME}" -o"RedPanda-CPP" -xr'!$PLUGINSDIR' -x"!uninstall.exe"
7z a -mmt -mx9 -ms=on -mqs=on -mf=BCJ2 "${PORTABLE_NAME}" "RedPanda-CPP"
rm -rf "RedPanda-CPP"
mv "${SETUP_NAME}" "${TARGET_DIR}"
mv "${PORTABLE_NAME}" "${TARGET_DIR}"
popd popd
echo "Clean up..."
rm -rf "${PACKAGE_DIR}"

View File

@ -1,31 +1,91 @@
#!/bin/bash #!/bin/bash
TARGET_DIR="/r/" set -euxo pipefail
BUILD_DIR="${TEMP}/redpandacpp-build"
PACKAGE_DIR="${TEMP}/RedPanda-CPP"
GCC_DIR="/mingw64"
PATH="${GCC_DIR}/bin:${PATH}"
QMAKE="${GCC_DIR}/qt5-static/bin/qmake"
NSIS="/d/Program Files (x86)/NSIS/bin/makensis.exe"
SOURCE_DIR=`pwd`
MINGW="/e/Workspaces/contributes/MinGW/MinGW64"
MINGW_NAME="MinGW64"
rm -rf "${BUILD_DIR}" # Usage:
test -z "${BUILD_DIR}" | mkdir "${BUILD_DIR}" # packages/msys/build-x64.sh [-c|--clean] [-nd|--no-deps] [-t|--target-dir <dir>]
rm -rf "${PACKAGE_DIR}"
mkdir "${PACKAGE_DIR}"
echo "Building..." if [[ ! -v MSYSTEM || ( ${MSYSTEM} != "MINGW64" && ${MSYSTEM} != "UCRT64" ) ]]; then
echo "This script must be run in a MinGW64 or UCRT64 shell"
exit 1
fi
CLEAN=0
CHECK_DEPS=1
TARGET_DIR="$(pwd)/dist"
while [[ $# -gt 0 ]]; do
case $1 in
-c|--clean)
CLEAN=1
shift
;;
-nd|--no-deps)
CHECK_DEPS=0
shift
;;
-t|--target-dir)
TARGET_DIR="$2"
shift 2
;;
*)
echo "Unknown argument: $1"
exit 1
;;
esac
done
BUILD_DIR="${TEMP}/redpanda-mingw-${MSYSTEM}-build"
PACKAGE_DIR="${TEMP}/redpanda-mingw-${MSYSTEM}-pkg"
QMAKE="${MINGW_PREFIX}/qt5-static/bin/qmake"
NSIS="/mingw32/bin/makensis"
SOURCE_DIR="$(pwd)"
MINGW_ARCHIVE="mingw64.7z"
function fn_print_progress() {
echo -e "\e[1;32;44m$1\e[0m"
}
## check deps
if [[ ${CHECK_DEPS} -eq 1 ]]; then
deps=(
${MINGW_PACKAGE_PREFIX}-{gcc,make,qt5-static,7zip}
mingw-w64-i686-nsis
git
)
for dep in ${deps[@]}; do
pacman -Q ${dep} &>/dev/null || {
echo "Missing dependency: ${dep}"
exit 1
}
done
fi
if [[ ! -f "${SOURCE_DIR}/assets/${MINGW_ARCHIVE}" ]]; then
echo "Missing MinGW archive: assets/${MINGW_ARCHIVE}"
exit 1
fi
## prepare dirs
if [[ ${CLEAN} -eq 1 ]]; then
rm -rf "${BUILD_DIR}"
rm -rf "${PACKAGE_DIR}"
fi
mkdir -p "${BUILD_DIR}" "${PACKAGE_DIR}" "${TARGET_DIR}"
## build
fn_print_progress "Building..."
pushd . pushd .
cd "${BUILD_DIR}" cd "${BUILD_DIR}"
make distclean "$QMAKE" PREFIX="${PACKAGE_DIR}" X86_64=ON -o Makefile "${SOURCE_DIR}/Red_Panda_Cpp.pro" -r -spec win32-g++
"$QMAKE" PREFIX="${PACKAGE_DIR}" X86_64=ON -o Makefile "${SOURCE_DIR}\Red_Panda_Cpp.pro" -r -spec win32-g++ mingw32-make -j$(nproc)
make -j16 mingw32-make install
make install
popd popd
echo "Making no-compiler installer ..." ## prepare packaging resources
pushd . pushd .
cd "${PACKAGE_DIR}" cd "${PACKAGE_DIR}"
@ -33,63 +93,45 @@ cp "${SOURCE_DIR}/platform/windows/qt.conf" .
cp "${SOURCE_DIR}/platform/windows/installer-scripts/lang.nsh" . cp "${SOURCE_DIR}/platform/windows/installer-scripts/lang.nsh" .
cp "${SOURCE_DIR}/platform/windows/installer-scripts/redpanda-nocompiler.nsi" . cp "${SOURCE_DIR}/platform/windows/installer-scripts/redpanda-nocompiler.nsi" .
cp "${SOURCE_DIR}/platform/windows/installer-scripts/redpanda-x64.nsi" .
"${NSIS}" redpanda-nocompiler.nsi
rm -f lang.nsh
rm -f config.nsh
rm -f config32.nsh
rm -f config-clang.nsh
rm -f redpanda-nocompiler.nsi
SETUP_NAME=`ls *.Setup.exe`
PORTABLE_NAME=`echo $SETUP_NAME | sed 's/Setup.exe/Portable.7z/'`
mv "$SETUP_NAME" "${TARGET_DIR}"
popd popd
pushd . ## make no-compiler package
cd "${TARGET_DIR}"
echo "Making no-compiler Portable Package..."
7z a -mmt8 -mx9 "${PORTABLE_NAME}" "${PACKAGE_DIR}"
popd
# we need reinstall config.nsh
pushd .
cd "${BUILD_DIR}"
make install
popd
echo "Making installer..."
pushd . pushd .
cd "${PACKAGE_DIR}" cd "${PACKAGE_DIR}"
cp -a "${MINGW}" . fn_print_progress "Making no-compiler installer ..."
#rm -rf "${MINGW_NAME}/share/gcc-11.2.0" "${NSIS}" redpanda-nocompiler.nsi
#cp -a "${SOURCE_DIR}/tools/gdb-scripts/gcc-11.2.0" "${MINGW_NAME}/share"
cp "${SOURCE_DIR}/platform/windows/installer-scripts/lang.nsh" . SETUP_NAME="$(ls *.Setup.exe)"
cp "${SOURCE_DIR}/platform/windows/installer-scripts/redpanda-x64.nsi" . PORTABLE_NAME="$(echo $SETUP_NAME | sed 's/Setup.exe/Portable.7z/')"
"${NSIS}" redpanda-x64.nsi fn_print_progress "Making no-compiler Portable Package..."
rm -f lang.nsh 7z x "${SETUP_NAME}" -o"RedPanda-CPP" -xr'!$PLUGINSDIR' -x"!uninstall.exe"
rm -f config.nsh 7z a -mmt -mx9 -ms=on -mqs=on -mf=BCJ2 "${PORTABLE_NAME}" "RedPanda-CPP"
rm -f config32.nsh rm -rf "RedPanda-CPP"
rm -f config-clang.nsh
rm -f redpanda-x64.nsi
SETUP_NAME=`ls *.Setup.exe`
PORTABLE_NAME=`echo $SETUP_NAME | sed 's/Setup.exe/Portable.7z/'`
mv "$SETUP_NAME" "${TARGET_DIR}"
mv "${SETUP_NAME}" "${TARGET_DIR}"
mv "${PORTABLE_NAME}" "${TARGET_DIR}"
popd popd
## make mingw package
pushd . pushd .
cd "${PACKAGE_DIR}"
fn_print_progress "Making installer..."
[[ ! -d mingw64 ]] && 7z x "${SOURCE_DIR}/assets/${MINGW_ARCHIVE}" -o"${PACKAGE_DIR}"
cd "${TARGET_DIR}" "${NSIS}" redpanda-x64.nsi
echo "Making Portable Package..."
7z a -mmt8 -mx9 "${PORTABLE_NAME}" "${PACKAGE_DIR}"
echo "Clean up..." SETUP_NAME="$(ls *.Setup.exe)"
rm -rf "${PACKAGE_DIR}" PORTABLE_NAME="$(echo $SETUP_NAME | sed 's/Setup.exe/Portable.7z/')"
fn_print_progress "Making Portable Package..."
7z x "${SETUP_NAME}" -o"RedPanda-CPP" -xr'!$PLUGINSDIR' -x"!uninstall.exe"
7z a -mmt -mx9 -ms=on -mqs=on -mf=BCJ2 "${PORTABLE_NAME}" "RedPanda-CPP"
rm -rf "RedPanda-CPP"
mv "${SETUP_NAME}" "${TARGET_DIR}"
mv "${PORTABLE_NAME}" "${TARGET_DIR}"
popd popd