Recent

Author Topic: Tutorial: Install Lazarus to Raspberry Pi  (Read 45688 times)

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #15 on: August 26, 2019, 11:22:50 am »
That error at least makes perfect sense. You cannot create a file under /usr/lib as a normal user. And good thing too !

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Mi-Ki

  • Jr. Member
  • **
  • Posts: 74
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #16 on: August 26, 2019, 11:28:41 am »
@ dbannon - you're right
sudo  ./startlazarus

works and they're going to add packers.
How to solve it to work without sudo?


Mi-Ki

  • Jr. Member
  • **
  • Posts: 74
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #17 on: August 26, 2019, 11:44:39 am »
It works, thank you. :D

I installed according to the instructions.
/ usr / lib / lazarus /
All directories group pi, owner pi
Just / usr / lib / lazarus / units / to root

The first time you run lazarus is this error, but everything works.
How to solve?

rvk

  • Hero Member
  • *****
  • Posts: 6109
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #18 on: August 26, 2019, 11:48:57 am »
How to solve it to work without sudo?
Don't run install.sh with sudo (as root).

I never liked installing Lazarus and FPC as root.

You might want to just install it to /home/pi/dev/fpc and /home/pi/dev/lazarus

My current script (will install in /home/pi/dev and only needs sudo for some packages)
Works for Linux on Raspberry as well as i686 and x86_64.

