Auto-éditer un wikilivre/Annexer (Version internationalisée)/install annex.sh

Un livre de Wikilivres.
Aller à la navigation Aller à la recherche

Description - Recommandations[modifier | modifier le wikicode]

  • install_annex.sh is tested with test_install_annex.bash and Copy2Tmp.bash
  • This script install Add_appendix or Annexer for single user or Add_appendix for all users
  • Syntax to install and tests: The scripts to tests are all in user working tests directory
$HOME/Tmp/test_install_annex.bash
  • Syntax to install directly:
$HOME/Tmp/install_annex.sh Add_appendix
$HOME/Tmp/install_annex.sh Annexer
$HOME/Tmp/install_annex.sh /usr/local

install_annex.sh[modifier | modifier le wikicode]

#! /bin/bash
#H File install_annex.sh in ~/tmp or re-install_annex.sh in /usr/local/sbin directory
#H Codage UTF-8 sans BOM
#H Syntax : ~/Add_appendix/sbin/install_annex.sh [Install directory | ? ]
#H   The installation directory can be /usr/local or /usr or ~/Annexer or ~/Add_appendixby default
#P Creation date     : 2020/06/10 by GC
#P Modification date : 2020/06/12 by GC 
#P Modification date : 2021/05/19 by GC
#P Last test date    : 2021/05/19 by GC
#P This program installs the directory structure for the annex program of wikibooks.
#P

#P . gettext for translation
#P . gettext.sh

