Commit f52dbd09 authored by Jondy Zhao's avatar Jondy Zhao

Refine build-slapos script

parent a102426b
#! /bin/bash #! /bin/bash
export PATH=/usr/local/bin:/usr/bin:$PATH export PATH=/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:$PATH
slapos_home=/opt/slapos slapos_home=${1-/opt/slapos}
slapos_cache=/opt/download-cache slapos_cache=/opt/download-cache
slapos_url=http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-0:/component/slapos/buildout.cfg
slapos_cfg=$slapos_home/buildout.cfg
slapos_bootstrap=$slapos_home/bootstrap.py
patch_files=/etc/slapos/patches/slapos-core-format.patch
if [[ ! -d $slapos_home ]] ; then mkdir -p $slapos_home/log
echo "Make directory of slapos home: $slapos_home" mkdir -p $slapos_cache
mkdir -p $slapos_home
fi
if [[ ! -d $slapos_cache ]] ; then
echo "Make directory of slapos cache: $slapos_cache"
mkdir -p $slapos_cache
fi
cd $slapos_home if [[ -r $slapos_cfg ]] ; then
if [[ ! -f buildout.cfg ]] ; then echo "Change $slapos_home/buildout.cfg with "
echo "Create $slapos_home/buildout.cfg" echo " extends = ${slapos_url}"
echo "[buildout] sed -i -e "s%^extends = .*$%extends = ${slapos_url}%g" $slapos_cfg
extends = http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-0:/component/slapos/buildout.cfg
download-cache = /opt/download-cache
prefix = ${buildout:directory}
" > buildout.cfg
else else
echo "Edit $slapos_home/buildout.cfg" cat <<EOF > $slapos_cfg
sed -i -e "s%^extends = .*$%extends = http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-0:/component/slapos/buildout.cfg%g" buildout.cfg [buildout]
extends = ${slapos_url}
download-cache = ${slapos_cache}
prefix = $${buildout:directory}
EOF
echo "$slapos_home/buildout.cfg created."
fi fi
if [[ ! -f bootstrap.py ]] ; then if [[ ! -f $slapos_bootstrap ]] ; then
echo "Download $slapos_home/bootstrap.py" 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.py echo "$slapos_bootstrap downloaded."
python -S bootstrap.py if (! cd $slapos_home ; python -S bootstrap.py) ; then
(($?)) && echo "SlapOS bootstrap failed." && exit 1 echo "SlapOS bootstrap failed."
exit 1
fi
fi fi
bin/buildout -v -N # cd $slapos_home
(($?)) && echo "Buildout SlapOS failed." && exit 1 if (! cd $slapos_home ; $slapos_home/bin/buildout -v -N) ; then
echo "SlapOS buildout failed."
exit 1
fi
# apply patches # apply patches
patch_file=/etc/slapos/patches/slapos-core-format.patch for filename in $patch_files ; do
if [[ -f $patch_file ]] ; then if [[ -r $filename ]] ; then
echo "Apply patch: $patch_file" echo "Apply patch: $filename"
for x in $(find $slapos_home/eggs -name slapos.core-*.egg ; do for x in $(find $slapos_home/eggs -name slapos.core-*.egg) ; do
echo Patching $x ... echo " at $x ..."
cd $x (cd $x ; patch -f --dry-run -p1 < $filename > /dev/null && \
patch -f --dry-run -p1 < $patch_file > /dev/null && patch -p1 < $patch_file && echo Patch $x OK. patch -p1 < $filename && echo " OK.")
done done
fi fi
done
echo Build SlapOS successfully. echo Build SlapOS successfully.
read -n 1 -p "Press any key to exit..." read -n 1 -t 60 -p "Press any key to exit..."
exit 0 exit 0
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