Code: Bash  [Select][+][-]
  1. #!/bin/sh
  2. # ======================================================
  3. # by rvk (v.1.2, 2018-02-21)
  4. # ======================================================
  5. echo ""
  6. echo "=============================================================="
  7. echo "Running on: $([ -f /proc/device-tree/model ] && cat /proc/device-tree/model || cat /sys/devices/virtual/dmi/id/product_name)"
  8.  
  9. BASE=$HOME/dev
  10. mkdir -p $BASE
  11. cd $BASE
  12.  
  13. begin=$(date +%s)
  14.  
  15. # ======================================================
  16. # minimal swap space needed is 1024MB
  17. # ======================================================
  18. while true; do
  19.  
  20.   # FREESWAP=$(swapon -s | tail -n 1 | awk '{print $3}')
  21.   FREESWAP=$(free | tail -n1 | awk '{print $2}')
  22.   if [ $FREESWAP -lt 900000 ]; then
  23.  
  24.     # we can increase this if /etc/dphys-swapfile exists
  25.     echo "Swap size is too small. Minimum required is 1024MB.";
  26.     [ -f /etc/dphys-swapfile ] && {
  27.  
  28.       echo "=============================================================="
  29.       free -h
  30.       echo "Setting in /etc/dphys-swapfile $(cat /etc/dphys-swapfile | grep CONF_SWAPSIZE)"
  31.       echo "Current size is $FREESWAP"
  32.       echo "=============================================================="
  33.       while true; do
  34.         read -p "Do you want to increase it to 1024MB? (y/n) " yn
  35.         case $yn in
  36.           [Yy]* ) break;;
  37.           [Nn]* ) echo >&2 "Please increase the swap space manually. Aborting..."; exit 1;;
  38.           * ) echo "Please answer yes or no.";;
  39.         esac
  40.       done
  41.       echo "Increasing value and restarting swap"
  42.       sudo sed -i 's/CONF_SWAPSIZE=[0-9]*$/CONF_SWAPSIZE=1024/g' /etc/dphys-swapfile
  43.       sudo /etc/init.d/dphys-swapfile stop
  44.       sudo /etc/init.d/dphys-swapfile restart
  45.       echo "=============================================================="
  46.  
  47.     } || {
  48.  
  49.       echo >&2 "Please increase the swap space manually. Aborting..."; exit 1;
  50.  
  51.     }
  52.   else
  53.     break;
  54.   fi
  55.  
  56. done
  57.  
  58. # ======================================================
  59. # update packages list to latest version
  60. # ======================================================
  61. echo "=============================================================="
  62. echo ""
  63. echo "Updating package list to latest version (sudo needed)"
  64. echo ""
  65. apt-get --version >/dev/null 2>&1 || { echo >&2 "I require apt-get but it's not installed. Aborting."; exit 1; }
  66. sudo apt-get update >/dev/null || { echo >&2 "apt-get update cannot be run. Aborting."; exit 1; }
  67.  
  68. # ======================================================
  69. # some other essentials
  70. # ======================================================
  71. echo "=============================================================="
  72. echo ""
  73. echo "Installing required packages (sudo used)"
  74. echo ""
  75. sudo apt-get -y install build-essential bzip2 p7zip-full subversion >/dev/null
  76. sudo apt-get -y install libx11-dev libgdk-pixbuf2.0-dev libcairo2-dev lpango-1.0 libpangox-1.0-dev xorg-dev libatk1.0-dev libgtk2.0-dev >/dev/null
  77. sudo apt-get -y install libssl-dev >/dev/null # for all your ssl stuff
  78.  
  79. #sudo apt-get install -y freetds-dev
  80. sudo apt-get -y install pv >/dev/null # pipeviewer for progress http://www.catonmat.net/blog/unix-utilities-pipe-viewer/
  81. svn --version >/dev/null 2>&1 || { echo >&2 "I require svn but it's not installed. Aborting."; exit 1; }
  82.  
  83. # ======================================================
  84. # We need a bootstrap compiler fpc 3.0.4
  85. # There is NONE AVAILABLE so we need to download complete
  86. # fpc-3.0.4.arm-linux-raspberry1wq.tar
  87. # in virtualbox Rasbian stretch we need i386
  88. # ======================================================
  89. CPU=$(uname -m)
  90. if [ "$CPU" = "armv7l" ]; then # note L not 1
  91.   echo "Compiling for ARMv7 Processor (Pi2 and Pi3 only)"
  92.   OPTIONS_FPC="-g -gl -O2 -Xs -CX -XX -v0 -vh- -dFPC_ARMHF"
  93.   OPTIONS_LAZ="-v0"
  94.   OS_TARGET="linux"
  95.   CPU_TARGET="arm"
  96.   COMP3_DOWNLOAD="ftp://ftp.freepascal.org/pub/fpc/dist/3.0.4/arm-linux/fpc-3.0.4.arm-linux-eabihf-raspberry.tar"
  97.   COMP=ppcarm
  98. elif [ "$CPU" = "x86_64" ]; then
  99.   echo "Compiling for x64 Processor"
  100.   OPTIONS_FPC="-g -gl -O2 -Xs -CX -XX -v0"
  101.   OPTIONS_LAZ="-v0"
  102.   OS_TARGET="linux"
  103.   CPU_TARGET="x86_64"
  104.   COMP3_DOWNLOAD="ftp://ftp.freepascal.org/pub/fpc/dist/3.0.4/x86_64-linux/fpc-3.0.4.x86_64-linux.tar" # complete version
  105.   COMP3_DOWNLOAD="ftp://ftp.freepascal.org/pub/fpc/dist/3.0.4/bootstrap/x86_64-linux-ppcx64.bz2" # bootstrap
  106.   COMP=ppcx64
  107. elif [ "$CPU" = "i686" ]; then
  108.   echo "Compiling for i686 Processor"
  109.   OPTIONS_FPC="-g -gl -O2 -Xs -CX -XX -v0"
  110.   OPTIONS_LAZ="-v0"
  111.   OS_TARGET="linux"
  112.   CPU_TARGET="i386"
  113.   COMP3_DOWNLOAD="ftp://ftp.freepascal.org/pub/fpc/dist/3.0.4/i386-linux/fpc-3.0.4.i386-linux.tar" # complete version
  114.   COMP=ppc386
  115. else
  116.   echo >&2 "$CPU is not supported as processor (needed armv7l/x86_64/i686). Aborting."; exit 1;
  117. fi
  118.  
  119. # ------------------------------------------------------
  120.  
  121. if [ ! -x ./compiler3/$COMP ]; then
  122.   if echo "$COMP3_DOWNLOAD" | grep -q "\.bz2"; then
  123.  
  124.     echo "Downloading bootstrap compiler 3.0.4"
  125.     echo ""
  126.     wget --continue --quiet --show-progress -O compiler3.bz2 $COMP3_DOWNLOAD
  127.     echo ""
  128.     [ -f ./compiler3.bz2 ] || { echo >&2 "Download of bootstrap compiler failed. Aborting."; exit 1; }
  129.     mkdir -p ./compiler3
  130.     bzip2 -d -c compiler3.bz2 > ./compiler3/$COMP
  131.     chmod ug+rx ./compiler3/ppcx64
  132.     rm ./compiler3.bz2
  133.  
  134.   else
  135.  
  136.     echo "Downloading compiler 3.0.4"
  137.     echo ""
  138.     wget --continue --quiet --show-progress -O compiler3.tar $COMP3_DOWNLOAD
  139.     echo ""
  140.     [ -f ./compiler3.tar ] || { echo >&2 "Download of bootstrap compiler failed. Aborting."; exit 1; }
  141.     mkdir -p ./compiler3/ex
  142.     tar xf compiler3.tar -C ./compiler3/ex --strip=1 >/dev/null
  143.     tar xvf ./compiler3/ex/binary.*-linux.tar -C ./compiler3/ex >/dev/null
  144.     tar zxvf ./compiler3/ex/base.*-linux.tar.gz -C ./compiler3/ex >/dev/null
  145.     mv $(find -name $COMP) ./compiler3
  146.     rm ./compiler3/ex -Rf
  147.     rm ./compiler3.tar
  148.  
  149.   fi
  150. fi
  151. [ -x ./compiler3/$COMP ] || { echo >&2 "Bootstrap $BASE/compiler3/$COMP compiler not found. Aborting."; exit 1; }
  152.  
  153. # ======================================================
  154. # downloading fpc and lazarus
  155. # ======================================================
  156. echo "=============================================================="
  157. echo ""
  158. echo "Downloading FPC sources $(svn info fpc 2>&1 | grep Rev:)"
  159. echo ""
  160. # svn co https://svn.freepascal.org/svn/fpc/trunk fpc -r42644 >/dev/null
  161. svn co https://svn.freepascal.org/svn/fpc/trunk fpc >/dev/null
  162. [ -f ./fpc/Makefile ] || { echo >&2 "Download of fpc failed. Aborting."; exit 1; }
  163. echo "Now: $(svn info fpc | grep Rev:)"
  164. echo ""
  165.  
  166. echo "Downloading Lazarus sources $(svn info lazarus 2>&1 | grep Rev:)"
  167. echo ""
  168. # svn co https://svn.freepascal.org/svn/lazarus/trunk lazarus -r61689 >/dev/null
  169. svn co https://svn.freepascal.org/svn/lazarus/trunk lazarus >/dev/null
  170. [ -f ./lazarus/Makefile ] || { echo >&2 "Download of fpc failed. Aborting."; exit 1; }
  171. echo "Now: $(svn info lazarus | grep Rev:)"
  172. echo ""
  173.  
  174. # ======================================================
  175. # compiling fpc
  176. # ======================================================
  177. echo "=============================================================="
  178. echo ""
  179. echo "Now compiling FPC, this will take some time"
  180. echo ""
  181. cd $BASE/fpc
  182. make -s all install OPT="$OPTIONS_FPC" OS_TARGET=$OS_TARGET CPU_TARGET=$CPU_TARGET INSTALL_PREFIX=$BASE/fpc PP=$BASE/compiler3/$COMP \
  183.   | pv -l -bp >$BASE/fpc.log \
  184.   || { echo >&2 "Compilation of FPC failed. Aborting."; exit 1; }
  185. cd $BASE
  186. [ -x ./fpc/bin/fpc ] || { echo >&2 "Something went wrong compiling FPC. Aborting."; exit 1; }
  187.  
  188. echo ""
  189. echo "Doing some extra configuration"
  190. [ -f $HOME/.fpc.cfg ] && rm $HOME/.fpc.cfg
  191. ln -sf $BASE/fpc/lib/fpc/3.3.1/$COMP $BASE/fpc/bin/$COMP
  192. ln -sf $BASE/fpc/lib/fpc/3.3.1/samplecfg $BASE/fpc/bin/samplecfg
  193. $BASE/fpc/bin/fpcmkcfg -d basepath=$BASE/fpc -o $HOME/.fpc.cfg
  194.  
  195. # sudo find / -name crtbegin.o
  196. # This library needs to be added to the fpc.cfg file.
  197.  
  198. cat << EOF >> $HOME/.fpc.cfg
  199. -Fu$BASE/fpc/lib/fpc/\$fpcversion/units/\$fpctarget
  200. -Fu$BASE/fpc/lib/fpc/\$fpcversion/units/\$fpctarget/*
  201. -Fu$BASE/fpc/lib/fpc/\$fpcversion/units/\$fpctarget/rtl
  202. -Fl$(find / -name crtbegin.o -printf '%h\n' 2>/dev/null | head -n 1)
  203. -FD$BASE/fpc/bin
  204. EOF
  205.  
  206.  
  207. echo ""
  208.  
  209. # ======================================================
  210. # compiling lazarus
  211. # ======================================================
  212. echo "=============================================================="
  213. echo ""
  214. echo "Now compiling Lazarus, this will take some time"
  215. echo ""
  216. cd $BASE/lazarus
  217. make -s bigide OS_TARGET=$OS_TARGET CPU_TARGET=$CPU_TARGET OPT="$OPTIONS_LAZ" PP="$BASE/fpc/bin/fpc" \
  218.   | pv -l -bp >$BASE/laz.log \
  219.   || { echo >&2 "Compilation of Lazarus failed. Aborting."; exit 1; }
  220. cd $BASE
  221. [ -f ./lazarus/lazarus ] || { echo >&2 "Something went wrong compiling Lazarus. Aborting."; exit 1; }
  222.  
  223. echo ""
  224. echo "Doing some extra configuration"
  225. echo ""
  226.  
  227. # set path withhout old fpc
  228. PATH=$(echo $PATH | sed "s|$BASE/fpc/bin\:||g")
  229.  
  230. # strip previous $BASE from .profile
  231. sed -i '/# FPC PATH/,/fi/d' $HOME/.profile
  232.  
  233. cat << EOF >> $HOME/.profile
  234.  
  235. # FPC PATH
  236. if [ -d $BASE/fpc/bin ] ; then
  237.     PATH="$BASE/fpc/bin:\$PATH"
  238. fi
  239. EOF
  240.  
  241. # replace all double empty lines with one
  242. sed -i '/^$/N;/^\n$/D' $HOME/.profile
  243.  
  244. cat << EOF > $HOME/Desktop/Lazarus.desktop
  245. [Desktop Entry]
  246. Name=Lazarus
  247. Comment=Lazarus
  248. Icon=$BASE/lazarus/images/ide_icon48x48.png
  249. Exec=$BASE/lazarus/startlazarus
  250. Path=$BASE/lazarus
  251. Type=Application
  252. Encoding=UTF-8
  253. Terminal=false
  254. Categories=None;
  255. EOF
  256.  
  257. end=$(date +%s)
  258. echo "=============================================================="
  259. echo ""
  260. echo "$((($end-$begin) / 60)) minutes and $((($end-$begin) % 60)) seconds elapsed."
  261. echo ""
  262. echo "We are done. Please logout and back in before starting Lazarus"
  263. echo "Otherwise you need to supply the fpc location on 1st start"
  264. echo ""
  265. echo "=============================================================="
  266. echo ""

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #19 on: August 26, 2019, 12:51:35 pm »
Nice script rvk, you must have done a few pis to put that together !

However, it seems (http://www.raspberryconnect.com/raspbian-packages/29-raspbian-devel) that Buster now includes fpc 304, no need for the bootstrap compiler. So I think the best approach is to use Buster's fpc and then install and build Lazarus in the user's home directory (as you note).

Mi-Ki - this means that if you are happy with your fpc install, then you proceed to install Lazarus in your own, home directory. Maybe that is /home/pi ?

First, use app-get to install a pretty standard app called subversion, it provides the svn command. Then follow the instructions in https://wiki.freepascal.org/Installing_Lazarus_on_Linux#Build_Lazarus_from_Source

You might be well advised to clean out the lazarus install under /usr/ - it really should not be there. And, to be sure, clean it out before doing what I suggested above.

Davo



 
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

rvk

  • Hero Member
  • *****
  • Posts: 6109
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #20 on: August 26, 2019, 01:04:07 pm »
However, it seems (http://www.raspberryconnect.com/raspbian-packages/29-raspbian-devel) that Buster now includes fpc 304, no need for the bootstrap compiler. So I think the best approach is to use Buster's fpc and then install and build Lazarus in the user's home directory (as you note).
True. My next step would indeed be to use FPC 3.0.4 from the repositories. I haven't got around to that yet.

But because I also want the trunk version of FPC itself as end-result, I would only want to download FPC 3.0.4 with apt-get download and unpack the compiler and use that. In that case there are no lingering FPC files from an older version.

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #21 on: August 26, 2019, 01:26:30 pm »
But because I also want the trunk version of FPC itself as end-result, I would only want to download FPC 3.0.4 with apt-get download and unpack the compiler and use that. In that case there are no lingering FPC files from an older version.

Ah, thats why you manually install the dependencies rather than let apt do it. Makes sense !

Lingering Files cause problems, no doubt. Particularly when the OS is updated.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

rvk

  • Hero Member
  • *****
  • Posts: 6109
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #22 on: August 26, 2019, 01:40:06 pm »
But because I also want the trunk version of FPC itself as end-result, I would only want to download FPC 3.0.4 with apt-get download and unpack the compiler and use that. In that case there are no lingering FPC files from an older version.
Ah, thats why you manually install the dependencies rather than let apt do it. Makes sense !
Yeah, I saw (with a dry-run) a whole lot of packages being installed too.

Just doing this gave me an ppcarm compiler (FPC) which should also just work fine as bootstrap compiler without all the other junk (I hope, didnt test yet).

Code: Bash  [Select][+][-]
  1. apt-get download fp-compiler-3.0.4
  2. dpkg-deb --fsys-tarfile fp-compiler*.deb | tar -x ./usr/lib/arm-linux-gnueabihf/fpc/3.0.4/ppcarm --strip-components 6

Edit: Yep, new script works.
Only problem is, it takes a wopping 42 minutes to compile FPC and Lazarus on a RPI3 B with 1GB.
Can't remember it took so long in the past.
(I use the first and last line to copy and paste this into a SSH session and run it from there)

Code: Bash  [Select][+][-]
  1. cat << 'EEOF' > laz
  2. #!/bin/sh
  3. # ======================================================
  4. # by rvk (v.1.3, 2019-08-26)
  5. # ======================================================
  6. echo ""
  7. echo "=============================================================="
  8. echo "Running on: $([ -f /proc/device-tree/model ] && cat /proc/device-tree/model || cat /sys/devices/virtual/dmi/id/product_name)"
  9.  
  10. BASE=$HOME/dev
  11. mkdir -p $BASE
  12. cd $BASE
  13.  
  14. begin=$(date +%s)
  15.  
  16. # ======================================================
  17. # minimal swap space needed is 1024MB
  18. # ======================================================
  19. while true; do
  20.  
  21.   # FREESWAP=$(swapon -s | tail -n 1 | awk '{print $3}')
  22.   FREESWAP=$(free | tail -n1 | awk '{print $2}')
  23.   if [ $FREESWAP -lt 900000 ]; then
  24.  
  25.     # we can increase this if /etc/dphys-swapfile exists
  26.     echo "Swap size is too small. Minimum required is 1024MB.";
  27.     [ -f /etc/dphys-swapfile ] && {
  28.  
  29.       echo "=============================================================="
  30.       free -h
  31.       echo "Setting in /etc/dphys-swapfile $(cat /etc/dphys-swapfile | grep CONF_SWAPSIZE)"
  32.       echo "Current size is $FREESWAP"
  33.       echo "=============================================================="
  34.       while true; do
  35.         read -p "Do you want to increase it to 1024MB? (y/n) " yn
  36.         case $yn in
  37.           [Yy]* ) break;;
  38.           [Nn]* ) echo >&2 "Please increase the swap space manually. Aborting..."; exit 1;;
  39.           * ) echo "Please answer yes or no.";;
  40.         esac
  41.       done
  42.       echo "Increasing value and restarting swap"
  43.       sudo sed -i 's/CONF_SWAPSIZE=[0-9]*$/CONF_SWAPSIZE=1024/g' /etc/dphys-swapfile
  44.       sudo /etc/init.d/dphys-swapfile stop
  45.       sudo /etc/init.d/dphys-swapfile restart
  46.       echo "=============================================================="
  47.  
  48.     } || {
  49.  
  50.       echo >&2 "Please increase the swap space manually. Aborting..."; exit 1;
  51.  
  52.     }
  53.   else
  54.     break;
  55.   fi
  56.  
  57. done
  58.  
  59. # ======================================================
  60. # update packages list to latest version
  61. # ======================================================
  62. echo "=============================================================="
  63. echo ""
  64. echo "Updating package list to latest version (sudo needed)"
  65. echo ""
  66. apt-get --version >/dev/null 2>&1 || { echo >&2 "I require apt-get but it's not installed. Aborting."; exit 1; }
  67. sudo apt-get update >/dev/null || { echo >&2 "apt-get update cannot be run. Aborting."; exit 1; }
  68.  
  69. # ======================================================
  70. # some other essentials
  71. # ======================================================
  72. echo "=============================================================="
  73. echo ""
  74. echo "Installing required packages (sudo used)"
  75. echo ""
  76. sudo apt-get -y install build-essential bzip2 p7zip-full subversion >/dev/null
  77. sudo apt-get -y install libx11-dev libgdk-pixbuf2.0-dev libcairo2-dev lpango-1.0 libpangox-1.0-dev xorg-dev libatk1.0-dev libgtk2.0-dev >/dev/null
  78. sudo apt-get -y install libssl-dev >/dev/null # for all your ssl stuff
  79.  
  80. #sudo apt-get install -y freetds-dev
  81. sudo apt-get -y install pv >/dev/null # pipeviewer for progress http://www.catonmat.net/blog/unix-utilities-pipe-viewer/
  82. svn --version >/dev/null 2>&1 || { echo >&2 "I require svn but it's not installed. Aborting."; exit 1; }
  83.  
  84. # ======================================================
  85. # We need a bootstrap compiler fpc 3.0.4
  86. # There is NONE AVAILABLE so we need to download complete
  87. # fpc-3.0.4.arm-linux-raspberry1wq.tar
  88. # in virtualbox Rasbian stretch we need i386
  89. # ======================================================
  90. CPU=$(uname -m)
  91. if [ "$CPU" = "armv7l" ]; then # note L not 1
  92.   echo "Compiling for ARMv7 Processor (Pi2 and Pi3 only)"
  93.   OPTIONS_FPC="-g -gl -O2 -Xs -CX -XX -v0 -vh- -dFPC_ARMHF"
  94.   OPTIONS_LAZ="-v0"
  95.   OS_TARGET="linux"
  96.   CPU_TARGET="arm"
  97.   COMP3_DOWNLOAD="ftp://ftp.freepascal.org/pub/fpc/dist/3.0.4/arm-linux/fpc-3.0.4.arm-linux-eabihf-raspberry.tar"
  98.   COMP3_DOWNLOAD="fp-compiler"
  99.   COMP=ppcarm
  100. elif [ "$CPU" = "x86_64" ]; then
  101.   echo "Compiling for x64 Processor"
  102.   OPTIONS_FPC="-g -gl -O2 -Xs -CX -XX -v0"
  103.   OPTIONS_LAZ="-v0"
  104.   OS_TARGET="linux"
  105.   CPU_TARGET="x86_64"
  106.   COMP3_DOWNLOAD="ftp://ftp.freepascal.org/pub/fpc/dist/3.0.4/x86_64-linux/fpc-3.0.4.x86_64-linux.tar" # complete version
  107.   COMP3_DOWNLOAD="ftp://ftp.freepascal.org/pub/fpc/dist/3.0.4/bootstrap/x86_64-linux-ppcx64.bz2" # bootstrap
  108.   COMP=ppcx64
  109. elif [ "$CPU" = "i686" ]; then
  110.   echo "Compiling for i686 Processor"
  111.   OPTIONS_FPC="-g -gl -O2 -Xs -CX -XX -v0"
  112.   OPTIONS_LAZ="-v0"
  113.   OS_TARGET="linux"
  114.   CPU_TARGET="i386"
  115.   COMP3_DOWNLOAD="ftp://ftp.freepascal.org/pub/fpc/dist/3.0.4/i386-linux/fpc-3.0.4.i386-linux.tar" # complete version
  116.   COMP=ppc386
  117. else
  118.   echo >&2 "$CPU is not supported as processor (needed armv7l/x86_64/i686). Aborting."; exit 1;
  119. fi
  120.  
  121. # ------------------------------------------------------
  122.  
  123. if [ ! -x ./compiler3/$COMP ]; then
  124.  
  125.   if echo "$COMP3_DOWNLOAD" | grep -q "fp-compiler"; then
  126.  
  127.     echo "Downloading package fp-compiler-3.0.4"
  128.     echo ""
  129.     mkdir -p ./compiler3
  130.     apt-get download fp-compiler-3.0.4
  131.     dpkg-deb --fsys-tarfile fp-compiler*.deb | tar -x ./usr/lib/arm-linux-gnueabihf/fpc/3.0.4/ppcarm --strip-components 6
  132.     mv ppcarm ./compiler3
  133.     rm ./fp-compiler*.deb
  134.  
  135.   else
  136.  
  137.     if echo "$COMP3_DOWNLOAD" | grep -q "\.bz2"; then
  138.  
  139.       echo "Downloading bootstrap compiler 3.0.4"
  140.       echo ""
  141.       wget --continue --quiet --show-progress -O compiler3.bz2 $COMP3_DOWNLOAD
  142.       echo ""
  143.       [ -f ./compiler3.bz2 ] || { echo >&2 "Download of bootstrap compiler failed. Aborting."; exit 1; }
  144.       mkdir -p ./compiler3
  145.       bzip2 -d -c compiler3.bz2 > ./compiler3/$COMP
  146.       chmod ug+rx ./compiler3/ppcx64
  147.       rm ./compiler3.bz2
  148.  
  149.     else
  150.  
  151.       echo "Downloading compiler 3.0.4"
  152.       echo ""
  153.       wget --continue --quiet --show-progress -O compiler3.tar $COMP3_DOWNLOAD
  154.       echo ""
  155.       [ -f ./compiler3.tar ] || { echo >&2 "Download of bootstrap compiler failed. Aborting."; exit 1; }
  156.       mkdir -p ./compiler3/ex
  157.       tar xf compiler3.tar -C ./compiler3/ex --strip=1 >/dev/null
  158.       tar xvf ./compiler3/ex/binary.*-linux.tar -C ./compiler3/ex >/dev/null
  159.       tar zxvf ./compiler3/ex/base.*-linux.tar.gz -C ./compiler3/ex >/dev/null
  160.       mv $(find -name $COMP) ./compiler3
  161.       rm ./compiler3/ex -Rf
  162.       rm ./compiler3.tar
  163.  
  164.     fi
  165.    
  166.   fi
  167.  
  168. fi
  169. [ -x ./compiler3/$COMP ] || { echo >&2 "Bootstrap $BASE/compiler3/$COMP compiler not found. Aborting."; exit 1; }
  170.  
  171. # ======================================================
  172. # downloading fpc and lazarus
  173. # ======================================================
  174. echo "=============================================================="
  175. echo ""
  176. echo "Downloading FPC sources $(svn info fpc 2>&1 | grep Rev:)"
  177. echo ""
  178. # svn co https://svn.freepascal.org/svn/fpc/trunk fpc -r42644 >/dev/null
  179. svn co https://svn.freepascal.org/svn/fpc/trunk fpc >/dev/null
  180. [ -f ./fpc/Makefile ] || { echo >&2 "Download of fpc failed. Aborting."; exit 1; }
  181. echo "Now: $(svn info fpc | grep Rev:)"
  182. echo ""
  183.  
  184. echo "Downloading Lazarus sources $(svn info lazarus 2>&1 | grep Rev:)"
  185. echo ""
  186. # svn co https://svn.freepascal.org/svn/lazarus/trunk lazarus -r61689 >/dev/null
  187. svn co https://svn.freepascal.org/svn/lazarus/trunk lazarus >/dev/null
  188. [ -f ./lazarus/Makefile ] || { echo >&2 "Download of fpc failed. Aborting."; exit 1; }
  189. echo "Now: $(svn info lazarus | grep Rev:)"
  190. echo ""
  191.  
  192. # ======================================================
  193. # compiling fpc
  194. # ======================================================
  195. echo "=============================================================="
  196. echo ""
  197. echo "Now compiling FPC, this will take some time"
  198. echo ""
  199. cd $BASE/fpc
  200. make -s all install OPT="$OPTIONS_FPC" OS_TARGET=$OS_TARGET CPU_TARGET=$CPU_TARGET INSTALL_PREFIX=$BASE/fpc PP=$BASE/compiler3/$COMP \
  201.   | pv -l -bp >$BASE/fpc.log \
  202.   || { echo >&2 "Compilation of FPC failed. Aborting."; exit 1; }
  203. cd $BASE
  204. [ -x ./fpc/bin/fpc ] || { echo >&2 "Something went wrong compiling FPC. Aborting."; exit 1; }
  205.  
  206. echo ""
  207. echo "Doing some extra configuration"
  208. [ -f $HOME/.fpc.cfg ] && rm $HOME/.fpc.cfg
  209. ln -sf $BASE/fpc/lib/fpc/3.3.1/$COMP $BASE/fpc/bin/$COMP
  210. ln -sf $BASE/fpc/lib/fpc/3.3.1/samplecfg $BASE/fpc/bin/samplecfg
  211. $BASE/fpc/bin/fpcmkcfg -d basepath=$BASE/fpc -o $HOME/.fpc.cfg
  212.  
  213. # sudo find / -name crtbegin.o
  214. # This library needs to be added to the fpc.cfg file.
  215.  
  216. cat << EOF >> $HOME/.fpc.cfg
  217. -Fu$BASE/fpc/lib/fpc/\$fpcversion/units/\$fpctarget
  218. -Fu$BASE/fpc/lib/fpc/\$fpcversion/units/\$fpctarget/*
  219. -Fu$BASE/fpc/lib/fpc/\$fpcversion/units/\$fpctarget/rtl
  220. -Fl$(find / -name crtbegin.o -printf '%h\n' 2>/dev/null | head -n 1)
  221. -FD$BASE/fpc/bin
  222. EOF
  223.  
  224.  
  225. echo ""
  226.  
  227. # ======================================================
  228. # compiling lazarus
  229. # ======================================================
  230. echo "=============================================================="
  231. echo ""
  232. echo "Now compiling Lazarus, this will take some time"
  233. echo ""
  234. cd $BASE/lazarus
  235. make -s bigide OS_TARGET=$OS_TARGET CPU_TARGET=$CPU_TARGET OPT="$OPTIONS_LAZ" PP="$BASE/fpc/bin/fpc" \
  236.   | pv -l -bp >$BASE/laz.log \
  237.   || { echo >&2 "Compilation of Lazarus failed. Aborting."; exit 1; }
  238. cd $BASE
  239. [ -f ./lazarus/lazarus ] || { echo >&2 "Something went wrong compiling Lazarus. Aborting."; exit 1; }
  240.  
  241. echo ""
  242. echo "Doing some extra configuration"
  243. echo ""
  244.  
  245. # set path withhout old fpc
  246. PATH=$(echo $PATH | sed "s|$BASE/fpc/bin\:||g")
  247.  
  248. # strip previous $BASE from .profile
  249. sed -i '/# FPC PATH/,/fi/d' $HOME/.profile
  250.  
  251. cat << EOF >> $HOME/.profile
  252.  
  253. # FPC PATH
  254. if [ -d $BASE/fpc/bin ] ; then
  255.     PATH="$BASE/fpc/bin:\$PATH"
  256. fi
  257. EOF
  258.  
  259. # replace all double empty lines with one
  260. sed -i '/^$/N;/^\n$/D' $HOME/.profile
  261.  
  262. cat << EOF > $HOME/Desktop/Lazarus.desktop
  263. [Desktop Entry]
  264. Name=Lazarus
  265. Comment=Lazarus
  266. Icon=$BASE/lazarus/images/ide_icon48x48.png
  267. Exec=$BASE/lazarus/startlazarus
  268. Path=$BASE/lazarus
  269. Type=Application
  270. Encoding=UTF-8
  271. Terminal=false
  272. Categories=None;
  273. EOF
  274.  
  275. end=$(date +%s)
  276. echo "=============================================================="
  277. echo ""
  278. echo "$((($end-$begin) / 60)) minutes and $((($end-$begin) % 60)) seconds elapsed."
  279. echo ""
  280. echo "We are done. Please logout and back in before starting Lazarus"
  281. echo "Otherwise you need to supply the fpc location on 1st start"
  282. echo ""
  283. echo "=============================================================="
  284. echo ""
  285.  
  286. EEOF
« Last Edit: August 26, 2019, 04:31:26 pm by rvk »

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1106
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #23 on: August 26, 2019, 06:49:03 pm »
But because I also want the trunk version of FPC itself as end-result, I would only want to download FPC 3.0.4 with apt-get download and unpack the compiler and use that. In that case there are no lingering FPC files from an older version.
Ah, thats why you manually install the dependencies rather than let apt do it. Makes sense !
Yeah, I saw (with a dry-run) a whole lot of packages being installed too.
Just doing this gave me an ppcarm compiler (FPC) which should also just work fine as bootstrap compiler without all the other junk (I hope, didnt test yet).
Very interesting.
When you finish, could you write a wiki or blog article about your discoverings and solution?
Thanks.

Linkat

  • New Member
  • *
  • Posts: 19
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #24 on: August 27, 2019, 06:34:12 am »
Hi, this thread is an very good example, how a discussion shouldn't work.
With one thank you post, and about 20 posts missing the topic.
But this was exactly the reason writing the tutorial.
You can find a lot of old descriptions or installation scripts, which are no more up-to-date and have all these different problems.

@Mi-Ki, if you did use the tutorial, you could find the sudo before ./install.sh

@rvk, why an installation of Lazarus as root is an absolutely no go? If you have more then one user, an installation in the home space is not very useful. For installing a program you almost do it as root.

Back to topic.

Again the question to the experts:
Why no lazarus-stable-deb package of the current version (like the deb- and rpm-packages for Intel/AMD) exists for the raspbian OS?
It would be very helpful for the beginners. And it would bring a lot of new users.

Linkat

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #25 on: August 27, 2019, 10:46:29 am »
Hi, this thread is an very good example, how a discussion shouldn't work.
With one thank you post, and about 20 posts missing the topic.

Yes Linkat, you are probably right in some respects. I would be the last person to discourage anyone from contributing documentation for fpc/lazarus. So, thank you !

@rvk, why an installation of Lazarus as root is an absolutely no go? If you have more then one user, an installation in the home space is not very useful. For installing a program you almost do it as root.
Every time you install a package, you rebuild lazarus. And the 'copy' of lazarus you are talking about is in a read only part of your hard disk. Hmm, how is that possible ? Because, behind the scenes, lazarus realises you are trying to do something a bit odd, it cleverly deflects all your rebuild and puts it in a hidden copy below your home dir. So, from very first rebuild, you are no longer using that copy you have installed in /usr. This is done to help people who install from binaries such as debs or rpms.  Unnecessary complication and a total waste of diskspace if you are building your own however.
 
Further, you will find that as you use lazarus, you are often browsing through the LCL code in particular, maybe you want to add a debug statement, fix a bug or what ever. But you cannot, its read only !

Next, you decide you would like to have a look at a trunk or fixes version, Lazarus is a rapidly evolving product. But doing that is a lot harder if if your main copy of Lazarus is locked into /usr.   

Finally, as a very long term Unix System Admin, take my word for it, nothing should be in the system area that can live in user space.  On a true multiuser system, no developer would want to be sharing, for example, the LCL.

Why no lazarus-stable-deb package of the current version (like the deb- and rpm-packages for Intel/AMD) exists for the raspbian OS?
It would be very helpful for the beginners. And it would bring a lot of new users.

Please see http://www.raspberryconnect.com/raspbian-packages/29-raspbian-devel
There you will that there are (Buster) debs for fpc304 and Lazarus200. So, if you are happy with the limitations of using them, why not just use them ?
However, Lazarus200 is two releases behind the current version and, as I said earlier, you are far, far better off building your own Lazarus (but using the distro version of fpc). Its  impossible for any timed release disro to have all the uptodate versions of all packages. Anyway, thats a question you should take to Debian or Raspian, not here.

But Linkat, please don't be discouraged. That you took the time to write up that tutorial is a good thing, with a bit more experience I am very sure you will be a very valuable contributor to fpc/lazarus. But, we all have to accept that sometimes, we get stuff wrong. Thats better than not trying at all !

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

ttomas

  • Full Member
  • ***
  • Posts: 245
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #26 on: August 27, 2019, 11:03:08 am »

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #27 on: August 27, 2019, 11:24:29 am »
Neat ttomas, do you use zram to provide swap (zswap like) or use it to make extra ram ?

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

kupferstecher

  • Hero Member
  • *****
  • Posts: 583
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #28 on: August 27, 2019, 12:27:04 pm »
Why no lazarus-stable-deb package of the current version (like the deb- and rpm-packages for Intel/AMD) exists for the raspbian OS?

Please see http://www.raspberryconnect.com/raspbian-packages/29-raspbian-devel
There you will that there are (Buster) debs for fpc304 and Lazarus200. So, if you are happy with the limitations of using them, why not just use them ?
[...]
Its  impossible for any timed release disro to have all the uptodate versions of all packages. Anyway, thats a question you should take to Debian or Raspian, not here.
It's imho not a question to take to Debian or Raspian, the reason you already mentioned:
"Its  impossible for any timed release disro to have all the uptodate versions of all packages."

I see it the same as Linkat, for a non-experienced user the best way would be up-to-date fpc/Lazarus packages provided from official side, i.e. on lazarus-ide.org. And even for experienced users this could mean a smoother/quicker installation.
By the way, the fpc binaries are available, but not the Lazarus ones: https://freepascal.org/download.html

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Tutorial: Install Lazarus to Raspberry Pi
« Reply #29 on: August 27, 2019, 01:33:02 pm »
I see it the same as Linkat, for a non-experienced user the best way would be up-to-date fpc/Lazarus packages provided from official side, i.e. on lazarus-ide.org. And even for experienced users this could mean a smoother/quicker installation.
Hi kupferstecher, we'll have to disagree  there. As I said in above very long winded post, in my opinion by far the best Lazarus install for most users is to build from source in user's home directory. Its not much harder than a binary install and is much more usable. Its only four commands !

By the way, the fpc binaries are available, but not the Lazarus ones: https://freepascal.org/download.html
Thats not a deb install you realise ? Right now we are lucky, Buster has current fpc in its repo and just needs one (su) command to install. Why do anything else ?

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018