#O Include function users_install_annex.sh
function users_install_annex ()
{
#T Tests
     echo "First param : $1"
#O Create variables : Workdir, Bindir
    if [ $1 = "Add_appendix" ]; then Workdir=~/Add_appendix; echo "Workdir = "$Workdir; fi
    if [ $1 = "Annexer" ]; then Workdir=~/Annexer; echo "Workdir = "$Workdir; fi
    if [ -d $Workdir ]; then echo " $Workdir is present."; else echo " $Workdir is not present, i create it."; mkdir $Workdir; fi
    
    Bindir="$Installdir/bin"; echo "Bindir : "$Bindir 
    if test -d $Bindir
    then echo " is ok." 
    else echo " not present, create it"; mkdir $Bindir 
    fi
#T Breakpoint exit 0

#O Create or recreate directory hierarchy
    cd $Workdir
    echo -n "The current directory to create $Workdir sub directories = "; pwd
    mkdir bin books datas lib man lib/src resources sbin share src temp tests vars
    cd $Workdir/tests
    echo "$Workdir/tests is the current directory to create sub tests directories."; pwd
    mkdir 00-install_annex 0-pre-annex.sh 1-annex.lib 2-annex.sh 3-header.inc.sh 4-list.sh 5-download.sh 6-add_sclt.sh
    mkdir 7-scli.inc.sh 8-add_sclic.sh 9-add_sclipco.sh 10-add_sclipwb.sh 11-annexer.sh 12-add_appendix.sh

    cd $Workdir/share
    echo "$Workdir/share is the current directory to create sub share directories."; pwd
    mkdir man doc doc/html 
    mkdir -p man man/{man1,fr,fr/man1,fr.UTF8,fr.UTF8/man1,es,es/man1}
    mkdir -p locale locale/{en,en/LC_MESSAGES,fr,fr/LC_MESSAGES,es,es/LC_MESSAGES}
#T Breakpoint exit 0

#O If findbook.sh, ecfpb.sh, ecfpc.sh, exist in the lib/src directory, build the annex.lib file
    if test -e $Workdir/lib/src/findbook.sh && test -e $Workdir/lib/src/ecfpb.sh && test -e $Wordir/lib/src/ecfpc
    then
      cat $Workdir/lib/src/findbook.sh | grep -v "#O\|#P\|#T" > $Workdir/lib/annex.lib
      cat $Workdir/lib/src/ecfpb.sh | grep -v "#O\|#P\|#T" >> $Workdir/lib/annex.lib
      cat $Workdir/lib/src/ecfpc.sh | grep -v "#O\|#P\|#T" >> $Workdir/lib/annex.lib
    else echo "annex.lib is not builded or not updated in $Workdir/lib/annex.lib"
    fi

#O If file annex.lib not exist in $Libdir and if file annex.lib.sh exist in $Libdir/src, 
    if test -z $Workdir/lib/annex.lib && test -e $Workdir/src/annex.lib.sh
    then cat $Workdir/src/annex.lib.sh | grep -v "#O\|#P\|#T" > $Workdir/lib/annex.lib
    fi
      
    rm $Workdir/vars/installdir.var
    echo "Installdir=$Installdir" > $Workdir/vars/installdir.var
    echo "Workdir=$Workdir" >> $Workdir/vars/installdir.var    
    echo; echo "Content of file $Workdir/vars/installdir.var"
    cat $Workdir/vars/installdir.var
	
	if [ "$1" = "Annexer" ]
	then 
	  echo; echo "First param = $1"
	  echo; echo "Se connecter à l'url :"
	  echo "https://fr.wikibooks.org/wiki/Autoéditer_un_wikilivre/Annexer_(Version_internationalisée)#src.orig_en_français"
	  echo "Copier les pages de codes, les coller dans un éditeur de texte et les enregistrer dans les répertoires spécialisés"
	  echo "Les fichiers : "
	  echo " sources, dans le répertoire $1/src"
	  echo " de données dans $1/datas"
	  echo " de librairies, dans $1/lib"
	  echo " d'exécutables de maintenance, dans  $1/sbin (chmod 755 * dans sbin)"
	  echo " de documentation dans $1/share/doc"
	  echo " de manuels dans $1/share/man"
	  echo "Utiliser cette version imprimable : "
	  echo "   https://fr.wikibooks.org/wiki/Auto-éditer_un_wikilivre/Annexer_(Version_internationalisée)/Version_imprimable"
	  echo "   pour copier les codes bash"
	  echo; echo "Finalement rééxécuter cette commande ~/Annexer/sbin/users_install_annex.sh"
	fi
	  
	if [ "$1" = "Add_appendix" ] 
	then 
	  echo; echo "First param = $1"
	  echo; echo "Login to url :"
	  echo "https://fr.wikibooks.org/wiki/Autoéditer_un_wikilivre/Annexer_(Version_internationalisée)#Codes_sources_(internationalized_source_code)"
	  echo "Copy code pages in memory, paste them in a text editor and save in the specialized directory"
	  echo "The files :"
	  echo " sources in the directory Add_appendix/src"
	  echo " datas in Add_appendix/datas"
	  echo " library in Add_appendix/lib"
	  echo " executable for maintenance, in Add_appendix/sbin (chmod 755 * in sbin)"
	  echo " documentation in Add_appendix/share/doc"
	  echo " manuals in Add_appendix/share/man"
	  echo "Use this printable version : " 
	  echo "   https://fr.wikibooks.org/wiki/Auto-éditer_un_wikilivre/Annexer_(Version_internationalisée)/Version_imprimable"
	  echo "   to copy the bash code"
	  echo; echo "Finaly reexecute this command ~/Add_appendix/sbin/users_install_annex.sh"
	fi    
    echo

#O Initialize $Conversions variable
    Datasdir=$Workdir/datas; echo "Datadir = $Datasdir"
    Conversions=$Datasdir/conversions.dat; echo "Conversion file = $Conversions" 

#O Create or recreate the conversions.dat file in datas directory
    if test -e $Conversions
    then echo "The $Conversions file is present and will not be updated"
    else 
    {
      echo "s/%24/\$/g;s/%21/\!/g;s/%25/%/g;s/%2B/+/g;s/%3C/\\\&lt\;/g;s/%3E/\&gt\;/g;" > $Conversions
      echo "s/%5C/\\\/g;s/%B0/°/g" >> $Conversions
      echo "s/%E0/à/g;s/%E2/â/g" >> $Conversions
      echo "s/%E8/è/g;s/%E9/é/g;s/%EA/ê/g;s/%EB/ë/g" >> $Conversions
      echo "s/%EE/î/g;s/%EF/ï/g" >> $Conversions
      echo "s/%F4/ô/g" >> $Conversions
      echo "s/%F9/ù/g;s/%FB/û/g" >> $Conversions
      echo "s/%25/%/g;" >> $Conversions
      echo "s/%28/(/g;s/%29/)/g;" >> $Conversions
      echo "s/%2B/+/g;" >> $Conversions
      echo "s/%3A/:/g;" >> $Conversions
      echo "s/%3D/=/g;" >> $Conversions
      echo "s/%5B/[/g;" >> $Conversions
      echo "s/%5D/]/g" >> $Conversions
      echo "s/%3B/;/g;s/%2F/\//g;s/%27/'/g" >> $Conversions
      echo 's/%22/"/g' >> $Conversions
      echo "s/%C3%A7/ç/g;s/%E7/ç/g" >> $Conversions
      echo "s/%C3%A0/à/g;s/%C3%A2/â/g" >> $Conversions
      echo "s/%C3%A9/é/g;s/%C3%A8/è/g;s/%C3%AA/ê/g" >> $Conversions
      echo "s/%C3%AE/î/g;s/%C3%AF/ï/g" >> $Conversions
      echo "s/%C3%B4/ô/g" >> $Conversions
      echo "s/%C3%B9/ù/g;s/%C3%BB/û/g" >> $Conversions
      echo "s/%C2%B7/-/g;s/%C2%AB/«/g;s/%C2%BB/»/g" >> $Conversions
    }
    fi
    echo "----"

#O Initialize $Content_cleaner variable
    Content_cleaner=$Datasdir/content_cleaner.dat 
    echo "Content_cleaner = $Content_cleaner"
#O If not exist create the content_cleaner.dat  in datas directory
    if test -e $Content_cleaner
    then echo "The $Content_cleaner file is present and will not be updated"
    else 
    {
      echo "s/: \[/\[/g;s/:\[/\[/g" > $Content_cleaner
      echo "s/# \[/[/g;s/#\[/\[/g" >> $Content_cleaner
      echo "s/* \[/[/g;s/*\[/\[/g" >> $Content_cleaner
      echo "s/; /;/g" >> $Content_cleaner
    }
    fi
    echo "----"  
    
#O Initialize $Unrecognized_links variable
    Unrecognized_links=$Datasdir/unrecognized_links.dat
    echo "Unrecognized_links = $Unrecognized_links"
#O If not exist, create the file Unrecognized_links.dat
    #O If not exist create the content_cleaner.dat  in datas directory
    if test -e $Unrecognized_links
    then echo "The $Unrecognized_links file is present and will not be updated"
    else
    {
      echo "fr.wikibooks.org: unrecognized_link.dat ignore les liens non contenus dans les pages Résumé ou Sommaire"
      echo "title" > $Unrecognized_links
      echo "Spécial" >> $Unrecognized_links
      echo "Accueil" >> $Unrecognized_links
      echo "Vitrine" >> $Unrecognized_links
      echo "Tous_les_livres" >> $Unrecognized_links
      echo "Rechercher_un_livre" >> $Unrecognized_links
      echo "Wikijunior" >> $Unrecognized_links
      echo "Portail_communautaire" >> $Unrecognized_links
      echo "Le_Bistro" >> $Unrecognized_links
      echo "Special:" >> $Unrecognized_links
      echo "Aide:Accueil" >> $Unrecognized_links
      echo "propos_de" >> $Unrecognized_links
      echo "https://fr.wikibooks.org/wiki/Wikilivres" >> $Unrecognized_links
      echo "Wikilivres:" >> $Unrecognized_links
      echo "Catégorie:" >> $Unrecognized_links
      echo "en.wikibooks.org: unrecognized_link.dat ignore the uncontained Links in the Summary or Contents pages"
      echo "Main_Page" >> $Unrecognized_links
      echo "Help:Contents" >> $Unrecognized_links
      echo "Card_Catalog_Office" >> $Unrecognized_links
      echo "Cookbook:Table_of_Contents" >> $Unrecognized_links
      echo "Featured_books" >> $Unrecognized_links
      echo "Using_Wikibooks" >> $Unrecognized_links
      echo "Reading_room" >> $Unrecognized_links
      echo "Community_Portal" >> $Unrecognized_links
      echo "Reading_room/Bulletin_Board" >> $Unrecognized_links
      echo "Maintenance" >> $Unrecognized_links
      echo "Policies_and_guidelines" >> $Unrecognized_links
      echo "Contact_us" >> $Unrecognized_links
      echo "Welcome" >> $Unrecognized_links
      echo "General_disclaimer" >> $Unrecognized_links
      echo "Category:" >> $Unrecognized_links
    }
    fi
    echo "----"  
 
#O Write README in bin directory
#T echo "param 1 = $1"
    if [ "$1" = "Add_appendix" ]
    then
    echo "*** Write bin/README file "
    echo "README to use bin directory" > $Workdir/bin/README
    echo "This directory is reserved for commands without a '.sh' file suffix." >> $Workdir/bin/README
    echo "Commands without '.sh' are stripped of comments. They come from the" >> $Workdir/bin/README 
    echo "  'src' directory or from the 'tests' subdirectories." >> $Workdir/bin/README
    echo "Executables commands with '.sh', '.x' or .exe suffix are commands for" >> $Workdir/bin/README
    echo "  maintainers in 'sbin' directory" >> $Workdir/bin/README
    echo "*** Write README in Add_appendix"
    echo "README file in Add_apperdix" > $Workdir/README
    echo "Type ~/Add_appendix/bin/annex to launch the application" >> $Workdir/README
    fi
    
    if [ "$1" = "Annexer" ]
    then
    echo "*** écriture du fichier bin/LISEZ-MOI"
    echo "LISEZ-MOI pour l'utilisation du répertoire 'bin'" > $Workdir/bin/LISEZ-MOI
    echo "Ce répertoire est réservé aux commandes shell sans l'extension '.sh'." >> $Workdir/bin/LISEZ-MOI
    echo "Les commandes sans '.sh' proviennent du répertoire 'src' ou des sous-répertoires" >> $Workdir/bin/LISEZ-MOI
    echo "  des 'tests', dépouillées des commentaires." >> $Workdir/bin/README
    echo "Les exécutables avec l'extension 'sh', '.x' ou .exe sont des commandes" >> $Workdir/bin/LISEZ-MOI
    echo "  pour les mainteneurs dans le répertoire'sbin'" >> $Workdir/bin/LISEZ-MOI
    echo "*** écriture du fichier LISEZ-MOI dans Annexer"
    echo "Fichier LISEZ-MOI dans Annexer" > $Workdir/LISEZ-MOI
    echo "Taper ~/Annexer/bin/annex pour lancer l'application" >> $Workdir/LISEZ-MOI
    fi
    
#O When you run this script again, the message translation .pot files will be updated.
    if test -e $Installdir/bin/header.inc; then
      xgettext -L shell -o $Installdir/share/locale/header.inc.pot --from-code=UTF-8 $Installdir/bin/header.inc; fi
    if test -e $Installdir/bin/annex; then
      xgettext -L shell -o $Installdir/share/locale/annex.pot --from-code=UTF-8 $Installdir/bin/annex; fi
    echo "-----"    
    echo -e "\033[1;33mYou find Pot-files in $Workdir/share/locale for translations with 'Poedit':\033[0m"
    ls -R $Workdir/share/locale
    echo -e "\033[1;33mWhen you run this script again, the message translation .pot files will be updated.\033[0m"

    
#O Copy this program to $Workdir/sbin
    cp -Pu $0 $Workdir/sbin/users_install_annex.sh
    
#O Create the documentation of this program
    if test -e $Workdir/sbin/users_install_annex.sh; then cat $Workdir/sbin/users_install_annex.sh | grep -e "#D" | grep -v "if test" | sed 's/#D//g' > $Workdir/share/doc/users_install_annex.sh.doc; fi

#O Clean tmpfiles
    if test -d ~/tmp; then rm -r ~/tmp; fi
    
#O End of function users_install_annex          
}

