Fix samplecfg tool to be compatible with multiarch compiler paths.
authorAbou Al Montacir <abou.almontacir@sfr.fr>
Wed, 30 Dec 2020 21:21:46 +0000 (22:21 +0100)
committerAbou Al Montacir <abou.almontacir@sfr.fr>
Sat, 7 Jan 2023 12:07:32 +0000 (12:07 +0000)
(Closes: Bug#975351)

Gbp-Pq: Name fix-samplecfg-tool.patch

fpcsrc/compiler/utils/samplecfg

index 592b8df23efdb444727604edeb68f025a6ba275a..882c37824807f4396b37ae18f5f9b96764e00e2e 100644 (file)
@@ -15,7 +15,7 @@ if [ $# = 0 ]; then
   echo 'confdir = Path to /etc'
   echo 'Example :'
   echo 'samplecfg /usr/local/lib/fpc/3.0.2'
-  exit 1
+  fpcdir=${1:-`dirname $0`}
 fi
 if [ "$2" ]; then
   sysdir="$2"
@@ -23,17 +23,19 @@ if [ "$2" ]; then
 else
   sysdir=/etc
 fi
-FPCBIN=`dirname "$1"`/../../bin/fpc
-FPBIN=`dirname "$1"`/../../bin/fp
-FPPKGBIN=`dirname "$1"`/../../bin/fppkg
-FPCMKCFGBIN=`dirname "$1"`/../../bin/fpcmkcfg
-SHAREPATH=`dirname "$1"`/../../share/fpc/\$fpcversion
+fpcdir=`realpath -s "${fpcdir}"`
+echo 'Running with fpcdir="'${fpcdir}'"'
+FPCBIN=/usr/bin/fpc
+FPBIN=/usr/bin/fp
+FPPKGBIN=/usr/bin/fppkg
+FPCMKCFGBIN=/usr/bin/fpcmkcfg
+SHAREPATH=/usr/share/fpc/\$fpcversion
 # Look for one in the PATH, if no new one was installed.
 if [ ! -f $FPCMKCFGBIN ]; then
   FPCMKCFGBIN=fpcmkcfg
 fi
 
-sysfpdirbase=`dirname "$1"`/`"$FPCBIN" -iV`
+sysfpdirbase=`dirname "${fpcdir}"`/`"$FPCBIN" -iV`
 sysfpdirbase2=$sysfpdirbase/ide
 sysfpdir=$sysfpdirbase2/text
 
@@ -72,10 +74,10 @@ if [ -f "$FPBIN" ] ; then
 fi
 
 # set right path to FPC with $fpcversion
-FPCPATH=`dirname "$1"`/\$fpcversion
+FPCPATH=`dirname "${fpcdir}"`
 # set right prefix to FPC
-FPCGLOBALPATH=`dirname "$1"`
-FPCGLOBALPREFIX="$FPCGLOBALPATH"/../../
+FPCGLOBALPATH=`dirname "${FPCPATH}"`
+FPCGLOBALPREFIX=/usr
 
 # Write (.)fpc.cfg
 echo Writing sample configuration file to $fpccfgfile