Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Update these batch scripts so that it's not necessary to manually spe…
Browse files Browse the repository at this point in the history
…cify the paths of SAGE_LOCAL or CYGWIN_ROOT
  • Loading branch information
embray committed May 5, 2017
1 parent b60823b commit e2905b1
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 8 deletions.
36 changes: 32 additions & 4 deletions src/bin/sage-rebase.bat
@@ -1,19 +1,32 @@
@echo off
rem Author:
rem * Jean-Pierre Flori <jean-pierre.flori@ssi.gouv.fr>
rem * Erik M. Bray <erik.bray@lri.fr>
rem
rem Rebase all dlls in the SAGE_LOCAL directory (and its subdirectories),
rem but do not touch the ones already stored in the system database,
rem and do not update it.
rem Note that subsequent calls to 'rebaseall' will not update the Sage dlls.
rem
rem Invoke this script from a Windows command prompt,
rem after adjusting SAGE_LOCAL to the Windows location of the Sage directory,
rem Invoke this script from a Windows command prompt
rem and, if Cygwin is installed in a non-standard location,
rem adjusting CYGWIN_ROOT.

set CYGWIN_ROOT=C:\cygwin\
set SAGE_LOCAL=C:\cygwin\usr\local\sage\
setlocal ENABLEEXTENSIONS

set THIS_BIN=%~dp0

rem SAGE_LOCAL should be one level up from the bin/ this script is in
rem This is about the most elegant way to do this I can find thanks
rem http://stackoverflow.com/a/33404867/982257
call :NORMALIZEPATH "%THIS_BIN%.."
set SAGE_LOCAL=%RETVAL%

rem Cygwin saves its installation root here
rem If there is more than one Cygwin installation on the system this
rem will just pick up the first one
call :READREGISTRY HKEY_LOCAL_MACHINE\SOFTWARE\Cygwin\setup rootdir
set CYGWIN_ROOT=%RETVAL%

rem Make sure bash can be called from MSDOS prompt:
path %CYGWIN_ROOT%\bin;%path%
Expand All @@ -22,3 +35,18 @@ set CYGWIN=%CYGWIN% nodosfilewarning
rem Call the bash script to do the real work:
cd %SAGE_LOCAL%
bash bin\sage-rebase.sh


:: ========== FUNCTIONS ==========
exit /B

:READREGISTRY
for /F "usebackq skip=2 tokens=3" %%V in (`reg query %1 /v %2 2^>nul`) do (
set RETVAL=%%V
break
)
exit /B

:NORMALIZEPATH
set RETVAL=%~dpfn1
exit /B
35 changes: 31 additions & 4 deletions src/bin/sage-rebaseall.bat
Expand Up @@ -2,23 +2,35 @@
rem Authors:
rem * Dmitrii Pasechnik <dimpase@gmail.com>
rem * Jean-Pierre Flori <jean-pierre.flori@ssi.gouv.fr>
rem * Erik M. Bray <erik.bray@lri.fr>
rem
rem Rebase all dlls in the SAGE_LOCAL directory (and its subdirectories),
rem as well as the ones already stored in the system database,
rem and update the database.
rem This system-wide database is located in '/etc/rebase.db.i386' and
rem includes the Cygwin system dlls.
rem
rem Invoke this script from a Windows command prompt,
rem after adjusting SAGE_LOCAL to the Windows location of the Sage directory,
rem Invoke this script from a Windows command prompt
rem and, if Cygwin is installed in a non-standard location,
rem adjusting CYGWIN_ROOT.
rem
rem Ensure that no other Cygwin processes are currently running.
rem Note that you need write access to the system-wide rebase database
rem (which usually means admin rights).

set CYGWIN_ROOT=C:\cygwin\
set SAGE_LOCAL=C:\cygwin\usr\local\sage\
set THIS_BIN=%~dp0

rem SAGE_LOCAL should be one level up from the bin/ this script is in
rem This is about the most elegant way to do this I can find thanks
rem http://stackoverflow.com/a/33404867/982257
call :NORMALIZEPATH "%THIS_BIN%.."
set SAGE_LOCAL=%RETVAL%

rem Cygwin saves its installation root here
rem If there is more than one Cygwin installation on the system this
rem will just pick up the first one
call :READREGISTRY HKEY_LOCAL_MACHINE\SOFTWARE\Cygwin\setup rootdir
set CYGWIN_ROOT=%RETVAL%

rem Make sure dash can be called from MSDOS prompt:
path %CYGWIN_ROOT%\bin;%path%
Expand All @@ -27,3 +39,18 @@ set CYGWIN=%CYGWIN% nodosfilewarning
rem Call the dash script to do the real work:
cd %SAGE_LOCAL%
dash bin\sage-rebaseall.sh


:: ========== FUNCTIONS ==========
exit /B

:READREGISTRY
for /F "usebackq skip=2 tokens=3" %%V in (`reg query %1 /v %2 2^>nul`) do (
set RETVAL=%%V
break
)
exit /B

:NORMALIZEPATH
set RETVAL=%~dpfn1
exit /B

0 comments on commit e2905b1

Please sign in to comment.