Différences entre les versions de « Auto-éditer un wikilivre/Annexer (Version internationalisée)/cp-src2bin.sh »

Aller à la navigation Aller à la recherche
Ajout du script compil2bin.bash
m (Révision)
(Ajout du script compil2bin.bash)
== Compil2bin.bash ==
* Attention this script is common for lib, sbin, and src for Add_appendix software
* this script is used in package ''addappendix-O~210927''
<syntaxhighlight lang="bash"
#!/bin/bash
#H File : compil2bin
#D Documentation for compil2bin shell file
#D Compil2bin is used in package to product addappendix-<version>.deb and
#D to copy sources files to bin directories
#D Syntax : compil2bin $(SRC) [ $(BIN) | $(SBIN) | $(LIB) ] <file-list>
#D Example: compil2bin ~/Add_appendix/src ~/Add_appendix/bin addappendix pre-annex annex etc.
#D Compilation shell bash file-list product binaries files to directories
#D specified in first parameter.
#D file-list are shell files to compil from $(SRC) directory
#D The compilation consists of eliminating the #D#O#P comments and producing
#D the .pot files for the translations
 
VERSION=210928
 
#T echo "Sources = $1 ; Bin is : $2"; exit 0
 
#O Afficher la version si le prelier argument est --v
if [ "$1" = "--t" ]; then clear screen; echo "compil2bin version $VERSION"; exit 0; fi
 
#O Affect Srcdir variable
if test -d "$1" || test -e "$1"/addappendix.sh ]; then echo "Sources directory is found: $1"; Srcdir=$1; else echo "Sources directory is not found"; exit -1; fi
#O Affect bindir variable
if test -d "$2"; then Bindir="$2"; echo "Variable Bindir is $Bindir"; else echo "$2 bin directory not found"; exit -1; fi
#O Affect Resourcesdir variable
if test -d "./resources"; then Resourcesdir="./resources"; echo "Variable Resources is found: $Resourcesdir"; fi
 
#O Indiquer le nombre de pamètres
echo "Number of parameter : $#"
#T exit 0
 
function cpcleaned2bin
{
#O Print $1
echo "*** $1 *** in cpcleaned2bin"
#O Cleaner
mkdir -p ./tmp
cat ./$Srcdir/$1.sh | grep -v "#O\|#P\|#T" | sed "s/eval_gettext /echo \$/g" | sed "s/; echo//g" \
| sed "s/\"\$(gettext '/\$\"/g" | sed "s/' )//g" | sed "s/')//g" > ./tmp/$1
cp ./tmp/$1 $Bindir/$1
if echo $Bindir/$1 | grep ".inc"; then chmod 644 $Bindir/$1; else chmod 755 $Bindir/$1; fi
#O Create new .pot files
xgettext -L shell -o $Resourcesdir/lang/po/$1.pot --from-code=UTF-8 $Bindir/$1
#O Create or update fr .po files
if test -z $Resourcesdir/lang/po/fr/$1.po
then cp $Resourcesdir/lang/po/$1.pot $Resourcesdir/lang/po/fr/$1.po
else msgmerge --update $Resourcesdir/lang/po/fr/$1.po $Resourcesdir/lang/po/$1.pot
fi
#O Create or update fr .mo files in resources directory
msgfmt $Resourcesdir/lang/po/fr/$1.po -o $Resourcesdir/lang/po/fr/$1.mo
echo -e "\033[1;33m### Only if you are edit and update $1.po with Poedit: ###\033[0m"
echo "copy $Resourcesdir/lang/po/fr/$1.mo to /usr/share/locale/fr/LC_MESSAGES/$1.mo"
#O Create or update es .po files
if test -z $Resourcesdir/lang/po/es/$1.po
then cp $Resourcesdir/lang/po/$1.pot $Resourcesdir/lang/po/es/$1.po
else msgmerge --update $Resourcesdir/lang/po/es/$1.po $Resourcesdir/lang/po/$1.pot
fi
#O Create or update fr .mo files in resources directory
msgfmt $Resourcesdir/lang/po/es/$1.po -o $Resourcesdir/lang/po/es/$1.mo
echo -e "\033[1;33m### Only if you are edit and update $1.po with Poedit: ###\033[0m"
echo "copy $Resourcesdir/lang/po/es/$1.mo to /usr/share/locale/es/LC_MESSAGES/$1.mo"
rm -r ./tmp
}
 
#O Create loop to ...for i in `seq 1 $#`
for i in "$@"
do
if test $i != $1 && test $i != $2
then
echo "$i"
cpcleaned2bin $i
fi
done
#O End of compil2bin
</syntaxhighlight>
 
== old version cp-src2bin.sh ==
; {{rouge|WARNING, this is an old version revised on Sep 18, 2021}}
; Install this executable shell code in sbin ( /usr/local/sbin | ~/Add_appendix/sbin | ~/Annexer/sbin )

Menu de navigation