#######################################################

#O clean screen
   clear;
   
#O Version
    VERSION=210919
    if [ "$1" = "--v" ]; then echo "Version of install_annex.sh $VERSION"; exit 0; fi

#O If the first parameter '$1' is empty or '?' print syntax.  
    if [ "$1" = "?" ]; then echo "Syntax for install_annex.sh: $0 [ <Install-directory> | ? | --v ]"; exit 0; fi
    if [ -z $1 ]; 
    then 
      echo "Syntax ~/Tmp/install_annex.sh [ --v | ? | Add_appendix | Annexer | /usr/local ]"; exit 0
    fi

#P Do not use sudo
    if [ $USER = "root" ]; then echo "USER = $USER"; echo "Do not use 'sudo' please."; exit -1; fi
  
#O Go to home directory and print the current directory.
    cd ~
    echo""; echo -n "current directory = "; pwd; echo ""
    
#O If the first parameter is not empty  
    if [ $1 ];
    then 
      if [ $1 = "/usr/local" ]; then  Installdir=$1; echo "Installdir = /usr/local"
      elif [ $1 = "Annexer" ]; then Installdir=~/Annexer; echo "Installdir = $Installdir"
      elif [ $1 = "Add_appendix" ]; then Installdir=~/Add_appendix; echo "Installdir = $Installdir"
      fi
    fi
    
    if [ $1 = "Annexer" ] || [ $1 = "Add_appendix" ]; then users_install-annex $1; exit 0; fi
    
    if [ $1 = "/usr/local" ]
    then 
      if test -d /usr/local/src/Add_appendix
      then echo "/usr/local/src/Add_appendix is present"
      else echo "/usr/local/src/Add_appendix is not found, create it."; sudo mkdir /usr/local/src/Add_appendix
      fi
