Commit a033b119 authored by Jondy Zhao's avatar Jondy Zhao

refine slapos-build-installer

parent 82a77cbd
...@@ -510,6 +510,8 @@ Then upload the source packages dist/psutil-1.0.1.tar.gz to http://www.nexedi.or ...@@ -510,6 +510,8 @@ Then upload the source packages dist/psutil-1.0.1.tar.gz to http://www.nexedi.or
<para>This chapter descripts how to create a slapos node in the windows which used to test the windows installer self: <para>This chapter descripts how to create a slapos node in the windows which used to test the windows installer self:
<itemizedlist> <itemizedlist>
<listitem><para>Install cygwin</para></listitem> <listitem><para>Install cygwin</para></listitem>
<listitem><para>Install Microsoft Visual C++ 2008 Express Edition or later version. If you're running X64 environments, install Microsoft Windows SDK v7.0 either.</para></listitem>
<listitem><para>Install inno-setup, copy all binary files to /opt/inno-setup</para></listitem>
<listitem><para>Prepare certificate, key, computer.key, computer.crt</para></listitem> <listitem><para>Prepare certificate, key, computer.key, computer.crt</para></listitem>
<listitem><para>Run slapos-cygwin-bootstrap.sh, got it from slapos.package.git/windows/scripts</para></listitem> <listitem><para>Run slapos-cygwin-bootstrap.sh, got it from slapos.package.git/windows/scripts</para></listitem>
<listitem><para>Run slapos-configure.sh, got it from slapos.package.git/windows/scripts</para></listitem> <listitem><para>Run slapos-configure.sh, got it from slapos.package.git/windows/scripts</para></listitem>
......
...@@ -8,74 +8,71 @@ if ! source /usr/share/csih/cygwin-service-installation-helper.sh ; then ...@@ -8,74 +8,71 @@ if ! source /usr/share/csih/cygwin-service-installation-helper.sh ; then
exit 1 exit 1
fi fi
function show_usage() # ======================================================================
# Functions
# ======================================================================
function slapos_apply_patch()
{ {
echo "This script is used to build slapos node in the Cygwin." local _filename=$1
echo "" local _destpath=$2
echo "Usage: ./build-slapos.sh" local _basename=$(basename ${_filename})
echo ""
[[ -f ${_filename} ]] ||
cp /opt/git/slapos.package/windows/patches/${_basename} ${_filename} 2>/dev/null ||
wget -c http://git.erp5.org/gitweb/slapos.package.git/blob_plain/heads/cygwin:/windows/patches/${_basename} -O ${_filename} ||
csih_error "download ${_filename} failed"
csih_inform "download ${_filename} OK"
csih_inform "applay patch ${_filename}"
(cd $(ls -d ${_destpath}) &&
csih_inform "patch at $(pwd)" &&
patch -f --dry-run -p1 < ${_filename} > /dev/null &&
patch -p1 < ${_filename} &&
csih_inform "apply patch ${_filename} OK")
} }
readonly -f show_usage readonly -f slapos_apply_patch
function slapos_buildout() function slapos_buildout()
{ {
# ----------------------------------------------------------- local _home=$1/slapos
# Run the buildout of slapos node local _cache=$1/download-cache
# ----------------------------------------------------------- local _buildcfg=${_home}/buildout.cfg
local _bootstrap=${_home}/bootstrap.py
local _buildurl=${2:-http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/component/slapos/buildout.cfg}
[[ -z "$1" ]] && csih_error "no slapos path specified"
csih_inform "Starting run buildout of slapos node ..." csih_inform "Starting run buildout of slapos node ..."
csih_inform "mkdir /opt/slapos/log" csih_inform "mkdir ${_home}/log"
mkdir -p ${slapos_home}/log mkdir -p ${_home}/log
csih_inform "mkdir /opt/download-cache" csih_inform "mkdir ${_cache}"
mkdir -p ${slapos_cache} mkdir -p ${_cache}
[[ ! -f ${slapos_cfg} ]] && [[ ! -f ${_buildcfg} ]] &&
echo "[buildout] echo "[buildout]
extends = ${slapos_url} extends = ${_buildurl}
download-cache = ${slapos_cache} download-cache = ${_cache}
prefix = ${buildout:directory} prefix = \${buildout:directory}
" > ${slapos_cfg} && " > ${_buildcfg} &&
csih_inform "${slapos_cfg} generated" csih_inform "${_buildcfg} generated"
[[ -f ${slapos_bootstrap} ]] || [[ -f ${_bootstrap} ]] ||
python -S -c 'import urllib2;print urllib2.urlopen("http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/bootstrap.py").read()' > ${slapos_bootstrap} || python -S -c 'import urllib2;print urllib2.urlopen("http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/bootstrap.py").read()' > ${_bootstrap} ||
csih_error "download bootstrap.py failed" csih_error "download bootstrap.py failed"
csih_inform "download ${slapos_bootstrap} OK" csih_inform "download ${_bootstrap} OK"
[[ -x ${slapos_home}/bin/buildout ]] || [[ -x ${_home}/bin/buildout ]] ||
(cd ${slapos_home} && python -S bootstrap.py) || (cd ${_home} && python -S bootstrap.py) ||
csih_error "run bootstrap.py failed" csih_error "run bootstrap.py failed"
csih_inform "run bootstrap.py OK" csih_inform "run bootstrap.py OK"
csih_inform "start bin/buildout" csih_inform "start bin/buildout"
(cd ${slapos_home} ; bin/buildout -v -N) || csih_error "bin/buildout failed" (cd ${_home} ; bin/buildout -v -N) || csih_error "bin/buildout failed"
_filename=~/slapos-core-format.patch slapos_apply_patch "~/slapos-core-format.patch" "${_home}/eggs/slapos.core-*.egg/"
[[ -f ${_filename} ]] || slapos_apply_patch "~/supervisor-cygwin.patch" "${_home}/eggs/supervisor-*.egg/"
wget -c http://git.erp5.org/gitweb/slapos.package.git/blob_plain/heads/cygwin:/windows/patches/$(basename ${_filename}) -O ${_filename} ||
csih_error "download ${_filename} failed"
csih_inform "download ${_filename} OK"
csih_inform "applay patch ${_filename}"
(cd $(ls -d ${slapos_home}/eggs/slapos.core-*.egg/) &&
csih_inform "patch at $(pwd)" &&
patch -f --dry-run -p1 < ${_filename} > /dev/null &&
patch -p1 < ${_filename} &&
csih_inform "apply patch ${_filename} OK")
_filename=~/supervisor-cygwin.patch
[[ -f ${_filename} ]] ||
wget -c http://git.erp5.org/gitweb/slapos.package.git/blob_plain/heads/cygwin:/windows/patches/$(basename ${_filename}) -O ${_filename} ||
csih_error "download ${_filename} failed"
csih_inform "download ${_filename} OK"
csih_inform "applay patch ${_filename}"
(cd $(ls -d ${slapos_home}/eggs/supervisor-*.egg) &&
csih_inform "patch at $(pwd)" &&
patch -f --dry-run -p1 < ${_filename} > /dev/null &&
patch -p1 < ${_filename} &&
csih_inform "apply patch ${_filename} OK")
csih_inform "Run buildout of slapos node OK" csih_inform "Run buildout of slapos node OK"
echo "" echo ""
...@@ -91,11 +88,7 @@ echo "" ...@@ -91,11 +88,7 @@ echo ""
# ----------------------------------------------------------- # -----------------------------------------------------------
# Local variable # Local variable
# ----------------------------------------------------------- # -----------------------------------------------------------
declare -r slapos_home=/opt/slapos declare -r slapos_path=${1:-/opt}
declare -r slapos_cache=/opt/download-cache
declare -r slapos_url=http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/component/slapos/buildout.cfg
declare -r slapos_cfg=${slapos_home}/buildout.cfg
declare -r slapos_bootstrap=${slapos_home}/bootstrap.py
# ----------------------------------------------------------- # -----------------------------------------------------------
# Command line options # Command line options
...@@ -125,7 +118,7 @@ done ...@@ -125,7 +118,7 @@ done
# ----------------------------------------------------------- # -----------------------------------------------------------
# Build SlapOS # Build SlapOS
# ----------------------------------------------------------- # -----------------------------------------------------------
slapos_buildout slapos_buildout ${slapos_path}
# ----------------------------------------------------------- # -----------------------------------------------------------
# End script # End script
......
#! /bin/bash #! /bin/bash
# #
# This script is used to build slapos installer of windows. There are 2 # This script is used to build slapos installer of windows. It's running
# scripts need to run in prior: # only in the SlapOS Cygwin bootstrap node. The directory structures of
# bootstrap node looks like:
# #
# slapos-cygwin-bootstrap.sh # ./cygwin-packages Cygwin local packages
# ./setup.exe Cygwin setup file
# ./cygwin The root path of cygwin
# #
# build-slapos.sh # In the cygwin bootstrap node, the following files are required:
#
# /opt/inno-setup
# Microsoft Visual C++ 2008 Express Edition or later version
# Microsoft Windows SDK v7.0 if you're in 64-bits environments
#
# Before run this script, you need first run build-slapos.sh to update
# slapos node:
#
# ./build-slapos.sh /opt/buildout
# #
# In this script, it will do: # In this script, it will do:
# #
# * Prepare sources # * Prepare the sources required by installer
#
# * Build ipwin/regpwd/ovpn-server/ovpn-client
# #
# * Make installer # * Make installer
# #
...@@ -32,7 +46,10 @@ function show_usage() ...@@ -32,7 +46,10 @@ function show_usage()
{ {
echo "Usage:" echo "Usage:"
echo "" echo ""
echo " ./slapos-build-installer" echo " ./slapos-build-installer [slapos-path]"
echo ""
echo " slapos-path: specify slapos root path, the buildout.cfg will be put in"
echo " slapos-path/slapos. The default value is /opt/buildout"
echo "" echo ""
} }
readonly -f show_usage readonly -f show_usage
...@@ -43,12 +60,6 @@ readonly -f show_usage ...@@ -43,12 +60,6 @@ readonly -f show_usage
csih_inform "Starting build Slapos Windows installer ..." csih_inform "Starting build Slapos Windows installer ..."
echo "" echo ""
# ======================================================================
# Constants
# ======================================================================
declare -r cygwin_home=$(cygpath -a $(cygpath -w /)\\.. | sed -e "s%/$%%")
declare -r ISCC=${cygwin_home}/inno-setup/ISCC.exe
# ----------------------------------------------------------- # -----------------------------------------------------------
# Start script # Start script
# ----------------------------------------------------------- # -----------------------------------------------------------
...@@ -63,9 +74,8 @@ while test $# -gt 0; do ...@@ -63,9 +74,8 @@ while test $# -gt 0; do
-h | --help) -h | --help)
show_usage show_usage
exit 0 exit 0
;;
*) *)
show_usage
exit 1
;; ;;
esac esac
...@@ -73,21 +83,35 @@ while test $# -gt 0; do ...@@ -73,21 +83,35 @@ while test $# -gt 0; do
shift shift
done done
# ======================================================================
# Constants
# ======================================================================
declare -r cygwin_home=$(cygpath -m $(cygpath -w /)\\.. | sed -e "s%/$%%")
declare -r ISCC=$(cyypath -m /opt/inno-setup/ISCC.exe)
declare -r slapos_path=${1:-/opt/buildout}
# ----------------------------------------------------------- # -----------------------------------------------------------
# Prepare the sources used to build installer # Build slapos
# ----------------------------------------------------------- # -----------------------------------------------------------
csih_inform "Preparing the sources used to build installer ..." slapos_buildout ${slapos_path} ${slapos_url}
(rm -rf /opt/slapos/slapos.tar.gz; cd /opt ; tar czf slapos.tar.gz slapos/ ; mv slapos.tar.gz slapos/) || (cd ${slapos_path} ; tar czf slapos.tar.gz slapos/ ; mv slapos.tar.gz /opt/slapos) ||
csih_error "create slapos.tar.gz failed" csih_error "create slapos.tar.gz failed"
csih_inform "tar package /opt/slapos/slapos.tar.gz generated" csih_inform "tar package /opt/slapos/slapos.tar.gz generated"
# -----------------------------------------------------------
# Prepare the sources used to build installer
# -----------------------------------------------------------
csih_inform "Preparing the sources used to build installer ..."
_filename=/opt/slapos/slapos.cfg.example _filename=/opt/slapos/slapos.cfg.example
[[ -f ${_filename} ]] ||
wget -c http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos.cfg.example -O ${_filename} || wget -c http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos.cfg.example -O ${_filename} ||
csih_error "download ${_filename} failed" csih_error "download ${_filename} failed"
csih_inform "Got ${_filename}" csih_inform "Got ${_filename}"
_filename=/opt/slapos/slapos-client.cfg.example _filename=/opt/slapos/slapos-client.cfg.example
[[ -f ${_filename} ]] ||
wget -c http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos-client.cfg.example -O ${_filename} || wget -c http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos-client.cfg.example -O ${_filename} ||
csih_error "download ${_filename} failed" csih_error "download ${_filename} failed"
csih_inform "Got ${_filename}" csih_inform "Got ${_filename}"
...@@ -97,7 +121,7 @@ csih_inform "Got ${_filename}" ...@@ -97,7 +121,7 @@ csih_inform "Got ${_filename}"
csih_error "clone http://git.erp5.org/repos/slapos.package.git failed" csih_error "clone http://git.erp5.org/repos/slapos.package.git failed"
csih_inform "clone/pull http://git.erp5.org/repos/slapos.package.git OK" csih_inform "clone/pull http://git.erp5.org/repos/slapos.package.git OK"
if csih_is_vista ; then if check_os_is_wow64 ; then
csih_inform "making babeld for vista or above ..." csih_inform "making babeld for vista or above ..."
(cd /opt/git/slapos.package/windows/babeld ; WINVER=VISTA make) || (cd /opt/git/slapos.package/windows/babeld ; WINVER=VISTA make) ||
csih_error "make babeld failed" csih_error "make babeld failed"
...@@ -108,8 +132,8 @@ else ...@@ -108,8 +132,8 @@ else
fi fi
_filename=/opt/git/slapos.package/windows/scripts/regpwd.exe _filename=/opt/git/slapos.package/windows/scripts/regpwd.exe
[[ ! -f ${_filename} ]] && (cd /opt/git/slapos.package/windows/scripts ; gcc -o regpwd.exe regpwd.c) ||
(cd /opt/git/slapos.package/windows/scripts ; gcc -o regpwd.exe regpwd.c) && csih_error "make regpwd.exe failed"
csih_inform "make regpwd.exe" csih_inform "make regpwd.exe"
_filename=~/openvpn-driver.tar.gz _filename=~/openvpn-driver.tar.gz
...@@ -128,11 +152,13 @@ csih_inform "extracting ${_filename} ..." ...@@ -128,11 +152,13 @@ csih_inform "extracting ${_filename} ..."
csih_error "extract ${_filename} failed" csih_error "extract ${_filename} failed"
_filename=/opt/downloads/pyOpenSSL-0.13.tar.gz _filename=/opt/downloads/pyOpenSSL-0.13.tar.gz
[[ -f ${_filename} ]] ||
wget -c --no-check-certificate https://pypi.python.org/packages/source/p/pyOpenSSL/pyOpenSSL-0.13.tar.gz#md5=767bca18a71178ca353dff9e10941929 -O ${_filename} || wget -c --no-check-certificate https://pypi.python.org/packages/source/p/pyOpenSSL/pyOpenSSL-0.13.tar.gz#md5=767bca18a71178ca353dff9e10941929 -O ${_filename} ||
csih_error "download ${_filename} failed" csih_error "download ${_filename} failed"
csih_inform "Got ${_filename}" csih_inform "Got ${_filename}"
_filename=/opt/downloads/miniupnpc-1.8.tar.gz _filename=/opt/downloads/miniupnpc-1.8.tar.gz
[[ -f ${_filename} ]] ||
wget -c http://miniupnp.free.fr/files/download.php?file=miniupnpc-1.8.tar.gz -O ${_filename} || wget -c http://miniupnp.free.fr/files/download.php?file=miniupnpc-1.8.tar.gz -O ${_filename} ||
csih_error "download ${_filename} failed" csih_error "download ${_filename} failed"
csih_inform "Got ${_filename}" csih_inform "Got ${_filename}"
...@@ -142,19 +168,19 @@ csih_inform "updating re6stnet.git ..." ...@@ -142,19 +168,19 @@ csih_inform "updating re6stnet.git ..."
(cd /opt/git ; git clone -b cygwin http://git.erp5.org/repos/re6stnet.git) || (cd /opt/git ; git clone -b cygwin http://git.erp5.org/repos/re6stnet.git) ||
csih_error "clone/pull re6stnet.git failed" csih_error "clone/pull re6stnet.git failed"
# # Now package i686-w64-mingw32-gcc isn't installed, so ignore it in temporary csih_inform "building ovpn-client and ovpn-server ..."
# csih_inform "building ovpn-client and ovpn-server ..." for _name in ovpn-client ovpn-server ; do
# for _name in ovpn-client ovpn-server ; do (cd /opt/git/re6stnet/re6st ; i686-w64-mingw32-gcc -o ${_name}.exe ${_name}.c ovpn-pipe.c) ||
# (cd /opt/git/re6stnet/re6st ; i686-w64-mingw32-gcc -o ${_name}.exe ${_name}.c ovpn-pipe.c) || csih_error "build ${_name}.exe failed"
# csih_error "build ${_name}.exe failed" csih_inform "build ${_name}.exe OK"
# csih_inform "build ${_name}.exe OK" done
# done
csih_inform "creating re6stnet source package ..." csih_inform "creating re6stnet source package ..."
(cd /opt/git/re6stnet ; python setup.py sdist) || (cd /opt/git/re6stnet ; python setup.py sdist) ||
csih_error "create re6stnet source package failed" csih_error "create re6stnet source package failed"
_filename=~/images.tar.gz _filename=~/images.tar.gz
[[ -f ${_filename} ]] ||
wget -c http://www.dashingsoft.com/products/slapos/images.tar.gz -O ${_filename} || wget -c http://www.dashingsoft.com/products/slapos/images.tar.gz -O ${_filename} ||
csih_error "download ${_filename} failed" csih_error "download ${_filename} failed"
csih_inform "Got ${_filename}" csih_inform "Got ${_filename}"
...@@ -163,17 +189,10 @@ csih_inform "extracting ${_filename} ..." ...@@ -163,17 +189,10 @@ csih_inform "extracting ${_filename} ..."
(cd /opt ; tar xzf ${_filename} --no-same-owner) || (cd /opt ; tar xzf ${_filename} --no-same-owner) ||
csih_error "extract ${_filename} failed" csih_error "extract ${_filename} failed"
# This command need microsoft sdk to build, so we just copy it
_filename=/opt/git/slapos.package/windows/ipwin/ipwin/ipwin.exe _filename=/opt/git/slapos.package/windows/ipwin/ipwin/ipwin.exe
if check_os_is_wow64 ; then /opt/git/slapos.package/windows/ipwin/ipwin/build.bat "batch" ||
_url=http://www.dashingsoft.com/products/slapos/ipwin-x64.tar.gz csih_error "build ipwin.exe failed"
else csih_inform "build ${_filename} OK"
_url=http://www.dashingsoft.com/products/slapos/ipwin-x86.tar.gz
fi
wget -c ${_url} -O ${_filename} ||
csih_error_multi "download ${_filename} failed" " from ${_url}"
csih_inform "Got ${_filename}"
csih_inform " from ${_url}"
csih_inform "Prepare the sources OK" csih_inform "Prepare the sources OK"
echo "" echo ""
...@@ -183,7 +202,7 @@ echo "" ...@@ -183,7 +202,7 @@ echo ""
# ----------------------------------------------------------- # -----------------------------------------------------------
_issfile=~/slapos.iss _issfile=~/slapos.iss
_installer_name=slapos-windows-all-in-one _installer_name=slapos-windows-all-in-one
_output_dir=$(cygpath -a -w $(cygpath -w /)\\.. | sed -e 's%\\%\\\\%g') _output_dir=$(cygpath -a -w $(cygpath -w /opt/publish) | sed -e 's%\\%\\\\%g')
_source_dir=$(cygpath -a -w $(cygpath -w /)\\.. | sed -e 's%\\%\\\\%g') _source_dir=$(cygpath -a -w $(cygpath -w /)\\.. | sed -e 's%\\%\\\\%g')
_srcfile=/opt/git/slapos.package/windows/scripts/slapos-all-in-one.iss _srcfile=/opt/git/slapos.package/windows/scripts/slapos-all-in-one.iss
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment