View previous topic :: View next topic |
Author |
Message |
evermind Guru
Joined: 10 Jan 2004 Posts: 322
|
Posted: Sat Oct 15, 2005 8:22 am Post subject: libstdc++.la: No such file or directory -- script to solve |
|
|
BIG FAT WARNING
nxsty mentioned that there is allready a rewrite for fix_libtool_files.sh on the way
bug#90744
after reading the comments there I saw that just replace strings in every *.la could
introduce binary incompatiblity and won´t save the real problem.
So I really deprecate the use of my script
------------------------------------------
I wrote a script for solving my issue with the missing of the right libstdc++.la path in *.la files
after upgrading to a newer gcc-version.
I knew there is allready fix_libtool_files.sh but it didn´t work like I want.
If I ran
Code: | fix_libtool_files.sh 3.3.6 3.4.4 |
some files get fixed others not. So I wrote this script.
maybe it helps others too.
Features
- backup all *.la files
- change gcc-versions in *.la files
- replace paths in *.la files
- search expression in *.la files
backup
backups will be stored in
~/backup_la-files/
Each time the script finds a *.la file to be altered
a backup copy is placed in
~/backup_la-files/2005-10-14_session-0/
next time the script runs and changs something and the
first backup allready exists it will copy the files into:
~/backup_la-files/2005-10-14_session-1
here all options of the script is shown
Code: | evermind@crazyfury (67 ~) $ ./fix_la-libs2 -h
-g, --gcc-version change gcc-version in *.la files
e.g -g 3.3.6 3.4.3
-p, --replace-paths change paths in *.la files
e.g -p /old/path/ /new/path/
-s, --search search expression in *.la files
e.g -s gcc-lib
-h, --help display help
-v, --version display version |
with -p you can replace entire paths in *.la files so be careful with this option
e.g
Code: | ./fix_la-libs2 -p /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/libstdc++.la /usr/lib/gcc/i686-pc-linux-gnu/3.4.4/libstdc++.la |
so here is the script: fix_la-libs2
WARNING: THIS SCRIPT IS NOT FULLY TESTED SO IT COULD KILL YOUR INSTALLATION or FILES
USE IT AT YOUR OWN RISK
Code: | #!/bin/bash
# license gpl v2
# this script fix all *.la files which containing old compiler-versions which not exists
#################################
# v0.1 2005-06-14 initial release
# v0.2 2005-10-14 fixes/enhancements
# now you can replace paths in *.la files with the -p option and -s regexp to search *.la files
# WARNING: use this option with care
# e.g -p /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/libstdc++.la /usr/lib/gcc/i686-pc-linux-gnu/4.0.2/libstdc++.la
VERSION="0.2 2005-10-14"
CMDLINE=$@
umask 0022
#######settings########
# set the paths to scan you can adjust it here
# but only paths with lib in it will work
LIB_PATHS="/usr/qt /usr/local /lib /usr/lib /opt /usr/games/lib /usr/kde /usr/i*-pc-linux-gnu/lib"
# path to store-backups (each session will be in a seperated dir)
BACKUP_BASE_PATH="${HOME}/backup_la-files"
###############
source /sbin/functions.sh
DATESTAMP="`date +'%F'`"
function display_version(){
local SILENT=$1
[ "$SILENT" == "silent" ] && echo "${VERSION%% *}" || echo "This is version: ${VERSION%% *}"
}
function setup_backup_path(){
[ "x${HOME}" == "x" ] && eerror "no valid homedir present: ${HOME}" && exit
CNT=0
BACKUP_PATH="${BACKUP_BASE_PATH}/${DATESTAMP}_session-${CNT}"
while [ -e "${BACKUP_PATH}" ];do
let CNT+=1
BACKUP_PATH="${BACKUP_BASE_PATH}/${DATESTAMP}_session-${CNT}"
done
}
function get_arch(){
local machine_run=`uname -m`
local matching_arch=`ls /usr/|awk -F- '$0 ~ /linux-gnu/ {printf "%s " ,$1}'`
set -- $matching_arch
for arch in ${matching_arch[@]};do
if [ "`uname -m`" == "$arch" ];then
USE_THIS_ARCH=$arch
local ARCH_FND="1"
break
fi
done
if [ "x${ARCH_FND}" != "x1" ];then
eerror "could not determine your arch: $arch" && exit 1
fi
}
function check_tools(){
local TOOLS="awk sed grep"
TOOLS=($TOOLS)
for tool in "${TOOLS[@]}" ;do
if ! type $tool &> /dev/null ; then
einfo "Install $tool and run this script again"
exit 1
fi
done
}
function check_vars_empty(){
# check if any of the needed vars is empty
if [ "x" == "x${FIND_EXP}" -o "x" == "x${REPLACE_EXP}" -o "x" == "x${ARCH}" ];then
eerror "check your cmdline: ./`basename $0` ${CMDLINE[@]}"
exit 1
fi
}
function get_files(){
local LIB_PATH=$1
find $LIB_PATH -iname '*.la' 2>/dev/null|awk '$0 ~ /lib/ {printf "%s ", $0}'
}
function backup_file(){
local FILE=$1
local BACKUP_PATH=$2
local WHOLE_BACKUP_PATH=${BACKUP_PATH}${FILE%/*}
[ ! -e "$BACKUP_PATH" ] && mkdir -p $BACKUP_PATH
[ ! -e "$WHOLE_BACKUP_PATH" ] && mkdir -p $WHOLE_BACKUP_PATH
ewarn " BACKUP: ${FILE##*/}" to $WHOLE_BACKUP_PATH
cp -a $FILE $WHOLE_BACKUP_PATH
}
function fix_file(){
local FILE=$1
ewarn " FIXING: ${FILE##*/}"
if [ "x${ENABLE_PATHS}" == "x1" ];then
sed -i -e "s|${FIND_EXP}|${REPLACE_EXP}|" $FILE
else
sed -i -e "s|\/${ARCH}\/${FIND_EXP}|\/${ARCH}\/${REPLACE_EXP}|" $FILE
fi
}
function select_files(){
local SELECT_FILES=$1
local LIB_PATH=$2
IFS=" "
set -- $SELECT_FILES
for FILE in ${SELECT_FILES[@]};do
if [ "x${ENABLE_PATHS}" == "x1" ];then
grep -q -e "${FIND_EXP}" $FILE
else
grep -q -e "\/${ARCH}\/${FIND_EXP}" $FILE
fi
if [ "$?" == "0" ];then
if [ "${ENABLE_SEARCH}" == "1" ];then
einfo [match] $FILE
else
backup_file "$FILE" "$BACKUP_PATH"
fix_file $FILE
fi
fi
done
}
check_tools
# check for cmdline parameters
while [ ${#} -gt 0 ]
do
a=${1}
shift
case "${a}" in
-h|--help)
echo -e "-g, --gcc-version change gcc-version in *.la files"
echo -e " e.g -g 3.3.6 3.4.3"
echo -e "-p, --replace-paths change paths in *.la files"
echo -e " e.g -p /old/path/ /new/path/"
echo -e "-s, --search search expression in *.la files"
echo -e " e.g -s gcc-lib"
echo -e "-h, --help display help"
echo -e "-v, --version display version"
exit
;;
-g|--gcc-version)
ENABLE_PATHS="0"
get_arch
ARCH=$USE_THIS_ARCH-pc-linux-gnu
FIND_EXP="${1}"
if [ "xchoice" == "x${1/[[:digit:]].[[:digit:]].[[:digit:]]/choice}" ];then
shift
else
eerror "no old_path gcc-version-given"
exit 1
fi
REPLACE_EXP="${1}"
if [ "xchoice" == "x${1/[[:digit:]].[[:digit:]].[[:digit:]]/choice}" ];then
shift
else
eerror "no old_path gcc-version-given"
exit 1
fi
;;
-p|--replace-paths)
ENABLE_PATHS="1"
FIND_EXP="${1//\//\\/}"
if [ "x" != "x$1" ];then
shift
else
eerror "no old_path given"
exit 1
fi
REPLACE_EXP="${1//\//\\/}"
if [ "x" != "x$1" ];then
shift
else
eerror "no new_path given"
exit 1
fi
ARCH="VAR_NOT_USED"
;;
-s| --search)
ENABLE_PATHS="1"
ENABLE_SEARCH="1"
FIND_EXP="${1//\//\\/}"
REPLACE_EXP="VAR_NOT_USED"
ARCH="VAR_NOT_USED"
if [ "x" != "x$1" ];then
einfo "search for files matching: ${FIND_EXP}"
shift
else
eerror "no expression given"
exit 1
fi
;;
-v| --version)
display_version
exit
;;
* ) echo "Unimplemented option chosen."
exit
;; # DEFAULT
esac
done
# get/check commandline argument
check_vars_empty
setup_backup_path
set -- $LIB_PATHS
LIB_PATHS=($LIB_PATHS)
LIB_PATHS_LENGTH="${#LIB_PATHS[@]}"
CNT=0
for LIB in ${LIB_PATHS[@]};do
einfo " [${CNT}/${LIB_PATHS_LENGTH}] Scanning ${LIB}/..."
let CNT+=1
FILES=$(get_files "$LIB")
select_files "$FILES" "${LIB}"
done
[ "${ENABLE_SEARCH}" == "1" ] && einfo "search for files matching: ${FIND_EXP}"
|
Last edited by evermind on Sat Oct 15, 2005 3:20 pm; edited 1 time in total |
|
Back to top |
|
|
bmichaelsen Veteran
Joined: 17 Nov 2002 Posts: 1277 Location: Hamburg, Germany
|
|
Back to top |
|
|
Earthwings Bodhisattva
Joined: 14 Apr 2003 Posts: 7753 Location: Germany
|
Posted: Sat Oct 15, 2005 11:44 am Post subject: |
|
|
What about fixing fix_libtools_files and filing a bug report with a patch? Moved from Portage & Programming to Unsupported Software. _________________ KDE |
|
Back to top |
|
|
evermind Guru
Joined: 10 Jan 2004 Posts: 322
|
Posted: Sat Oct 15, 2005 2:02 pm Post subject: |
|
|
maybe if someone find this script useful
Earthwings wrote: | What about fixing fix_libtools_files and filing a bug report with a patch? Moved from Portage & Programming to Unsupported Software. |
maybe but fix_libtool_files.sh is partially written for awk and I`ve written for bash.
So if the error will occur for me once again and fix_libtool_files.sh could not solve it
I maybe write a patch for it |
|
Back to top |
|
|
nxsty Veteran
Joined: 23 Jun 2004 Posts: 1556 Location: .se
|
|
Back to top |
|
|
evermind Guru
Joined: 10 Jan 2004 Posts: 322
|
Posted: Sat Oct 15, 2005 3:20 pm Post subject: |
|
|
ok so I think this is issue is more complicated then just change the paths in *.la files
so I edit my post above and add a warning with a reference to this bug |
|
Back to top |
|
|
|