#O Create variables
      Workdir=~/Add_appendix
      Booksdir=$Workdir/books
      Testsdir=$Workdir/tests
      Varsdir=$Workdir/vars
      Installdir=/usr/local
      Bindir=$Installdir/bin
      Includedir=$Installdir/include
      Libdir=$Installdir/lib
      Mandir=$Installdir/man
      Sbindir=$Installdir/sbin
      Sharedir=$Installdir/share
      Srcdir=$Installdir/src/Add_appendix
#P Extra directories added
      Datasdir=$Installdir/datas
      Resourcesdir=$Workdir/resources
#O Print variables        
      echo "Workdir=$Workdir"
      echo "Booksdir=$Booksdir"
      echo "Testsdir=$Testsdir"
      echo "Varsdir=$Varsdir"
      echo "Installdir=$Installdir"
      echo "Bindir=$Bindir"
      echo "Includedir=$Includedir"
      echo "Libdir=$Libdir"
      echo "Mandir=$Mandir"
      echo "Sbindir=$Sbindir"
      echo "Sharedir=$Sharedir"
      echo "Srcdir=$Srcdir"
      echo "Extra directory Datadir=$Datasdir"
      echo "Extra directory Resourcesdir=$Resourcesdir"        
#O Directives
        echo "Copy or update all sources .sh files in $Srcdir with root privilege."
    fi
