Difference between revisions of "LazarusScripts"

From Lazarus wiki
Jump to navigationJump to search
(New page: Lightning: Here is a windows batch script that takes care of checking out and updating '''Lazarus''' from '''SVN''' to a subdirectory and even basic error fixing, becaus...)
 
(code highlight)
Line 3: Line 3:
 
Please save the script as '''getlaz.bat''' or some other name, however there is no warranty of any kind, use at your own risk, put it in a test directory first and make sure there is no subdirectory already called '''lazarus'''.
 
Please save the script as '''getlaz.bat''' or some other name, however there is no warranty of any kind, use at your own risk, put it in a test directory first and make sure there is no subdirectory already called '''lazarus'''.
  
@echo off
+
<dos>@echo off
REM Script for checkout and update Lazarus from SVN
+
REM Script for checkout and update Lazarus from SVN
echo.
+
echo.
 
   
 
   
REM Check if lazarus directory exists to update or checkout first
+
REM Check if lazarus directory exists to update or checkout first
if exist lazarus (
+
if exist lazarus (
echo Updating Lazarus, please wait ...
+
echo Updating Lazarus, please wait ...
cd lazarus
+
cd lazarus
svn update
+
svn update
if %errorlevel% NEQ 0 goto CleanupLaz
+
if %errorlevel% NEQ 0 goto CleanupLaz
cd ..
+
cd ..
goto Exit
+
goto Exit
)
+
)
 
   
 
   
echo Checking out Lazarus for the first time, this might take a while ...
+
echo Checking out Lazarus for the first time, this might take a while ...
svn checkout http://svn.freepascal.org/svn/lazarus/trunk lazarus
+
svn checkout http://svn.freepascal.org/svn/lazarus/trunk lazarus
goto Exit
+
goto Exit
 
   
 
   
:CleanupLaz
+
:CleanupLaz
echo.
+
echo.
echo Something went wrong, trying to fix any problems if possible  ...
+
echo Something went wrong, trying to fix any problems if possible  ...
svn cleanup
+
svn cleanup
if %errorlevel% NEQ 0 (
+
if %errorlevel% NEQ 0 (
cd ..
+
cd ..
echo.
+
echo.
echo Cleanup Failed ! Please check or delete/move/rename the lazarus subdirectory ...
+
echo Cleanup Failed ! Please check or delete/move/rename the lazarus subdirectory ...
goto Exit
+
goto Exit
)
+
)
 
   
 
   
cd ..
+
cd ..
echo.
+
echo.
echo Cleanup complete please run the script again.
+
echo Cleanup complete please run the script again.
:Exit
+
:Exit</dos>
  
  
Line 44: Line 44:
 
But without further ado, here is the script. But (big but) it is given without any guarantee. :) If things break you are on your own.
 
But without further ado, here is the script. But (big but) it is given without any guarantee. :) If things break you are on your own.
  
#!/bin/bash
+
<bash>#!/bin/bash
 
   
 
   
# before you can use this script you have to checkout all files
+
# before you can use this script you have to checkout all files
# so first do a
+
# so first do a
# svn checkout http://svn.freepascal.org/svn/lazarus/trunk lazarus
+
# svn checkout http://svn.freepascal.org/svn/lazarus/trunk lazarus
 
   
 
   
#Define some directories
+
# Define some directories
BASEDIR=/usr/share/
+
BASEDIR=/usr/share/
LAZCVSDIR=~/cvsroot/lazarus/
+
LAZCVSDIR=~/cvsroot/lazarus/
LAZDIR=/usr/share/lazarus/
+
LAZDIR=/usr/share/lazarus/
LAZBACKUP=/usr/share/lazarus.bu
+
LAZBACKUP=/usr/share/lazarus.bu
 
   
 
   
#Remove old backup if it exists
+
# Remove old backup if it exists
date +"%T %tStart"
+
date +"%T %tStart"
if [ -d $LAZBACKUP ]
+
if [ -d $LAZBACKUP ]
then  
+
then  
  date +"%T %tRemoving old backup"
+
  date +"%T %tRemoving old backup"
  rm $LAZBACKUP -fr
+
  rm $LAZBACKUP -fr
else
+
else
  date +"%T %tNo backup to remove"
+
  date +"%T %tNo backup to remove"
