Difference between revisions of "LazarusScripts"

From Free Pascal 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...)
 
m (Check history instead for authors/editors)
 
(14 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[user:Lightning|Lightning]]:
+
==Windows==
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.
+
 
 +
Here is a windows batch script that takes care of checking out and updating '''Lazarus''' from '''GIT''' 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 installation.
 
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
+
<syntaxhighlight lang="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
+
git pull
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
+
git clone https://gitlab.com/freepascal.org/lazarus/lazarus.git
goto Exit
+
goto Exit
 
   
 
   
:CleanupLaz
+
:CleanupLaz
echo.
+
echo.
echo Something went wrong, trying to fix any problems if possible  ...
+
echo Something went wrong, please check or delete/move/rename the lazarus subdirectory ...
svn cleanup
+
goto Exit
if %errorlevel% NEQ 0 (
+
 
cd ..
+
:Exit
echo.
+
</syntaxhighlight>
echo Cleanup Failed ! Please check or delete/move/rename the lazarus subdirectory ...
+
 
goto Exit
+
==GNU/Linux==
)
+
 
+
A trivial script to update the local repository for Lazarus etc..
cd ..
+
 
echo.
+
In home-directory, have a special cvsroot-subdirectory.
echo Cleanup complete please run the script again.
+
 
:Exit
+
In this directory have a script for downloading Lazarus and other interesting projects.  
 +
 
 +
Lazarus is installed in /usr/share/lazarus.  
 +
 
 +
Before building a new version with the current remote repository from GitLab I make a backup, just in case the current remote repository is unstable.  
 +
 
 +
This is done by moving the /usr/share/lazarus directory to /usr/share/lazarus.BAK
 +
 
  
 +
To adapt the script to your system, you need to alter the constants defined at the start of the script.
  
[[user:Matthijs|Matthijs]]:
+
It may not be working, as usual and does not catch any errors.
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.
 
  
#!/bin/bash
+
<syntaxhighlight lang="bash">
 +
#!/bin/bash
 
   
 
   
# before you can use this script you have to checkout all files
+
# get a local copy of the repository prior running this script - so first do:
# so first do a
+
# git clone https://gitlab.com/freepascal.org/lazarus/lazarus.git
# svn checkout http://svn.freepascal.org/svn/lazarus/trunk lazarus
 
 
   
 
   
#Define some directories
+
# Define some directories , much better to not put stuff below /usr/ but below /home/
BASEDIR=/usr/share/
+
# must point the the same root as LAZDIR
LAZCVSDIR=~/cvsroot/lazarus/
+
BASEDIR=/usr/share/
LAZDIR=/usr/share/lazarus/
+
# dir of the git repository
LAZBACKUP=/usr/share/lazarus.bu
+
LAZCVSDIR=~/cvsroot/lazarus/
 +
# dir where lazarus is installed to
 +
LAZDIR=/usr/share/lazarus/
 +
# backup dir with the previous lazarus installation
 +
LAZBACKUP=/usr/share/lazarus.BAK
 
   
 
   
#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 GitLab
date +"%T %tUpdate lazarus"
+
date +"%T %tUpdate lazarus"
svn update lazarus > ~/cvs_update.log
+
git pull > ~/cvs_update.log
 
   
 
   
#Copying cvs-files to our laz dir.
+
# Copying cloned 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                   ### so you don't see all the errors which will inevitably break the script
date +"%T %tmake the packages"
+
date +"%T %tmake the packages"
make idepkg > /dev/null
+
make idepkg > /dev/null
date +"%T %tFinished"
+
date +"%T %tFinished"
 +
</syntaxhighlight>
 +
 
 +
[[Category:Lazarus]]
 +
[[Category:Install]]

Latest revision as of 23:07, 27 December 2021

Windows

Here is a windows batch script that takes care of checking out and updating Lazarus from GIT 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 installation. 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
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
git pull
if %errorlevel% NEQ 0 goto CleanupLaz
cd ..
goto Exit
)
 
echo Checking out Lazarus for the first time, this might take a while ...
git clone https://gitlab.com/freepascal.org/lazarus/lazarus.git
goto Exit
 
:CleanupLaz
echo.
echo Something went wrong, please check or delete/move/rename the lazarus subdirectory ...
goto Exit

:Exit

GNU/Linux

A trivial script to update the local repository for Lazarus etc..

In home-directory, have a special cvsroot-subdirectory.

In this directory have a script for downloading Lazarus and other interesting projects.

Lazarus is installed in /usr/share/lazarus.

Before building a new version with the current remote repository from GitLab I make a backup, just in case the current remote repository is unstable.

This is done by moving the /usr/share/lazarus directory to /usr/share/lazarus.BAK


To adapt the script to your system, you need to alter the constants defined at the start of the script.

It may not be working, as usual and does not catch any errors.

#!/bin/bash
 
# get a local copy of the repository prior running this script - so first do:
# git clone https://gitlab.com/freepascal.org/lazarus/lazarus.git
 
# Define some directories , much better to not put stuff below /usr/ but below /home/ 
# must point the the same root as LAZDIR
BASEDIR=/usr/share/
# dir of the git repository
LAZCVSDIR=~/cvsroot/lazarus/
# dir where lazarus is installed to
LAZDIR=/usr/share/lazarus/
# backup dir with the previous lazarus installation
LAZBACKUP=/usr/share/lazarus.BAK
 
# 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
 
# Getting stuff from GitLab
date +"%T %tUpdate lazarus"
git pull > ~/cvs_update.log
 
# Copying cloned files to our laz dir.
date +"%T %tcopying files"
cp -Rf $LAZCVSDIR $BASEDIR --reply=yes
 
# Make and building of lazarus
date +"%T %tmake lazarus" 
cd $LAZDIR
make > /dev/null                   ### so you don't see all the errors which will inevitably break the script
date +"%T %tmake the packages"
make idepkg > /dev/null
date +"%T %tFinished"