« Auto-éditer un wikilivre/Annexer (Version internationalisée)/cp-src2bin.sh » : différence entre les versions

Un livre de Wikilivres.
Contenu supprimé Contenu ajouté
m Révision
Ajout du script compil2bin.bash
Ligne 1 : Ligne 1 :
== 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}}
; {{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 )
; Install this executable shell code in sbin ( /usr/local/sbin | ~/Add_appendix/sbin | ~/Annexer/sbin )

Version du 5 octobre 2021 à 16:34

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
.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

old version cp-src2bin.sh

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 )
Installer ce code shell éxécutable dans sbin
espagnol ; Instale este código de shell ejecutable en sbin
#! /bin/bash
#P File : .../sbin/cp-src2bin.sh. This file must be copied in executable mode
#P Copy the source files to the executables directory.
#P The tests directory is used to individual test bash files from annex programm.

clear

VERSION=210419

if [ "$1" = "--v" ]; then echo "cp-src2bin.sh : VERSION $VERSION rrevised on Sep 18, 2021"; exit 0; fi

#P Find the current directory
    pwd > pwd.txt
    read Currentdir<pwd.txt

#P Find the working name directory
    cat pwd.txt | cut -d "/" -f4 > workname.txt
    read Workname<workname.txt
	echo -n "Working name directory= $Workname"
	if [ $Workname = "Annexer" ] || [ $Workname = "Add_appendix" ]
	then echo " is found"; 
	else echo " is not a working name directory"; exit -1
	fi
	
#P Find full directories install, working etc.
	source ~/$Workname/vars/installdir.var
    echo "Install directory : $Installdir"
	echo "Working dir : $Workdir"

#T Test break exit 0

#P Make list files.pj 
    echo "Make files list from src directory in files.pj"
    ls -1 $Installdir/src/*.sh > files.pj

#P If files.pj is not empty copy all files *.sh to executable directory
    if [ -s "files.pj" ]
    then
      echo "files in files.pj :"
      cat files.pj
    else
      echo "files.pj is empty, exit from cp-src2bin.sh"
      exit 1
    fi

#P Copy copy without extension .sh, and make files executables
    echo "#####################################################################"
    echo "# Warning: this script move all src/*.sh to bin/* without comments. #"
    echo "# Warning: is not available to product POT files for translations.  #"
    echo "#####################################################################"
    while read line
    do
#T      echo "copy the ligne $line from files.pj '.sh' in the file exename without extension .sh"
      echo $line | sed s/.sh//g | awk -F "/" '{print $NF}'> exename.txt

#P   Affect the value in 'exename.txt' at the variable $Exename
      read Exename < exename.txt
      echo "copy $Installdir/src/$Exename.sh to $Installdir/bin/$Exename"
      cat $Installdir/src/$Exename.sh | grep -v "#O\|#P\|#T" >  $Installdir/bin/$Exename
      echo "Add mode 755 'executable' at file $Installdir/bin/$Exename"
      chmod 755 $Installdir/bin/$Exename
      echo "----"
    done < files.pj
#T Breakpoint exit 0

#P clean sbin directory
    rm files.pj pwd.txt exename.txt

#P End cp-src2bin