fi
+
fi
 
   
 
   
date +"%T %tCreating copy of lazarus dir"
+
date +"%T %tCreating copy of lazarus dir"
cp -R $LAZDIR $LAZBACKUP
+
cp -R $LAZDIR $LAZBACKUP
 
   
 
   
#Getting stuff from svn
+
# Getting stuff from svn
date +"%T %tUpdate lazarus"
+
date +"%T %tUpdate lazarus"
svn update lazarus > ~/cvs_update.log
+
svn update lazarus > ~/cvs_update.log
 
   
 
   
#Copying cvs-files to our laz dir.
+
# Copying cvs-files to our laz dir.
date +"%T %tcopying files"
+
date +"%T %tcopying files"
cp -Rf $LAZCVSDIR $BASEDIR --reply=yes
+
cp -Rf $LAZCVSDIR $BASEDIR --reply=yes
 
   
 
   
#Make and building of lazarus
+
# Make and building of lazarus
date +"%T %tmake lazarus"  
+
date +"%T %tmake lazarus"  
cd $LAZDIR
+
cd $LAZDIR
make > /dev/null
+
make > /dev/null
date +"%T %tmake the packages"
+
date +"%T %tmake the packages"
make idepkg > /dev/null
+
make idepkg > /dev/null
date +"%T %tFinished"
+
date +"%T %tFinished"</bash>

Revision as of 18:21, 18 January 2011

Lightning: Here is a windows batch script that takes care of checking out and updating Lazarus from SVN to a subdirectory and even basic error fixing, because i have no way of knowing where Lazarus is installed it cannot compile or copy the files to your working Lazarus instalation. Please save the script as getlaz.bat or some other name, however there is no warranty of any kind, use at your own risk, put it in a test directory first and make sure there is no subdirectory already called lazarus.

<dos>@echo off REM Script for checkout and update Lazarus from SVN echo.

REM Check if lazarus directory exists to update or checkout first if exist lazarus ( echo Updating Lazarus, please wait ... cd lazarus svn update if %errorlevel% NEQ 0 goto CleanupLaz cd .. goto Exit )

echo Checking out Lazarus for the first time, this might take a while ... svn checkout http://svn.freepascal.org/svn/lazarus/trunk lazarus goto Exit

CleanupLaz

echo. echo Something went wrong, trying to fix any problems if possible ... svn cleanup if %errorlevel% NEQ 0 ( cd .. echo. echo Cleanup Failed ! Please check or delete/move/rename the lazarus subdirectory ... goto Exit )

cd .. echo. echo Cleanup complete please run the script again.

Exit</dos>


Matthijs: In Linux I use a script (it is not very sophisticated, but does the trick) to download the latest SVN-version for Lazarus. Before I copy it here I'll explain my system. In my home-directory I have a special cvsroot-directory. In this directory I have a script for downloading Lazarus and other interesting projects. Lazarus is installed in /usr/share/lazarus. Before building a new version from SVN I make a backup, just in case the current svn is unstable. This is done by moving the /usr/share/lazarus directory to /usr/share/lazarus.bu To adapt the script to your system you only need to alter the constants defined at the start of the script. But without further ado, here is the script. But (big but) it is given without any guarantee. :) If things break you are on your own.

<bash>#!/bin/bash

  1. before you can use this script you have to checkout all files
  2. so first do a
  3. svn checkout http://svn.freepascal.org/svn/lazarus/trunk lazarus
  1. Define some directories

BASEDIR=/usr/share/ LAZCVSDIR=~/cvsroot/lazarus/ LAZDIR=/usr/share/lazarus/ LAZBACKUP=/usr/share/lazarus.bu

  1. Remove old backup if it exists

date +"%T %tStart" if [ -d $LAZBACKUP ] then

 date +"%T %tRemoving old backup"
 rm $LAZBACKUP -fr

else

 date +"%T %tNo backup to remove"

fi

date +"%T %tCreating copy of lazarus dir" cp -R $LAZDIR $LAZBACKUP

  1. Getting stuff from svn

date +"%T %tUpdate lazarus" svn update lazarus > ~/cvs_update.log

  1. Copying cvs-files to our laz dir.

date +"%T %tcopying files" cp -Rf $LAZCVSDIR $BASEDIR --reply=yes

  1. Make and building of lazarus

date +"%T %tmake lazarus" cd $LAZDIR make > /dev/null date +"%T %tmake the packages" make idepkg > /dev/null date +"%T %tFinished"</bash>