@@ -801,6 +801,26 @@ export https_proxy=$http_proxy
801801export ftp_proxy=$http_proxy
802802export rsync_proxy=$http_proxy
803803
804+ # #################################################################
805+ # We need to run sage-rebase.sh for each package installed, but it
806+ # can be dangerous to do this while other packages are installing
807+ # so we need to use a lock to manage when rebase is allowed to
808+ # run. Because of this, if multiple sage-spkg runs are waiting on
809+ # the rebase lock, we can end up with multiple consecutive rebase
810+ # calls that are redundant, but I don't see an obvious way around
811+ # that. This also unfortunately slows down parallel builds since
812+ # all packages will eventually need to wait for this lock, but
813+ # again there's no simple way around that.
814+ # #################################################################
815+
816+ if [ " $UNAME " = " CYGWIN" ]; then
817+ if [ ! -d " $SAGE_LOCAL /var/lock" ]; then
818+ mkdir -p " $SAGE_LOCAL /var/lock"
819+ fi
820+ exec 200> " $SAGE_LOCAL /var/lock/rebase.lock"
821+ sage-flock -s $lock_type 200
822+ fi
823+
804824# #################################################################
805825# Actually install
806826# #################################################################
@@ -810,6 +830,13 @@ export rsync_proxy=$http_proxy
810830# this in one place)
811831export SAGE_DESTDIR=" ${SAGE_BUILD_DIR} /${PKG_NAME} /inst"
812832
833+ # The actual prefix where the installation will be staged. This is the
834+ # directory that you need to work in if you want to change the staged
835+ # installation tree (before final installation to $SAGE_LOCAL) at the
836+ # end of spkg-install.
837+ export SAGE_DESTDIR_LOCAL=" ${SAGE_DESTDIR}${SAGE_LOCAL} "
838+
839+
813840if [ -f spkg-build ]; then
814841 # Package has both spkg-build and spkg-install; execute the latter with SAGE_SUDO
815842 time ./spkg-build
835862# case DESTDIR=$SAGE_DESTDIR installation was not used
836863echo " Copying package files from temporary location $SAGE_DESTDIR to $SAGE_LOCAL "
837864if [ -d " $SAGE_DESTDIR " ]; then
838- PREFIX=" ${SAGE_DESTDIR}${SAGE_LOCAL %/ } /"
865+ PREFIX=" ${SAGE_DESTDIR_LOCAL %/ } /"
839866
840867 rm -f " $PREFIX " lib/* .la
841868 if [ $? -ne 0 ]; then
@@ -872,9 +899,14 @@ if [ -d "$SAGE_DESTDIR" ]; then
872899fi
873900
874901if [ " $UNAME " = " CYGWIN" ]; then
902+ # Drop our sage-spkg's shared lock, and try to call sage-rebase.sh
903+ # under an exclusive lock
904+ sage-flock -u 200
905+
875906 # Rebase after installing each package--in case any packages load this
876907 # package at build time we need to ensure during the build that no binaries
877908 # have conflicting address spaces
909+ echo " Waiting for rebase lock"
878910 sage-flock -x " $SAGE_LOCAL /var/lock/rebase.lock" \
879911 sage-rebase.sh " $SAGE_LOCAL " 2> /dev/null
880912fi
0 commit comments