Browse Source

Install mono from snapshot packages without sudo

Pēteris Ņikiforovs 10 years ago
parent
commit
04ae558a16

+ 14 - 14
frameworks/CSharp/aspnet/setup_nginx.sh

@@ -2,36 +2,36 @@
 
 
 set -e
 set -e
 
 
+# mono environment variables
+. ${IROOT}/mono.installed
+
 export NGINX_HOME=${IROOT}/nginx
 export NGINX_HOME=${IROOT}/nginx
-export MONO_HOME=/opt/mono-20141222114925
-export PATH=$MONO_HOME/bin:$PATH
 
 
 sed -i 's|localhost|'"$DBHOST"'|g' src/Web.config
 sed -i 's|localhost|'"$DBHOST"'|g' src/Web.config
 
 
 # extra cleaning
 # extra cleaning
-sudo rm -rf src/bin src/obj /tmp/nuget
+rm -rf src/bin src/obj
+rm -rf /tmp/nuget
 
 
 xbuild src/Benchmarks.build.proj /t:Clean
 xbuild src/Benchmarks.build.proj /t:Clean
 xbuild src/Benchmarks.build.proj /t:Build
 xbuild src/Benchmarks.build.proj /t:Build
 
 
+# one fastcgi instance for each thread
+# load balanced by nginx
+port_start=9001
+port_end=$(($port_start+$MAX_THREADS))
+
 # nginx
 # nginx
 conf="upstream mono {\n"
 conf="upstream mono {\n"
-current=9001
-end=$(($current+$MAX_THREADS))
-while [ $current -lt $end ]; do
-  conf+="\tserver 127.0.0.1:${current};\n"
-  let current=current+1
+for port in $(seq $port_start $port_end); do
+  conf+="\tserver 127.0.0.1:${port};\n"
 done
 done
 conf+="}"
 conf+="}"
 echo -e $conf > $TROOT/nginx.upstream.conf
 echo -e $conf > $TROOT/nginx.upstream.conf
 
 
 $NGINX_HOME/sbin/nginx -c $TROOT/nginx.conf -g "worker_processes ${MAX_THREADS};"
 $NGINX_HOME/sbin/nginx -c $TROOT/nginx.conf -g "worker_processes ${MAX_THREADS};"
 
 
-# Start fastcgi for each thread
 # To debug, use --printlog --verbose --loglevels=All
 # To debug, use --printlog --verbose --loglevels=All
-current=9001
-end=$(($current+$MAX_THREADS))
-while [ $current -lt $end ]; do
-  fastcgi-mono-server4 --applications=/:${TROOT}/src --socket=tcp:127.0.0.1:$current &
-  let current=current+1
+for port in $(seq $port_start $port_end); do
+  fastcgi-mono-server4 --applications=/:${TROOT}/src --socket=tcp:127.0.0.1:$port &
 done
 done

+ 49 - 30
toolset/setup/linux/languages/mono.sh

@@ -1,32 +1,51 @@
 #!/bin/bash
 #!/bin/bash
 
 