#T Test break    exit 0

########################################"
#O Create or recreate directories
    mkdir -p $Varsdir $Booksdir $Resourcesdir $Resourcesdir/{lang,lang/po,lang/po/fr,lang/po/es,lang/man,man,man/en,man/es,man/fr}
    sudo mkdir -p $Datasdir

#O If findbook.sh, ecfpb.sh, ecfpc.sh, exist in the lib/src directory, build the annex.lib file
    mkdir $Workdir/lib
    if test -e $Srcdir/findbook.sh
    then sudo cat $Srcdir/findbook.sh | grep -v "#O\|#P\|#T" > $Workdir/lib/annex.lib
    sudo cp $Workdir/lib/annex.lib $Libdir/annex.lib
    else echo "findbook in annex.lib is not builded or not updated in $Libdir/annex.lib"
    fi
    rm -rf $Workdir/lib 
#    if test -e $Srcdir/ecfpb.sh; then cat $Srcdir/ecfpb.sh | grep -v "#O\|#P\|#T" >> $Libdir/annex.lib; fi
#    if test -e $Srcdir/ecfpc.sh; then cat $Srcdir/ecfpc.sh | grep -v "#O\|#P\|#T" >> $Libdir/annex.lib; fi
#O If they exist: install_datasfiles.sh in the lib/src directory, 
#O   then build this file and move to $Datasdir 
   if test -e $Srcdir/install_datasfiles.sh
   then 
     mkdir $Workdir/datas
     cp $Srcdir/install_datasfiles.sh $Workdir/datas/.; chmod 755 $Workdir/datas/install_datasfiles.sh
     $Workdir/datas/install_datasfiles.sh
     sudo cp -Rf $Workdir/datas/*.dat /usr/local/datas/. 
   else echo "install_datasfiles.sh not found in $Srcdir (datas files not updated in $Datasdir)"
   fi
   rm -r $Workdir/datas

#O Verify the content of datas dir
   if test -e $Datasdir/content_cleaner.dat; then echo "$Datasdir/content_cleaner.dat is found"; else echo "$Datasdir/content_cleaner.dat not found"; fi
   if test -e $Datasdir/conversions.dat; then echo "$Datasdir/conversions.dat is found"; esle echo "$Datasdir/conversions.dat is not found"; fi
   if test -e $Datasdir/unrecognized_links; then echo "$Datasdir/unrecognized_links is found"; else echo "$Datasdir/unrecognized_links is not found"; fi

#O Install cp-src2bin.shx, install_annex.shx, users_install_annex.shx, makeman_annex.shx, docu2html.shx
     mkdir $Workdir/sbin
     if test -e $Srcdir/cp-src2bin.sh; then cp $Srcdir/cp-src2bin.sh $Workdir/sbin/.; shc -r -v -f $Workdir/sbin/cp-src2bin.sh -o $Workdir/sbin/cp-src2bin.x; else echo "$Srcdir/cp-src2bin.sh not found"; fi
       if test -e $Workdir/sbin/cp-src2bin.x; then sudo cp $Workdir/sbin/cp-src2bin.x /usr/local/sbin/; fi
       
     if test -e $Srcdir/install_annex.sh; then cp $Srcdir/install_annex.sh $Workdir/sbin/.; shc -r -v -f $Workdir/sbin/install_annex.sh -o $Workdir/sbin/install_annex.x; else echo "$Srcdir/install_annex.sh not found"; fi
       if test -e $Workdir/sbin/install_annex.x; then sudo cp $Workdir/sbin/install_annex.x /usr/local/sbin/; fi
       
     if test -e $Srcdir/users_install_annex.sh; then cp $Srcdir/users_install_annex.sh $Workdir/sbin/.; shc -r -v -f $Workdir/sbin/users_install_annex.sh -o $Workdir/sbin/users_install_annex.x; else echo "$Srcdir/users_install_annex.sh not found"; fi
       if test -e $Workdir/sbin/users_install_annex.x; then sudo cp $Workdir/sbin/users_install_annex.x /usr/local/sbin/; fi
       
     if test -e $Srcdir/makeman_annex.sh; then cp $Srcdir/makeman_annex.sh $Workdir/sbin/.; shc -r -v -f $Workdir/sbin/users_install_annex.sh -o $Workdir/sbin/users_install_annex.x; else echo "$Srcdir/makeman_annex.sh not found"; fi
       if test -e $Workdir/sbin/users_install_annex.x; then sudo cp $Workdir/sbin/users_install_annex.x /usr/local/sbin/; fi
       
     if test -e $Srcdir/docu2html.sh; then cp $Srcdir/docu2html.sh $Workdir/sbin/.; shc -r -v -f $Workdir/sbin/docu2html.sh -o $Workdir/sbin/docu2html.x; else echo "$Srcdir/docu2html.sh not foud"; fi
       if test -e $Workdir/sbin/docu2html.x; then sudo cp $Workdir/sbin/docu2html.x /usr/local/sbin/; fi

     if test -e $Srcdir/install_datasfiles.sh; then cp $Srcdir/install_datasfiles.sh $Workdir/sbin/.; shc -r -v -f $Workdir/sbin/install_datasfiles.sh -o $Workdir/sbin/install_datasfiles.x; else echo "$Srcdir/install_datasfiles.sh not foud"; fi
       if test -e $Workdir/sbin/install_datasfiles.x; then sudo cp $Workdir/sbin/install_datasfiles.x /usr/local/sbin/; fi
#    rm -rf $Workdir/sbin
exit 0
#O Create function cpcleaned2bin
function cpcleaned2bin
{
#O Cleaner
    mkdir -p $Workdir/tmp 
    sudo 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" > $Workdir/tmp/$1
    sudo cp $Workdir/tmp/$1 $Bindir/$1
    if echo $Bindir/$1 | grep ".inc"; then sudo chmod 644 $Bindir/$1; else sudo chmod 755 $Bindir/$1; fi
#O Create new .pot file
    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"
}

#O Clean program sources files and add .pot files
# add_sclic
    if [ -e $Srcdir/add_sclic.sh ]; then cpcleaned2bin add_sclic; else echo "$Srcdir/add_sclic.sh not found"; fi
# add_sclipco
    if [ -e $Srcdir/add_sclipco.sh ]; then cpcleaned2bin add_sclipco; else echo "$Srcdir/add_sclipco.sh not found"; fi
# add_sclipwb
    if [ -e $Srcdir/add_sclipwb.sh ]; then cpcleaned2bin add_sclipwb; else echo "$Srcdir/add_sclipwb.sh not found"; fi
# add_sclt
    if [ -e $Srcdir/add_sclt.sh ]; then cpcleaned2bin add_sclt; else echo "$Srcdir/add_sclt.sh not found"; fi
# annex
    if [ -e $Srcdir/annex.sh ]; then cpcleaned2bin annex; else echo "$Srcdir/annex.sh not found"; fi
# download
    if [ -e $Srcdir/download.sh ]; then cpcleaned2bin download; else echo "$Srcdir/download.sh not found"; fi
# en_sclic.inc
    if [ -e $Srcdir/en_sclic.inc.sh ]; then cpcleaned2bin en_sclic.inc; else echo "$Srcdir/en_sclic.inc.sh not found"; fi
# en_sclipco.inc
    if [ -e $Srcdir/en_sclipco.inc.sh ]; then cpcleaned2bin en_sclipco.inc; else echo "$Srcdir/en_sclipco.inc.sh not found"; fi
# en_sclipwb.inc
    if [ -e $Srcdir/en_sclipwb.inc.sh ]; then cpcleaned2bin en_sclipwb.inc; else echo "$Srcdir/en_sclipwb.inc.sh not found"; fi
# en_sclt.inc
    if [ -e $Srcdir/en_sclt.inc.sh ]; then cpcleaned2bin en_sclt.inc; else echo "$Srcdir/en_sclt.inc.sh not found"; fi
# fr_sclic.inc
    if [ -e $Srcdir/fr_sclic.inc.sh ]; then cpcleaned2bin fr_sclic.inc; else echo "$Srcdir/fr_sclic.inc.sh not found"; fi
# fr_sclipco.inc
    if [ -e $Srcdir/fr_sclipco.inc.sh ]; then cpcleaned2bin fr_sclipco.inc; else echo "$Srcdir/fr_sclipco.inc.sh not found"; fi
# fr_sclipwb.inc
    if [ -e $Srcdir/fr_sclipwb.inc.sh ]; then cpcleaned2bin fr_sclipwb.inc; else echo "$Srcdir/fr_sclipwb.inc.sh not found"; fi
# fr_sclt.inc
    if [ -e $Srcdir/fr_sclt.inc.sh ]; then cpcleaned2bin fr_sclt.inc; else echo "$Srcdir/fr_sclt.inc.sh not found"; fi
# header.inc
    if [ -e $Srcdir/header.inc.sh ]; then cpcleaned2bin header.inc; else echo "$Srcdir/header.inc.sh not found"; fi
# list
    if [ -e $Srcdir/list.sh ]; then cpcleaned2bin list; else echo "$Srcdir/list.sh not found"; fi
# pre-annex
    if [ -e $Srcdir/pre-annex.sh ]; then cpcleaned2bin pre-annex; else echo "$Srcdir/pre-annex.sh not found"; fi
# scli.inc
    if [ -e $Srcdir/scli.inc.sh ]; then cpcleaned2bin scli.inc; else echo "$Srcdir/scli.inc.sh not found"; fi

    
#O List the Installdir/src directory and recreate the tmp/shell_files.prj
#P    if test -e ~/tmp; then  rm -r ~/tmp; fi
#P    mkdir ~/tmp 
#P    ls $Srcdir/*.sh > ~/tmp/shell_files.prj
#T Breakpoint exit 0

#O While line read in shell_files.prj
#P    while read line
#P    do
#O   Read $line, delete comments, write the result in Testdir directory for the Units Tests.
#P      echo $line | awk -F "/" '{print $NF}' > ~/tmp/tmpfile.txt
#P      read file < ~/tmp/tmpfile.txt
#T	  echo " file = "$file
#P      mkdir $Testdir/$file
#P      cp $Srcdir/$file $Testdir/$file/$file; chmod 755 $Testdir/$file/$file
#P    done < ./tmp/shell_files.prj
#O Clean tmpfile
#P    rm ~/tmp/tmpfile.txt
#P   rm -r ~/tmp

#O Message of the tasks to be accomplished.  
    echo "-----"
    echo "Tasks to be accomplished :"
	echo "Modify these files as functions"
    echo "Integrate functions in the librairie $Libdir/annex.lib"
    echo "Copy include files in $Includedir"
#    echo "Copy $Srcdir/install_annex.sh in $Sbindir"
    echo "See also users_install_annex.sh, best command for user"
    
#O Put install dirs to  /vars/installdir.var   
    rm $Workdir/vars/installdir.var
    echo "Installdir=$Installdir" > $Varsdir/installdir.var
    echo "Workdir=$Workdir" >> $Varsdir/installdir.var 
    echo "Booksdir=$Booksdir" >> $Varsdir/installdir.var 
    echo "Testsdir=$Testsdir" >> $Varsdir/installdir.var 
    echo "Varsdir=$Varsdir" >> $Varsdir/installdir.var 
    echo "Bindir=$Bindir" >> $Varsdir/installdir.var 
    echo "Includedir=$Includedir" >> $Varsdir/installdir.var 
    echo "Libdir=$Libdir" >> $Varsdir/installdir.var 
    echo "Mandir=$Mandir" >> $Varsdir/installdir.var 
    echo "Sbindir=$Sbindir" >> $Varsdir/installdir.var 
    echo "Sharedir=$Sharedir" >> $Varsdir/installdir.var 
    echo "Srcdir=$Srcdir" >> $Varsdir/installdir.var 
    echo "Extra directory Datadir=$Datasdir" >> $Varsdir/installdir.var 
    echo "Extra directory Resourcesdir=$Resourcesdir" >> $Varsdir/installdir.var           
    echo; echo "Content of file $Varsdir/installdir.var"
    cat $Varsdir/installdir.var
    
#O Clean tmpfiles
    if test -d ~/tmp; then rm -r ~/tmp; fi
    if test -d $Workdir/tmp; then rm -r $Workdir/tmp; fi
   
#O End 'install_annex.sh'

test_install_annex.bash[modifier | modifier le wikicode]

#!/bin/bash
#P File : test_install_annex.bash
#H Usage : ~/Tmp/test_install_annex.bash [ --v | ? | Annexer | Add_appendix ]
#H

#P Creation date     : 2021/07/27 by GC
#P Update and tests  : 2021/07/27 by GC
#P

#D This Documentation is included in source file
#H Header of file included in source file
#O Organigram of program included in source file
#P Comments for programmers included in source file
#S Structure comments of program included in source file
#w Warnings comments in program included in source file

#O clean screen
    clear

# Copy files to Tmp directory
    ./Copy2Tmp.bash

#O Version
    unset $VERSION
    VERSION=210917

    if [ "$1" = "--v" ]; then echo "Version of test_install_annex.bash "$VERSION; exit 0; fi

#O If the first parameter '$1' is '?' print syntax.  
    if [ "$1" = "?" ]
    then 
    echo "$HOME/Tmp/test_install_annex.bash [ --v | ? | Annexer | Add_appendix | /urs/local ]"; exit 0
    fi
    
#O If the first parameter '$1' is empty print syntax.
#T echo "param 0 = $0; param 1 = $1" exit 0
    if [ "$0" != "$HOME/Tmp/test_install_annex.bash" ] || [ -z $1 ]
    then
      echo "Copy test_install_annex.bash in ~/Tmp directory"
      echo "Syntax $HOME/Tmp/test_install_annex.bash [ --v | ? | Add_appendix | Annexer | /usr/local ]"
    fi
#T Test break  exit 0 
#O Test whishout firstparam
    echo "Test whishout firstparam"
    $HOME/Tmp/install_annex.sh
    sleep 3
#O Test --v
    echo "Test VERSION with '--v'"
    $HOME/Tmp/install_annex.sh --v
    sleep 3
#O Test ?
    echo "Test syntax with '?'"
    $HOME/Tmp/install_annex.sh ?
    sleep 4
#O Choose Annexer or Add_appendix
    echo -n "Choose Annexer inkey '1' or Add_appendix inkey '2' or /usr/local inkey '3': "
    read Inkey
    if [ "$Inkey" == "1" ]
    then 
#O Test Annexer
    $HOME/Tmp/install_annex.sh Annexer
    echo "Contenu du répertoire Annexer :" 
    ls -al ~/Annexer
    echo "Contenu des sous-répertoires"
    ls -al ~/Annexer/datas ~/Annexer/lib ~/Annexer/lib/src ~/Annexer/sbin ~/Annexer/share/doc ~/Annexer/vars
    exit 0
    elif [ "$Inkey" == "2" ]
    then
#O Test Add_appendix
    $HOME/Tmp/install_annex.sh Add_appendix
    echo "Add_appendix directory :"
    ls -al ~/Add_appendix
    echo "Contents of sub-directories :"
    ls -al ~/Add_appendix/datas ~/Add_appendix/lib ~/Add_appendix/lib/src ~/Add_appendix/sbin ~/Add_appendix/share/doc ~/Add_appendix/vars
    exit 0 
    elif [ "$Inkey" == "3" ]
    then
#O Test /usr/local
    $HOME/Tmp/install_annex.sh /usr/local
    ls -al ~/Add_appendix ~/Add_appendix/vars ~/Add_appendix/resources
    echo; echo "Contents of /usr/local sub-directories :"
    ls -al /usr/local/src/Add_appendix /usr/local/datas /usr/local/lib /usr/local/sbin
    exit 0
#O Else print syntax
    else $HOME/Tmp/install_annex.bash ?
    fi
#O End test_install_annex.bash

Copy2Tmp.bash[modifier | modifier le wikicode]

#!/bin/bash
#H File Copy2Tmp.bash in $Workdir/tests/00-install_annex directory
VERSION=210818
cp -u test_users_install_annex.bash ~/Tmp/.; chmod 766 ~/Tmp/test_users_install_annex.bash
cp -u users_install_annex.sh ~/Tmp/.; chmod 766 ~/Tmp/users_install_annex.sh
cp -u users_install_annex.sh.x ~/Tmp/.
#
cp -u test_install_annex.bash ~/Tmp/.; chmod 766 ~/Tmp/test_install_annex.bash
cp -u install_annex.sh ~/Tmp/.; chmod 766 ~/Tmp/install_annex.sh
#P End of file Copy2Tmp.bash