+# enable the right repos
+curl http://repos.riftio.com/public/xenial-riftware-public-key | sudo apt-key add -
+
+# always use the same file name so that updates will overwrite rather than enable a second repo
+sudo curl -o /etc/apt/sources.list.d/rift.list http://buildtracker.riftio.com/repo_file/ub16/${PLATFORM_REPOSITORY}/
+sudo apt-get update
+
+sudo apt install -y --allow-downgrades rw.tools-container-tools=${PLATFORM_VERSION} rw.tools-scripts=${PLATFORM_VERSION}
+
+if $installFromPackages; then
+
+ # Install module and platform from packages
+ sudo -H /usr/rift/container_tools/mkcontainer --modes $MODULE --repo ${PLATFORM_REPOSITORY} --rw-version ${PLATFORM_VERSION}
+
+else
+
+ # Install environment to build module
+ sudo -H /usr/rift/container_tools/mkcontainer --modes $MODULE-dev --repo ${PLATFORM_REPOSITORY} --rw-version ${PLATFORM_VERSION}
+ sudo -H pip3 install --upgrade pip
+ sudo -H pip3 install setuptools
+ sudo -H pip3 install juju
+ sudo mkdir -p /usr/rift/etc/default
+ sudo chmod 777 /usr/rift/etc/default
+ echo LAUNCHPAD_OPTIONS="--use-xml-mode" >> /usr/rift/etc/default/launchpad
+ sudo systemctl daemon-reload || true
+
+ IM_FILES="
+ietf-l2-topology.yang
+ietf-network-topology.yang
+ietf-network.yang
+mano-rift-groupings.yang
+mano-types.yang
+nsd-base.yang
+nsd.yang
+nsr.yang
+odl-network-topology.yang
+project-nsd.yang
+project-vnfd.yang
+vlr.yang
+vnfd-base.yang
+vnfd.yang
+vnffgd.yang
+vnfr.yang
+"
+ echo "installing IM files"
+ if [ ! -d ../IM ]; then
+ echo cloning IM
+ # note that this cannot be inside the SO or else CMAKE will find it
+ git clone $(dirname $(git remote get-url origin))/IM.git ../IM
+ fi
+ for file in $IM_FILES; do
+ rm -f models/plugins/yang/$file
+ cp ../IM/models/yang/$file models/plugins/yang
+ done
+
+ # Build and install module
+ make -j16
+ sudo make install