-set -e
-
-post_install () {
-  . mono-snapshot mono/20141222114925
-  
-  echo "Installing SSL certificates"
-  sudo env "PATH=$PATH" mozroots --import --sync --machine
-  echo -e 'y\ny\ny\n' | sudo env "PATH=$PATH" certmgr -ssl -m https://nuget.org
-
-  # For apps that need write access to the registry
-  sudo mkdir -p /etc/mono/registry
-  sudo chmod 777 /etc/mono/registry
-}
-
-RETCODE=$(fw_exists $IROOT/monosnap.installed)
-[ ! "$RETCODE" == 0 ] || { 
-  post_install
-  return 0
-}
-
-echo "Installing mono from packages"
-sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
-echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
-echo "deb http://jenkins.mono-project.com/repo/debian sid main" | sudo tee /etc/apt/sources.list.d/mono-jenkins.list
-sudo apt-get update
-sudo apt-get install -y -f cli-common mono-snapshot-20141222114925
-
-post_install
-
-touch $IROOT/monosnap.installed
+RETCODE=$(fw_exists $IROOT/mono.installed)
+[ ! "$RETCODE" == 0 ] || { return 0; }
+
+# what do we want? latest mono
+# how do we want it? already compiled from packages but without sudo
+
+# save environment
+cat > $IROOT/mono.installed <<'END'
+export SNAPDATE=20141220092712
+export MONO_HOME=$IROOT/mono-snapshot-$SNAPDATE
+export MONO_PATH=$MONO_HOME/lib/mono/4.5
+export MONO_CFG_DIR=$MONO_HOME/etc
+export PATH=$MONO_HOME/bin:$PATH
+export LD_LIBRARY_PATH=$MONO_HOME/lib:$LD_LIBRARY_PATH
+export PKG_CONFIG_PATH=$MONO_HOME/lib/pkgconfig:$PKG_CONFIG_PATH
+END
+
+# load environment
+. $IROOT/mono.installed
+
+# temp dir for extracting archives
+TEMP=$IROOT/mono-snapshot-${SNAPDATE}-temp
+
+# start fresh
+rm -rf $TEMP && mkdir -p $TEMP
+rm -rf $MONO_HOME && mkdir -p $MONO_HOME
+
+# download .debs and extract them into $TEMP dir
+fw_get http://jenkins.mono-project.com/repo/debian/pool/main/m/mono-snapshot-${SNAPDATE}/mono-snapshot-${SNAPDATE}_${SNAPDATE}-1_amd64.deb
+fw_get http://jenkins.mono-project.com/repo/debian/pool/main/m/mono-snapshot-${SNAPDATE}/mono-snapshot-${SNAPDATE}-assemblies_${SNAPDATE}-1_all.deb
+dpkg-deb -x mono-*amd64.deb $TEMP
+dpkg-deb -x mono-*assemblies*.deb $TEMP
+
+# move /opt/mono-$SNAPDATE to /installs
+mv $TEMP/opt/mono-*/* $MONO_HOME
+
+# cleanup
+rm mono-*.deb
+rm -rf $TEMP
+
+# replace /opt/mono-$SNAPDATE path
+file $MONO_HOME/bin/* | grep "POSIX shell script" | awk -F: '{print $1}' | xargs sed -i "s|/opt/mono-$SNAPDATE|$MONO_HOME|g"
+sed -i "s|/opt/mono-$SNAPDATE|$MONO_HOME|g" $MONO_HOME/lib/pkgconfig/*.pc $MONO_HOME/etc/mono/config
+
+# import SSL certificates
+#mozroots --import --sync
+echo -e 'y\ny\ny\n' | certmgr -ssl https://nuget.org
+
+touch $IROOT/mono.installed

+ 12 - 3
toolset/setup/linux/languages/xsp.sh

@@ -1,18 +1,27 @@
 #!/bin/bash
 #!/bin/bash
 
 
+set -e
+
 RETCODE=$(fw_exists ${IROOT}/xsp.installed)
 RETCODE=$(fw_exists ${IROOT}/xsp.installed)
 [ ! "$RETCODE" == 0 ] || { return 0; }
 [ ! "$RETCODE" == 0 ] || { return 0; }
 
 
 fw_depends mono
 fw_depends mono
 
 
-. mono-snapshot mono/20141222114925
+# mono environment variables
+. ${IROOT}/mono.installed
 
 
+# get
 git clone git://github.com/mono/xsp
 git clone git://github.com/mono/xsp
 cd xsp
 cd xsp
 git checkout e272a2c006211b6b03be2ef5bbb9e3f8fefd0768
 git checkout e272a2c006211b6b03be2ef5bbb9e3f8fefd0768
 
 
-./autogen.sh --prefix=${MONO_PREFIX}
+# build
+./autogen.sh --prefix=${MONO_HOME} --disable-docs
 make
 make
-sudo make install
+make install
+
+# cleanup
+cd ..
+rm -rf xsp
 
 
 touch ${IROOT}/xsp.installed
 touch ${IROOT}/xsp.installed