Auto-éditer un wikilivre/addappendix/reconstruction et tests du script addappendix

Attention : modification en cours !link={{{link}}}

Un contributeur est en train de retravailler en profondeur cette page. Vous êtes prié(e) d'éviter de le modifier pour limiter les risques de conflit de versions jusqu'à disparition de cet avertissement. Merci.

  • Cette page concerne le logiciel addappendix mis en paquet

preinstall-usr-local.bashModifier

#!/bin/bash
#H Header doc
#H -------------------------------
#H File : tests/preinstall-usr-local.bash
#H Syntax : ./preinstall-usr-local.bash./ [ ?  | -v ]
#H Created : 220118 by <wikibooks user>
#H Updated : 220118 by ... for
#O Organizational chart
#O -------------------------------
#P Programmers notes
#P -------------------------------
VERSION=220313

#O Script begin here
sudo install -d /usr/local/datas
#P sudo cp /home/cardabela/addappendix-211219/datas/*.dat /usr/local/datas/.
sudo cp ~/Add_appendix /datas/*.dat /usr/local/datas/.
ls /usr/local/datas
#O Script end

script addapendix.sh 22/03/10Modifier

#!/bin/bash
#H Header doc
#H -------------------------------
#H File : ~/Add_appendix/tests/13-(pkg)-addappendix.sh/addapendix.sh
#H Syntax : addapendix [ ?  | --v ]
#H Created : 220113 by GC
#H Updated : 220221 by GC for page ScliC
#O Organizational chart
#O -------------------------------
#P Programmers notes
#P -------------------------------

VERSION=220310
TEXTDOMAIN=addappendix
TEXTDOMAINDIR="/usr/share/locale"
#TEXTDOMAINDIR="~/Add_appendix/share/locale"
export TEXTDOMAINDIR

#P . gettext for translation
. gettext.sh

#O Script begin here
#O If parameters is empty
    if test -z $1
#O Then print the short syntax ant exit -1
    then 
	  echo -n -e "\033[31m"
      echo -n $"No parameter. addappendix [ full URL of book | ? | --v ]"
	  echo -e "\033[0m"
	  exit -1
	fi

#O If firt parameter is '?'
	if [ "$1" = "?" ]
#O Then print syntax whih examples and exit 0
    then 
	  echo -n -e "\033[32m"
	  echo $"Syntax: addappendix [ full URL of book | ? | --v ]"
	  echo $"  Example 1 : addappendix https://en.wikibooks.org/wiki/Wikibooks:Collections/Guide_to_Unix"
	  echo $"  Example 2 : addappendix https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel"	  
	  echo -e "\033[0m"
      exit 0
	fi
#O IF first parameter is "--v"
    if [ "$1" = "--v" ]
#O Then print addapendix version
	then
	  echo -n -e "\033[32m"
	  echo -n $"addapendix version : $VERSION"
	  echo -e "\033[0m"
	  exit 0
	fi
	
#O *** First parameter analysis ***
#T    echo "$1"
#O Test if the first parameter points to wikibooks.org/wiki
    if echo $1 | grep wikibooks.org/wiki 
	then 
	  echo -n -e "\033[32m"	
	  echo -n $"  is a wiki-book"
	  echo -e "\033[0m"
    else
	  echo -n -e "\033[31m"	
	  echo -n $"$1 is not a wiki-book on wikibooks.org"
	  echo -e "\033[0m"
      exit -1
    fi
#O Check if $1 file exist
    if wget --spider $1 2>/dev/null; then
	  echo -n -e "\033[32m"		
      echo -n $"File $1 is found"
	  echo -e "\033[0m"	  
    else
	  echo -n -e "\033[31m"		
      echo -n $"File $1 is not found"
	  echo -e "\033[0m"
      exit -1
    fi

#O Find the bookname
    echo $1 | awk -F"/" ' { print $NF }' > bookname.txt
	read Bookname<bookname.txt
	echo; echo -n -e "\033[1;32m"		
	echo -n $"Book name : $Bookname"
	echo -e "\033[0m"
    
    echo $1 | awk -F"/" ' { print $3 }' > site.txt
    read Site<site.txt
	echo; echo -n -e "\033[1;32m"		
	echo -n $"Site name : $Site"
	echo -e "\033[0m"
    
    echo $1 | awk -F"/" ' { print $5 }' > compilations.txt
	read Compilations<compilations.txt
	echo -n -e "\033[1;32m"		
	echo -n $"Compilations name: $Compilations"
	echo -e "\033[0m"
	if [ "$Compilations" = "Wikilivres:Compilations" ]; then Suffix=compiled; fi
	if [ "$Compilations" = "Wikibooks:Collections" ]; then Suffix=compiled; fi
    if test -z $Suffix; then Suffix=compiled; fi
    echo -n -e "\033[1;32m"		
	echo "Suffix = $Suffix"
	echo -e "\033[0m"

#O Create Bookname directory
    install -d ~/Add_appendix/books/$Bookname
	Projectdir=~/Add_appendix/books/$Bookname
#O Create temp directory in Workdir
	Workdir=~/Add_appendix
	mkdir -p $Workdir/temp
#O ============================================================================
##O Create the file bookname.suffix
#T ***********************
#O Create $Projectdir/resources/TMP to download
    mkdir -p $Projectdir/resources/TMP
#O Download $1
    cd $Projectdir/resources/TMP
    rm -Rf $Projectdir/resources/TMP/* 2> /dev/null
    wget -N $1 -o $Workdir/temp/wget-log-télécharger.txt
    ls -1 > ../filename.txt
    read Filename<../filename.txt
    if [ "$Filename" = "filename.txt" ]; then echo $"line 113: \$Filename = filename.txt error, exit -1"; exit -1; fi
    rm ../filename.txt
#O go up in the directory resources and rename 'TMP' '$Filename'
    cd ..
    if test -e $Filename; then rm -R $Filename; fi
    if test -d $Filename 2>/dev/null
	then rm -R $Filename 2>/dev/null
    fi 
    mv TMP $Filename
    cd $Filename
#T  ls -al 
    cat $Filename|grep "<li><a href=">extract-li
    cat extract-li | sed "s/title=\"/\n[[/g" | grep -v "<li><a href=" |sed "s/\">/]]\n/g"|grep -v "</a>\|Cat\|<div" >extract-li1
    cat $Filename|grep "<dd><a href=">extract-dd
    cat extract-dd | sed "s/title=\"/\n[[/g" | grep -v "<dd><a href=" |sed "s/\">/]]\n/g"|grep -v "</a>" >extract-dd1
    cat extract-dd1 > $Bookname.$Suffix
    cat extract-li1 >> $Bookname.$Suffix
#T    echo "$Bookname.$Suffix = "
    cp $Bookname.$Suffix $Projectdir/$Bookname.$Suffix
#T ***********************
    if test -e $Projectdir/$Bookname.$Suffix
    then
	  echo -n -e "\033[1;32m"		
      echo -n "$Bookname.$Suffix : "
	  echo -e "\033[0m"
      cat $Projectdir/$Bookname.$Suffix
    fi
#O ============================================================================	
#O Download the book in html form
#O Télécharger le site récursivement avec une profondeur infinie ( -linf ), \
#O convertit les liens pour une consultation en local ( -k ), \
#O rapatrie tous les fichiers nécessaires à l'affichage convenable d'une page HTML ( -p ) \
#O et renomme toutes les pages HTML avec l'extension .html ( -E ) 
    echo; echo "Dowload $1"
    wget -r -linf -k -p -E "$1" -o $Workdir/temp/wget-log-télécharger.txt

# Create lists
   if test -e /usr/local/datas/content_cleaner.dat; then Datasdir=/usr/local/datas
   else
     echo -n -e "\033[12;31m"
     echo -n $"content_cleaner.dat not found in /usr/local/datas"
     echo -e "\33[0m"
     exit -1
   fi

   if test -e "$Projectdir/$Bookname.compiled"
   then 
   {
     echo $" Found Compiled page : $Projectdir/$Bookname.compiled"; echo
     echo " Create $Projectdir/$Bookname.list with :"; echo "    $Projectdir/$Bookname.compiled"; echo
     cat "$Projectdir/$Bookname.compiled" | sed -f $Datasdir/content_cleaner.dat > $Projectdir/$Bookname.compiled.cleaned
     cat "$Projectdir/$Bookname.compiled.cleaned" | grep -v '=' | sed "s/\[\[/https:\/\/$Site\/wiki\//g" | sed "s/\]\]//g" | grep "wiki" | tr ' ' '_' | cut -d '|' -f1 > $Projectdir/$Bookname.list
     cat "$Projectdir/$Bookname.compiled.cleaned" | grep -v '=' | sed "s/\[\[//g" | sed "s/\]\]//g" | cut -d '|' -f1 > $Projectdir/$Bookname.prj
   }
   fi
#T Print $Projectdir/$Bookname.prj
    cat $Projectdir/$Bookname.prj

#O Download the complete book structure in project directory
    cd $Projectdir
    echo $"download all sub-directories of the book '$Bookname'"
    wget -r -linf -k -p -E  -i $Bookname.list -o $Workdir/temp/wget-log-download.txt
    echo "----------"
#T Testspoint    exit 0
#O Move the html pages into working sub-directories to document the pages and sub pages
#O   create a local list to the downloaded directories $ Projectdir/$1.locale.list
      echo "create the complete concatenated hierarchy of the directories of the book '$Bookname'"
      cat $Projectdir/$Bookname.list | sed "s/https:\/\///g" | sed "s/\ /\\\ /g" | tr '\n' ',' > $Projectdir/$Bookname.locale.list
      echo "   Concatenated local list $Projectdir/$Bookname.locale.list :"
      echo ""
      cat $Projectdir/$Bookname.locale.list
      echo "----------"  
#O Copy the html files to respective directories
#O   Create a file with the pagename $Projectdir/$Bookname.mainPage
      echo
      echo $"Create the page from the local link to the main page, 'the book'"
      cat $Projectdir/$Bookname.locale.list | sed "s/ /\\ /g" | cut -d ',' -f1 > $Projectdir/$Bookname.mainPage
      echo "----------"
#O   Initialize the variable $mainPage
      read mainPage < $Projectdir/$Bookname.mainPage
      echo "variable mainPage = $mainPage"     
    #T cat $Projet/$1.mainPage | awk -F"/" '{print NF}' > nbchamps
    #T read NbChamps < nbchamps
    #T echo "Variable NbChamps = $NbChamps"
      echo "----------"
#O   Create a file of the working directories to be created.
      ls "$mainPage" | sed "s/.html//g"  > $Projectdir/$Bookname.dirs
      echo "sub-working-diectories : "
      cat  $Projectdir/$Bookname.dirs
      echo "----------" 
#O   Copy the html pages and subpages in the respective directories
      while read line
      do
        echo "$line".html | sed "s/https:\/\///g" | tr '\n' ' ' > source
        read Source < source
        echo "Source = $Source"

        echo "$line" | awk -F"/" '{ print $NF }'| tr '\n' '/' > destination 
        read dir < destination
        mkdir $dir
        echo "$line".html | awk -F"/" '{ print $NF }' >> destination
        read Destination < destination
        echo "Destination = $Destination"
        echo $"Copy : 'cp -f ./$Source $Destination'"
        cp -f "./$Source" "$Destination"
      done < $Projectdir/$Bookname.list
      rm source ; rm destination

#O ============================================================================
#O Create variable PageSclt
    PageSclt=$Projectdir/$Bookname.sclt
#O File creation '$Bookname.sclt' and print the contents.
    echo "----------"
    echo "$(gettext '= Appendix = ')" > $PageSclt
    echo >> $PageSclt

#O Add <references />
    echo "$(gettext '== References == ')" >> $PageSclt
    echo "$(gettext '<references /> ')" >> $PageSclt
    echo  >> $PageSclt
    echo "<div style='page-break-before:always'></div>" >> $PageSclt
    
#O Add the link to printable book and to articles.
    echo "$(gettext '== Contents == ')" >> $PageSclt
    echo "<div style='font-zize:85%'>" >> $PageSclt
    cat $Projectdir/$Bookname.list | tr ' ' '_' | tr '\n' '%' | sed "s/%/\n\n/g" >> $PageSclt
    echo "</div>" >> $PageSclt

#0 Add the link to the source of this edition.
    echo "$(gettext '=== Source for this edition === ')" >> $PageSclt
    echo "<div style='font-zize:85%';>" >> $PageSclt
    echo -n "https://" >> $PageSclt
    cat $Projectdir/$Bookname.mainPage | sed "s/\\\ /_/g" >> $PageSclt
#P other version : cat $Projectdir/Bookname".list" | tr ' ' '_' | tr '\n' '%' | sed "s/%/%\n/g" | grep $1% | tr -d % >> $PageSclt
    echo "</div>" >> $PageSclt
    echo " " >> $PageSclt
    echo "<div style='page-break-before:always'></div>" >> $PageSclt

#O Create section 'Article', 'Source', 'License', 'Contributors(?)'
    echo "$(gettext '== Articles Sources, and Contributors == ')" >> $PageSclt
#O   add the text : style PediaPress or personalized.
#O   The ''sources'' listed for each article provide more detailled licencing
#O   information including the copyright status, the copyleft owner and the license conditions.
    echo -n "<span style='font-zize:85%';>" >> $PageSclt
    echo "$(gettext 'The ''sources'' listed for each article provide more detailled licencing information including the copyright status, the copyleft owner and the license conditions..</span> ')" >> $PageSclt
#O or, validate one or the other of these texts : 
#   echo $"The texts are available with their respective licenses, however other terms may apply.<br />See the terms of use for more details : <br />https://wikimediafoundation.org/wiki/Conditions_d'utilisation.</span>" >> $PageSclt
    echo " " >> $PageSclt
    echo "<div style='font-zize:72%';>" >> $PageSclt
    
echo "----------"
#O Create or recreate the list-file $Projectdir/$1.pj
    cat $Projectdir/$Bookname.list | awk -F"/" '{ print $NF }' > $Projectdir/$Bookname.pj
    Pjlist=$Projectdir/$Bookname.pj
    echo "Pjlist : "$PjList

#O While exist line in file $PjList ,
    while read line
    do    
#O    Print the line read,
       echo
       echo $"   line read = $line"
       echo
#O    Extract and copy all strings from the html file
#O      $line.html in the file $line.str and add to screen
#T pwd
       mkd -pws '**' "$line/$line.html" $Projectdir/$line/$line.tmp | tr ',' '\n' > $Projectdir/$line/$line.str
#T break
#O    Create the documentation file of pages :
       echo "*** References : articles, src, lic, contrib. "
    
#O    Print article,
       if [ $line != $Bookname ]
       then  
         echo "'''$line'''" >> $PageSclt
       fi
       echo "'''"$line"'''" > $Projectdir/$line/$line.article
       cat $Projectdir/$line/$line.article
       
#O    Print source,
       echo -n $", ''source : ''https://"$Site"/w/index.php?oldid=" > $Projectdir/$line/$line.RevisionId
       cat $Projectdir/$line/$line.str | grep -n -m 1 -i -e wgRevisionId | tr -d ':' | sed "s/\"/%/g" | cut -d'%' -f3 >> $Projectdir/$line/$line.RevisionId
       if [ "$line" != "$Bookname" ]
       then          
         cat $Projectdir/$line/$line.RevisionId  >> $PageSclt
       fi
       cat $Projectdir/$line/$line.RevisionId
       

#P    license du bas de page : 
#P    <li id="footer-info-copyright">Les textes sont disponibles sous <a href="https://creativecommons.org/licenses/by-sa/3.0/">license Creative Commons attribution partage à l’identique</a> ; d’autres termes peuvent s’appliquer.<br/>
#P      Voyez les <a href="https://wikimediafoundation.org/wiki/Conditions_d'utilisation">termes d’utilisation</a> pour plus de détails.<br/></li>
#P
#P    Print license :
#P    <link rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"/>


#T echo ", ''Copyright :''"  >> ArticleUn.tmp
#T cat ArticleUn.str | grep -n -m 1 -i -e license | sed "s/\"\//%\//g" | cut -d'%' -f2 |sed "s/\/\//https:\/\//g"  >> ArticleUn.tmp
#O    Print license :
       echo -n $", ''license : ''" > $Projectdir/$line/$line.license
    #T cat $Projectdir/$line/$line.str | grep -n -m 1 -i -e license | sed "s/\"\//%\//g" | cut -d'%' -f4 >> $Projectdir/$line/$line.license
       cat $Projectdir/$line/$line.str | grep -n -m 1 -i -e license | sed "s/\"\//%\//g" | tr '"' '%' | cut -d'%' -f4 >> $Projectdir/$line/$line.license
    #T cat $Projectdir/$line/$line.str | grep -n -m 1 -i -e license | sed "s/\"\//%\//g" | cut -d'%' -f2 | sed "s/\/\//https:\/\//g" >> $Projectdir/$line/$line.license
       if [ $line != $Bookname ]
       then  
         cat $Projectdir/$line/$line.license >> $PageSclt
       fi
       cat $Projectdir/$line/$line.license
       #
       #P spécial pour bas de page fr ## 
       cat $Projectdir/$line/$line.str | grep -n -m 1 -i -e footer-info-copyright | sed "s/\"\//%\//g" | tr '"' '%' | cut -d'%' -f4  > $Projectdir/$line/$line.license

#O    Author(s).  
       echo -n $", ''authors : ''" > $Projectdir/$line/$line.author       
       cat $Projectdir/$line/$line.str | grep -n -m 1 -i -e wgRelevantUserName | sed "s/\"/%/g" | cut -d'%' -f4 > tmp
       if test -s tmp 
         then cat tmp >> $Projectdir/$line/$line.author; rm tmp
         else 
           echo $"Author not found ! " >> $Projectdir/$line/$line.author
           if wget --spider https://xtools.wmflabs.org/articleinfo/en.wikibooks.org/$line 2>/dev/null
           then
             echo "$(gettext '. -see :') https://xtools.wmflabs.org/articleinfo/$Sitename/$line" >> $Projectdir/$line/$line.author
           elif wget --spider https://xtools.wmflabs.org/articleinfo/$Sitename/$Bookname/$line 2>/dev/null
           then 
             echo "$(gettext '. -see :') https://xtools.wmflabs.org/articleinfo/$Sitename/$Bookname/$line" >> $Projectdir/$line/$line.author
           else 
             cat $Projectdir/$line/$line.str | grep -n -m 1 -i -e wgRelevantPageName | sed "s/\"/%/g" | cut -d'%' -f4 > tmp
             if test -s tmp
             then
               #T echo "&action=history" >> tmp
               echo -n "$(gettext '. -see ''contributors'' in book, history page of ')"  >> $Projectdir/$line/$line.author
               cat tmp >> $Projectdir/$line/$line.author; rm tmp
             fi
           fi
       fi
       #https://xtools.wmflabs.org/articleinfo/en.wikibooks.org/Guide_to_Unix/Introduction
       
       if [ $line != $Bookname ]
       then
         cat $Projectdir/$line/$line.author >> $PageSclt
         cat $Projectdir/$line/$line.author
       fi
       
       echo >> $PageSclt
       
#O end of while.
    done < $Pjlist
    
#O Add end of div and pagre break
    echo "</div>" >> $PageSclt
    echo "<div style='page-break-before:always'></div>" >> $PageSclt
    
#P
#P Création de la page Bookname.scli (sources contributeurs licenses des images)
#P

#0 Initialisation de la variable d'entête des fichiers scli.
    Headscli=$Projectdir/$Bookname.scli
    echo > $Headscli
#O Afficher le nom du fichier Headscli à la console 
#O Show Headscli filename to console
    echo
    echo -n "$Headscli"; echo $" english version"; echo
    echo $"== Images Sources Licenses and Contributors ==" > $Headscli
    echo -n "<span style='font-size:85%'>"; echo $"The ''sources'' listed for each illustration provide more detailed licensing information, including copyright status, the holders of these rights and the license conditions.</span>" >>  $Headscli
    echo " " >>  $Headscli
    echo "<div style='font-size:72%'>" >> $Headscli
    echo >>  $Headscli
#T Show the content of file Headscli    cat $Headscli; exit 0

#O ============================================================================
#O If the file $Projectdir/$Bookname/$Bookname.str exist, create the PageSclic in classic order
#O Si la page $Projectdir/$Bookname/$Bookname.str existe, créer la page $PageSclic contenant les images dans un ordre classique
    if test -e $Projectdir/$Bookname/$Bookname.str
    then
#O Select lines containing 'fichier:', 'file', image and create bookname.files
    cat $Projectdir/$Bookname/$Bookname.str | grep -n -i -e fichier: -e file: -e image: > $Projectdir/$Bookname/$Bookname.files
#O Select lines containing 'fichier:', '.jpg', '.png', '.gif' and create bookname.pict
    cat $Projectdir/$Bookname/$Bookname.str | grep -n -i -e fichier: -e .jpg -e .png -e .gif > $Projectdir/$Bookname/$Bookname.picts
#O Sélect in bookname.files, the lines containing 'title', remove the tag <div> cut ">" and select the last champ to create bookname.illustrations
    cat $Projectdir/$Bookname/$Bookname.files | grep title |sed "s/<\/div>//g" | awk -F">" '{print $NF}' > $Projectdir/$Bookname/$Bookname.illustrations
#O Dans le fichier .files avec le séparateur "=" imprimer dans le champ 'i' le retour chariot, sélectionner le slignes conteneant 'https', remplacer le caractère '"' par '!'
#O   et sélectionner le trosième champ, puis relélectionner la ligne contenant https, remplacer le caractère '>' par !, supprimer </a, puis supprimer le caractère '!'
#O   et créer le fichier.links
       cat $Projectdir/$Bookname/$Bookname.files | awk -F"=" '{for (i=1;i<=NF;i++) print $i "\n"}' | grep https | sed "s/\"/!/g" | cut -d '!' -f3 \
       | grep https | tr '>' ! | sed "s/<\/a//g" |sed "s/!//g" > $Projectdir/$Bookname/$Bookname.links
#OF Télécharger les fichiers contenus dans la liste du fichier bookname.links
#O Download the files contained in the list of the bookname.links file
    wget -P $Projectdir/$Bookname -r -linf -k -p -E -i $Projectdir/$Bookname/$Bookname.links       
#O Copy html liles from ./commons.wikimedia.org/wiki in the curreny directory
    cd $Bookname
    if test -e commons.wikimedia.org; then cp -R commons.wikimedia.org/wiki/*.html . ; fi
#O html.list initialization
    echo -n "" > html.list
    if test -s $Projectdir/$Bookname/$Bookname.links
    then 
    { 
      echo $"$Projectdir/$Bookname/$Bookname.links is not empty" 
#OF  Tant qu'on lit des lignes dans le fichier .links, lire les images et les lister dans html.list  
#O   As long as there is a line in file html.links, read the line and copy it to html.list
      while read line
      do
      echo $line | awk -F"/" '{print $NF}' | cut -d '%' -f1 | cut -d '.' -f1 > tmp
      read Image < tmp
      ls $Image*.html  >> html.list
      echo "Image : "$Image.html  
      done < $Projectdir/$Bookname/$Bookname.links
    }
    elif test -s $Projectdir/html.list; then cp $Projectdir/html.list $Projectdir/$Bookname/html.list
    else echo $"No images found in $Projectdir/$Bookname"; exit 0
    fi
    
    echo " *** References : image, src, lic, contrib."
#O As long as there is a line in file html.list extract illustrations, sources, licenses, authors(s)	   
    while read line
    do
       echo
       echo
       echo $"**** line = $line ****"
       echo
	   
       mkd -pw '**' $line $line.tmp
       cat $line.tmp | tr ',' '\n' > $line.str 
     
       echo -n $"'''Illustration : '''" > $line.title
       cat $line.str |grep wgTitle | cut -d '"' -f4 >> $line.title
       cat $line.title >> $PageSclic 
       cat $line.title

       echo -n $", '' source : ')''https://"$Site"/w/index.php?title= " > $line.source
       echo $line | sed "s/.html//g" >> $line.source
       cat $line.source >> $PageSclic
       cat $line.source

       echo -n $", ''license : ''" > $line.license
       cat $line.str | grep licensetpl_short | sed "s/<td>//g" | sed "s/<span class//g" | sed "s/<\/span>//g" | sed "s/style=\"display:none;\"//g" | tr '=' '\n' | grep licensetpl_short | awk -F">" '{print $NF}' >> $line.license
       cat $line.license >> $PageSclic
       cat $line.license
	   
       echo -n $", authors : ''" > $line.authors
       rm tmp
       cat $line.str | grep -i -n -m1 -A 1 -e Author | grep -i -e user -e utilisteur -e auteur | tr '/' '\n' | grep -i -e user -e utilisteur -e auteur | cut -d '"' -f1 > tmp
       if test -s tmp 
       then cat tmp >> $line.authors
       else echo "-" >> $line.authors
       fi
       cat $line.authors >> $PageSclic
       cat $line.authors	   
       echo >> $PageSclic
    done < html.list
#P bas de la page avant la nouvelle page	
    echo "</div>" >> $PageSclic
    
#T    echo "$(gettext '{{Newpage}} ')" >> $PageSclic
    echo "<div style='page-break-before:always'></div>" >> $PageSclic
#O end of test -e $Projectdir/$Bookname/$Bookname.str  
    else 
      echo  -e "\033[31m"
      echo $"Can not create $Projectdir/$Bookname/$Bookname.sclic. URL page of book is not found"
	  echo -e "\033[0m"
#O end of create PageSclic
    fi
    
#O ============================================================================
#O Create variable Pagesclipco
    Pagesclipco="$Projectdir/$Bookname.sclipco"
    echo $Pagesclipco
#O Wikibooks sclipco personalized page initialization with the title Images sources, etc.
    cat $Projectdir/$Bookname.scli > $Pagesclipco
#Test 
cat $Pagesclipco
#O ============================================================================
 
#O Create an identification loop of the directories corresponding to the articles
#O As long as we can read the lines of the file $Projectdir/$Bookname.pj
    while read pjline
    do
#O   If the line read is not $Bookname (name of the book)
#T    echo "line read : " $line
      if [ $pjline != $Bookname ]
#O     Then:
        then
#O     Enter in the article directory,
        cd $Projectdir/$pjline
#O     Create image documentation files
#O     Open the stream of $ Projectdir/$Bookname/$Bookname.str of the image and select 
#O       the character strings containing: File:, Image; and put in files
#O       $Projectdir/$line/$line/.files, .pict, .illustration, .images, .links
        cat $Projectdir/$pjline/$pjline.str | grep -n -i -e Fichier: -e file: -e image: | sed -f $RepCom/$Conversions > $Projectdir/$pjline/$pjline.files
        cat $Projectdir/$pjline/$pjline.str | grep -n -i -e fichier: -e .jpg -e .png -e .gif | sed -f $RepCom/$Conversions> $Projectdir/$pjline/$pjline.picts
        cat $Projectdir/$pjline/$pjline.files | grep title |sed "s/<\/div>//g" | awk -F">" '{print $NF}' > $Projectdir/$pjline/$pjline.illustrations
#T        cat $Projectdir/$pjline/$pjline.files | awk -F"=" '{for (i=1;i<=NF;i++) print $i "\n"}' | grep https | sed "s/\"/!/g" | cut -d '!' -f3 | grep https | tr '>' ! | sed "s/<\/a//g" |sed "s/!//g" > $Projectdir/$pjline/$pjline.links
        cat $Projectdir/$pjline/$pjline.files | awk -F"=" '{for (i=1;i<=NF;i++) print $i "\n"}' | grep https://$Site | sed "s/\"/!/g" | cut -d '!' -f2 > $Projectdir/$pjline/$pjline.images
#Tbreak
#O Transform the links of the image file on wikibooks into an image file on commons
    cat $Projectdir/$pjline/$pjline.images | sed "s/$Site/commons.wikimedia.org/g"| sed "s/Fichier/File/g" > $Projectdir/$pjline/$pjline.commonsimages
#O     Download the image files from the wikimedia server.
#P     Note: the -N option allows you to avoid downloading an up-to-date file,
#P      and without adding a numbering.
#T      #T wget -N -P $Projectdir/$pjline -i $Projectdir/$pjline/$pjline.images
        wget -P $Projectdir/$pjline -r -linf -k -p -E  -i $Projectdir/$pjline/$pjline.commonsimages
#T     echo "*** Commonsimages ***"; cat $Projectdir/$pjline/$pjline.commonsimages; exit 0
#O     Copy the downloaded images to the directory of the current article..
        cp $Projectdir/$pjline/commons.wikimedia.org/wiki/*.html $Projectdir/$pjline/.           
#O     Initialize the commonshtml.list file with empty text.
        echo -n "" > commonshtml.doublons  
#O     List the image files in the order of printing or display,
#O       using the list $Projectdir/$pjline/$pjline.commons.images
#O     As long as we can read lines in $Projectdir/$pjline/$pictline.images
        while read pictline
        do
#O       Cut the lignes at carriage return, sélect the last field and add '.html'
          #echo $pictline | awk -F"/" '{for (i=1;i<=NF;i+=2) print $i "\n"}' #| cut -d '%' -f1 | cut -d '.' -f1 > tmp
          echo $pictline | awk -F"/" '{ print $NF".html"}' >> commonshtml.doublons
#O       Cut the duplicated lines and select even fields.
          echo -n "" > commonshtml.list
          awk 'BEGIN { FILENAME }
                {memfile [NR] = $0 }
               END   { for ( i = 1 ; i <= NR ; i=i+2 ) {
                       print memfile[i] >> "commonshtml.list"
                       } 
	                   # print "Fin"
                     } ' commonshtml.doublons
#O     End of while $Projectdir/$pjline/$pjline.commonsimages
        done < $Projectdir/$pjline/$pjline.commonsimages

#T     Afficher html.list
#T echo "*** commonshtml.list ***"; cat commonshtml.listexit 0
#O   Copy article name in file $Bookname.sclipco
      echo "'''Article : $pjline'''<br />" >> $Pagesclipco
      echo "'''Article : $pjline'''"


#P## Annexe version 'wikimedia commons' ##############################

#O     As long as there are (local) links in the commonshtml.list image file
        while read htmlline
        do
#O       Afficher la ligne lue,
          echo ""
	      echo ""
          echo $" ---- line read = $htmlline --- "
          echo ""
#O   With mkd (sofware), select the character strings from the image file $htmlline
#O    and copy them to $ htmlline.co.str after replacing the character ',' with 
#O    'new-line'
	  mkd -pw '**' $htmlline $htmlline.tmp
	  cat $htmlline.tmp | tr ',' '\n' > $htmlline.co.str 
#T echo "*** $htmlline.co.str : ***"; cat $htmlline.co.str; exit 0     
#O     images, 
        echo -n $"'''Illustration : '''" > $htmlline.co.title
        cat $htmlline.co.str | grep wgTitle | cut -d '"' -f4 >> $htmlline.co.title
	    cat $htmlline.co.title >> $Pagesclipco 
	    cat $htmlline.co.title
#T echo "*** $htmlline.co.title : ***"; cat $htmlline.co.title; exit 0
#O     source, 
        echo -n $", ''source : ''https://commons.wikimedia.org/wiki/" > $htmlline.co.source
        ##echo -n ",''$(gettext 'source : ')''https://commons.wikimedia.org/wiki/" > $htmlline.co.source
	    echo -n $htmlline | sed "s/.html//g" | sed "s/.str//g" >> $htmlline.co.source
        if [ "$Site" = "fr.wikibooks.org" ]; then echo "?uselang=fr" >> $htmlline.co.source
        elif [ "$Site" = "en.wikibooks.org" ]; then echo "?uselang=en" >> $htmlline.co.source
        else echo
        fi
        cat $htmlline.co.source >> $Pagesclipco
        cat $htmlline.co.source
#T echo "*** $htmlline.co.source : ***"; cat $htmlline.co.source; exit 0
#O     license, 
        echo -n $", ''license : '' " > $htmlline.co.license
	    cat $htmlline.co.str | grep licensetpl_short | sed "s/<td>//g" | sed "s/<span class//g" | sed "s/<\/span>//g" | sed "s/style=\"display:none;\"//g" | tr '=' '\n' | grep licensetpl_short | awk -F">" '{print $NF}' >> $htmlline.co.license
        cat $htmlline.co.license >> $Pagesclipco
	    cat $htmlline.co.license
#T echo "*** $htmlline.co.license : ***"; cat $htmlline.co.license; exit 0	   

#O     authors. 
        rm -rf tmp
        echo -n $", ''authors : ''" > $htmlline.co.authors
#Test cat tmp; echo "$htmlline.co.authors"; exit -1
	    cat $htmlline.co.str | grep -i -n -m1 -A 1 -e Author -e Auteur | tr '/' '\n' | grep -i -e user -e utilisteur -e auteur -e author | cut -d '"' -f1 | grep -i -e user -e utilisteur -e auteur -e author > tmp        
        if test -s tmp; then echo ; else echo "-" > tmp; fi
        cat tmp >> $htmlline.co.authors
        cat $htmlline.co.authors >> $Pagesclipco
        cat $htmlline.co.authors 	   
#O   Finish the page $Pagesclipco
      echo "" >> $Pagesclipco
#O   End of as long as there are lines in commonshtml.list
      done < commonshtml.list
#O  End of 'if the line is not the name of book'.
     fi      
#O End of while line in $Bookname.pj
    done < $Projectdir/$Bookname.pj
#O clean intermediate files
    rm -rf tmp
#O End of page $Pagesclipco 
    echo "</div>" >> $Pagesclipco
    #T echo "$(gettext ' {{Newpage}} ')" >> $Pagesclipco 
    echo "<div style='page-break-before:always'></div>" >> $Pagesclipco
#O ============================================================================	
#O Creating Bookname.appendix
    cat $Projectdir/$Bookname.sclt>$Projectdir/$Bookname.appendix
    cat $Projectdir/$Bookname.sclipco>>$Projectdir/$Bookname.appendix
    echo $"= License of articles and sofware =">>$Projectdir/$Bookname.appendix
    echo "<div style='font-zize:85%'>">>$Projectdir/$Bookname.appendix
    echo "Creative Commons Attribution Share Alike 3.0">>$Projectdir/$Bookname.appendix
    echo "//creativecommons.org/licenses/by-sa/3.0/">>$Projectdir/$Bookname.appendix
    echo >>$Projectdir/$Bookname.appendix
    echo $"This appendix is created with addappendix software version $VERSION">>$Projectdir/$Bookname.appendix
    echo "https://fr.wikibooks.org/wiki/Auto-éditer_un_wikilivre/addappendix">>$Projectdir/$Bookname.appendix
    echo "</div>">>$Projectdir/$Bookname.appendix
    echo "<div style='page-break-before:always'></div>">>$Projectdir/$Bookname.appendix
#O ============================================================================	
#O Display file Bookname.appendix
    echo;echo -e "\033[1;32mcopy and paste the text displayed and add after the book $Bookname.\033[0m"
    cat $Projectdir/$Bookname.appendix 
    echo;echo -e "\033[1;32mcopy and paste the text displayed and add after the book.$Bookname\033[0m"
    exit 0
#O addappendix script end

script tests_addappendix.bashModifier

#!/bin/bash
#!/bin/bash
#H Header doc
#H -------------------------------
#H File : tests/addappendix/tests_addapendix.bash
#H Syntax : ./tests_addapendix.bash
#H Created : 220113 by GC
#H Updated : 220113 by ... for
#O Organizational chart
#O -------------------------------
#P Programmers notes
#P -------------------------------
VERSION=220119
#P Before execute this tests, execute tests/preinstall-usr-local.bash to install datas directory in /usr/local

echo -e "\033[1;033mtest addappendix.sh with first param empty\033[0m"
./addappendix.sh
sleep 3
echo "----"

echo -e "\033[1;033mtest addappendix.sh with first param = '?'\033[0m"
./addappendix.sh ?
sleep 3
echo "----"

echo -e "\033[1;033mtest addappendix.sh with first param = '--v'\033[0m"
./addappendix.sh --v
sleep 3
echo "----"

echo -e "\033[1;033mtest addappendix.sh with param = https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel\033[0m"
./addappendix.sh https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel

Résultat des testsModifier

Au Terminal
cardabela@jpl-W230SS:~/addappendix-211219/tests/addapendix$ ./tests_addapendix.bash 
test addappendix.sh with first param empty
No parameter. addappendix [ <full url of book> | ? | -v ]
----
test addappendix.sh with first param = '?'
Syntax: addappendix [ <full url of book> | -v ]
  Example 1 : addappendix https://en.wikibooks.org/wiki/Wikibooks:Collections/Guide_to_Unix
  Example 2 : addappendix https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel

----
test addappendix.sh with first param = '-v'
addapendix version : 220117
----
test addappendix.sh with param = https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel
https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel
  is a wiki-books
File https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel is found

Book name : Faire_sa_fleur_de_sel
Compilations name: Wikilivres:Compilations
Suffix = compiled

Faire_sa_fleur_de_sel.compiled : 
[[Faire fleurir le sel/Couverture]]
[[Faire fleurir le sel/Introduction]]
[[Faire fleurir le sel/Préparation]]
[[Faire fleurir le sel/Filtrer et aseptiser]]
[[Faire fleurir le sel/Récolter]]

Dowload https://fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel

List of book files created 31/01/2022
 find Add_appendix/books/Faire_sa_fleur_de_sel/
Add_appendix/books/Faire_sa_fleur_de_sel/
Add_appendix/books/Faire_sa_fleur_de_sel/Faire_sa_fleur_de_sel.prj
Add_appendix/books/Faire_sa_fleur_de_sel/fr.wikibooks.org
Add_appendix/books/Faire_sa_fleur_de_sel/fr.wikibooks.org/robots.txt
Add_appendix/books/Faire_sa_fleur_de_sel/fr.wikibooks.org/wiki
Add_appendix/books/Faire_sa_fleur_de_sel/fr.wikibooks.org/wiki/Faire_fleurir_le_sel
Add_appendix/books/Faire_sa_fleur_de_sel/fr.wikibooks.org/wiki/Faire_fleurir_le_sel/Introduction.html
Add_appendix/books/Faire_sa_fleur_de_sel/fr.wikibooks.org/wiki/Faire_fleurir_le_sel/Récolter.html
Add_appendix/books/Faire_sa_fleur_de_sel/fr.wikibooks.org/wiki/Faire_fleurir_le_sel/Préparation.html
Add_appendix/books/Faire_sa_fleur_de_sel/fr.wikibooks.org/wiki/Faire_fleurir_le_sel/Filtrer_et_aseptiser.html
Add_appendix/books/Faire_sa_fleur_de_sel/fr.wikibooks.org/wiki/Faire_fleurir_le_sel/Couverture.html
Add_appendix/books/Faire_sa_fleur_de_sel/Faire_sa_fleur_de_sel.dirs
Add_appendix/books/Faire_sa_fleur_de_sel/Filtrer_et_aseptiser
Add_appendix/books/Faire_sa_fleur_de_sel/Filtrer_et_aseptiser/Filtre
Add_appendix/books/Faire_sa_fleur_de_sel/Filtrer_et_aseptiser/Filtrer_et_aseptiser.license
Add_appendix/books/Faire_sa_fleur_de_sel/Filtrer_et_aseptiser/Filtrer_et_aseptiser.author
Add_appendix/books/Faire_sa_fleur_de_sel/Filtrer_et_aseptiser/Filtrer_et_aseptiser.html
Add_appendix/books/Faire_sa_fleur_de_sel/Filtrer_et_aseptiser/Filtrer_et_aseptiser.str
Add_appendix/books/Faire_sa_fleur_de_sel/Filtrer_et_aseptiser/Filtrer_et_aseptiser.article
Add_appendix/books/Faire_sa_fleur_de_sel/Filtrer_et_aseptiser/Filtrer_et_aseptiser.RevisionId
Add_appendix/books/Faire_sa_fleur_de_sel/Faire_sa_fleur_de_sel.sclt
Add_appendix/books/Faire_sa_fleur_de_sel/Faire_sa_fleur_de_sel.compiled.cleaned
Add_appendix/books/Faire_sa_fleur_de_sel/Faire_sa_fleur_de_sel.pj
Add_appendix/books/Faire_sa_fleur_de_sel/Faire_sa_fleur_de_sel.locale.list
Add_appendix/books/Faire_sa_fleur_de_sel/.tmp
Add_appendix/books/Faire_sa_fleur_de_sel/Faire_sa_fleur_de_sel.compiled
Add_appendix/books/Faire_sa_fleur_de_sel/Faire_sa_fleur_de_sel.list
Add_appendix/books/Faire_sa_fleur_de_sel/Préparation
Add_appendix/books/Faire_sa_fleur_de_sel/Préparation/Préparation.author
Add_appendix/books/Faire_sa_fleur_de_sel/Préparation/Préparation.html
Add_appendix/books/Faire_sa_fleur_de_sel/Préparation/Préparation.RevisionId
Add_appendix/books/Faire_sa_fleur_de_sel/Préparation/Préparation.license
Add_appendix/books/Faire_sa_fleur_de_sel/Préparation/Préparation.str
Add_appendix/books/Faire_sa_fleur_de_sel/Préparation/Préparation.article
Add_appendix/books/Faire_sa_fleur_de_sel/Récolter
Add_appendix/books/Faire_sa_fleur_de_sel/Récolter/Récolter.tmp
Add_appendix/books/Faire_sa_fleur_de_sel/Récolter/Récolter.license
Add_appendix/books/Faire_sa_fleur_de_sel/Récolter/Récolter.html
Add_appendix/books/Faire_sa_fleur_de_sel/Récolter/Récolter.author
Add_appendix/books/Faire_sa_fleur_de_sel/Récolter/Récolter.article
Add_appendix/books/Faire_sa_fleur_de_sel/Récolter/Récolter.str
Add_appendix/books/Faire_sa_fleur_de_sel/Récolter/Récolter.RevisionId
Add_appendix/books/Faire_sa_fleur_de_sel/resources
Add_appendix/books/Faire_sa_fleur_de_sel/resources/Faire_sa_fleur_de_sel
Add_appendix/books/Faire_sa_fleur_de_sel/resources/Faire_sa_fleur_de_sel/fr.wikibooks.org
Add_appendix/books/Faire_sa_fleur_de_sel/resources/Faire_sa_fleur_de_sel/fr.wikibooks.org/robots.txt
Add_appendix/books/Faire_sa_fleur_de_sel/resources/Faire_sa_fleur_de_sel/fr.wikibooks.org/wiki
Add_appendix/books/Faire_sa_fleur_de_sel/resources/Faire_sa_fleur_de_sel/fr.wikibooks.org/wiki/Wikilivres:Compilations
Add_appendix/books/Faire_sa_fleur_de_sel/resources/Faire_sa_fleur_de_sel/fr.wikibooks.org/wiki/Wikilivres:Compilations/Faire_sa_fleur_de_sel.html
Add_appendix/books/Faire_sa_fleur_de_sel/resources/Faire_sa_fleur_de_sel/Faire_sa_fleur_de_sel
Add_appendix/books/Faire_sa_fleur_de_sel/resources/Faire_sa_fleur_de_sel/extract-dd1
Add_appendix/books/Faire_sa_fleur_de_sel/resources/Faire_sa_fleur_de_sel/Faire_sa_fleur_de_sel.compiled
Add_appendix/books/Faire_sa_fleur_de_sel/resources/Faire_sa_fleur_de_sel/extract-li1
Add_appendix/books/Faire_sa_fleur_de_sel/resources/Faire_sa_fleur_de_sel/extract-dd
Add_appendix/books/Faire_sa_fleur_de_sel/resources/Faire_sa_fleur_de_sel/extract-li
Add_appendix/books/Faire_sa_fleur_de_sel/Introduction
Add_appendix/books/Faire_sa_fleur_de_sel/Introduction/Introduction.article
Add_appendix/books/Faire_sa_fleur_de_sel/Introduction/Introduction.html
Add_appendix/books/Faire_sa_fleur_de_sel/Introduction/Introduction.license
Add_appendix/books/Faire_sa_fleur_de_sel/Introduction/Introduction.RevisionId
Add_appendix/books/Faire_sa_fleur_de_sel/Introduction/Introduction.str
Add_appendix/books/Faire_sa_fleur_de_sel/Introduction/Introduction.author
Add_appendix/books/Faire_sa_fleur_de_sel/Faire_sa_fleur_de_sel.mainPage
Add_appendix/books/Faire_sa_fleur_de_sel/Couverture
Add_appendix/books/Faire_sa_fleur_de_sel/Couverture/Couverture.license
Add_appendix/books/Faire_sa_fleur_de_sel/Couverture/Couverture.article
Add_appendix/books/Faire_sa_fleur_de_sel/Couverture/Couverture.tmp
Add_appendix/books/Faire_sa_fleur_de_sel/Couverture/Couverture.RevisionId
Add_appendix/books/Faire_sa_fleur_de_sel/Couverture/Couverture.html
Add_appendix/books/Faire_sa_fleur_de_sel/Couverture/Couverture.author
Add_appendix/books/Faire_sa_fleur_de_sel/Couverture/Couverture.str

Appendix en anglais créée avec addappendix le 25 février 2022Modifier

  • À consulter :

Appendix de la compilation Faire_sa_fleur_de_sel, le 25 février 2022, avec la version internationalisée addappendix pour l'empaquetage linux;


Annexe en français créée avec addappendix le 6 mars 2022Modifier

Annexes de la compilation avec la traduction fr/LC_MESSAGES/addappendix.mo

  • À comparer avec la version de juin 2020 :

Annexe de Faire_fleurir_le_sel, Juin 2020, avec la première version Annexer

Tests du script d’installation du logiciel par MakefileModifier

Script du MakefileModifier

#!/bin/make
# file:Makefile to install ubuntu addappendix
# addappendix-O~220313
# updated by french wikibooks user:Goelette_Cardabela
# 
# Install this Makefile in ~/Add_appendix
# To test make -d clean install DESTDIR=../tests
# Lors de l'installation les fichiers sources doivent être recopiés
# d'un autre répertoire qui peut être ~/Add_appendix/tests
##
# /usr/local directory :
VERSION=220313
BIN		= $(DESTDIR)/usr/local/bin
DOCU	= $(DESTDIR)/usr/local/share/addappendix/doc
CATMANDIR		= $(DESTDIR)/var/cache/man
CATMANDIR_FR	= $(DESTDIR)/var/cache/man/fr.UTF-8/cat1 debian
DATAS	= $(DESTDIR)/usr/local/datas
DOC		= $(DESTDIR)/usr/local/share/doc/Add_appendix
ETC		= $(DESTDIR)/usr/local/etc
LIB		= $(DESTDIR)/usr/local/lib
SLIBS	= annex.lib.sh cpcleaned2bin.sh ecfpb.sh ecfpc.sh findbook.sh killalldoc.sh
# system directories :
ICONS	= $(DESTDIR)/usr/share/icons/hicolor
LANG	= $(DESTDIR)/usr/share/locale
MAN		= $(DESTDIR)/usr/share/man
MIME	= $(DESTDIR)/usr/share/mime
SRC		= $(DESTDIR)/usr/local/src/Add_appendix
SRCS	= addappendix.sh
SBIN	= $(DESTDIR)/usr/local/sbin
SBINS	= compil2bin.sh findversions.sh install_annex.sh \
		install_datasfiles.sh makeman_annex.sh users_install_annex.sh
PGM		= addappendix

# local Add_appendix directories as variables
Installdir=.
Workdir=.
Bindir=./bin
Booksdir=./books
Datasdir=./datas
Libdir=./lib
Sharedir=./share
Srcdir=./src/Add_appendix
Sbindir=./sbin
Testsdir=./tests
Varsdir=./vars
Langdir=./share/addappendix/resources/lang/po
Localedir=./share/locale
Mandir=./share/man

install: $(PGM)
            
$(PGM): 
	@echo "*** DESTDIR : $(DESTDIR)"
	# Create all directories to making up the application
	install -d $(BIN) $(DOCU) $(CATMANDIR_FR) $(DATAS) $(LIB) $(ETC) $(SBIN) $(SRC)
	# Copy all sources files in SRC directory
	cp -f $(Srcdir)/* $(SRC)/.
	# Copy all executables files in BIN directory
	cp -f $(Bindir)/* $(BIN)/.
	# Copy all datas files to DATAS directory
	cp -f $(Datasdir)/* $(DATAS)/.
	# Copy all sbin executables files to SBIN directory
	cp -rf $(Sbindir)/* $(SBIN)/.
	# Copy all lib files to LIB directory
	cp -rf $(Libdir)/* $(LIB)/.
	# Create new Add_appendix directory and essential sub-directories from package
	@if [ -e ~/Add_appendix ]; then echo "~/Add_appendix exist, ok"; else mkdir -p ~/Add_appendix; fi
	@if [ -e ~/Add_appendix/books ]; then echo "~/Add-appendix/books exist ok"; else mkdir -p ~/Add_appendix/books; fi
	@if [ -e ~/Add_appendix/vars ]; then echo "~/Add_appendix/vars exist ok"; else mkdir -p ~/Add_appendix/vars; fi
	@if [ -e ~/Add_appendix/temp ]; then mkdir -p ~/Add_appendix/temp; fi

install: $(PGM)
    # Create SHARE sub directories
	install -d $(ICON) $(LANG) $(MAN) $(MIME)

	#install icons and update cache
	install -d $(ICONS) $(ICONS)/scalable/mimetypes $(ICONS)/256x256/mimetypes
	install -d $(ICONS)/256x256/apps $(ICONS)/48x48/apps $(ICONS)/32x32/apps $(ICONS)/16x16/apps $(ICONS)/8x8/apps
	#cp -f $(Sharedir)/icons/AA256x256.svg $(ICONS)/scalable/mimetypes/addappendix.svg
	cp -f $(Sharedir)/icons/hicolor/scalable/mimetypes/addappendix.svg  $(ICONS)/scalable/mimetypes/addappendix.svg
	#cp -f $(Sharedir)/icons/AA256x256.png $(ICONS)/256x256/mimetypes/addappendix.png
	cp -f $(Sharedir)/icons/hicolor/256x256/mimetypes/addappendix.png $(ICONS)/256x256/mimetypes/addappendix.png
	#cp -f $(Sharedir)/icons/AA256x256.svg $(ICONS)/256x256/mimetypes/addappendix.svg
	cp -f $(Sharedir)/icons/hicolor/256x256/mimetypes/addappendix.svg $(ICONS)/256x256/mimetypes/addappendix.svg
	#cp -f $(Sharedir)/icons/AA48x48bleu.png $(ICONS)/48x48/apps/addappendix.png
	cp -f $(Sharedir)/icons/hicolor/48x48/apps/addappendix.png $(ICONS)/48x48/apps/addappendix.png
	#cp -f $(Sharedir)/icons/AA32x32bleu.png $(ICONS)/32x32/apps/addappendix.png
	cp -f $(Sharedir)/icons/hicolor/32x32/apps/addappendix.png $(ICONS)/32x32/apps/addappendix.png
	#cp -f $(Sharedir)/icons/AA16x16bleu.png $(ICONS)/16x16/apps/addappendix.png
	cp -f $(Sharedir)/icons/hicolor/16x16/apps/addappendix.png $(ICONS)/16x16/apps/addappendix.png
	#cp -f $(Sharedir)/icons/AA8x8bleu.png $(ICONS)/8x8/apps/addappendix.png
	cp -f $(Sharedir)/icons/hicolor/8x8/apps/addappendix.png $(ICONS)/8x8/apps/addappendix.png
	#
	# Attention il faut que toute la commande soit sur la même ligne d'où le caractère escape '\'
	# On ne peut mettre à jour la base de données que si les images sont installées dans le système
	# La ligne suivante est à inclure dans 'postinst' du paquet ubuntu
	@if [ -z $(DESTDIR) ]; then sudo gtk-update-icon-cache -t /usr/share/icons/hicolor;fi

	# Install languages after directories installation
	install -d $(LANG)/de/LC_MESSAGES $(LANG)/en/LC_MESSAGES $(LANG)/fr/LC_MESSAGES $(LANG)/es/LC_MESSAGES
	## de
	#cp -f $(Localedir)/de/LC_MESSAGES/*.mo $(LANG)/de/LC_MESSAGES/.
	## en
	#cp -f $(Localedir)/en/LC_MESSAGES/*.mo $(LANG)/en/LC_MESSAGES/.
	## es
	#cp -f $(Localedir)/es/LC_MESSAGES/*.mo $(LANG)/es/LC_MESSAGES/.
	## fr
	cp -f $(Localedir)/fr/LC_MESSAGES/*.mo $(LANG)/fr/LC_MESSAGES/.
	cp -u $(Langdir)/fr/addappendix.mo $(LANG)/fr/LC_MESSAGES/addappendix.mo
	cp -u $(Langdir)/fr/annex.mo $(LANG)/fr/LC_MESSAGES/annex.mo
	cp -u $(Langdir)/fr/header.inc.mo $(LANG)/fr/LC_MESSAGES/header.inc.mo

	#install manuals
	install -d $(MAN) $(MAN)/man1 $(MAN)/de/man1 $(MAN)/en/man1 $(MAN)/es/man1 $(MAN)/fr/man1 $(MAN)/fr.UTF-8/man1
	## Default manual
	@if [ -e $(Mandir)/man1/addappendix.1.gz ]; then catman -M $(Man)/man1/addappendix.1.gz; fi
	@if [ -e $(mandir)/man1/annex.1.gz ]; then catman -M $(MAN)/man1/annex.1.gz; fi
	@if [ -e $(mandir)/man1/compil2bin.1.gz; then catman -M $(MAN)/man1/compil2bin.1.gz; fi
	## de
	## en
	## es
	## fr
	@if [ -e $(Mandir)/fr.UTF-8/man1/addappendix.1.gz ]; then catman -M $(MAN)/fr.UTF-8/man1/addappendix.1.gz; fi
	@if [ -e $(Mandir)/fr.UTF-8/man1/annex.1.gz; then catman -M $(MAN)/fr.UTF-8/man1/annex.1.gz; fi
	@if [ -e $(Mandir)/fr.UTF-8/man1/annexer.1.gz; then catman -M $(MAN)/fr.UTF-8/man1/annexer.1.gz; fi
	# La ligne suivante est à inclure dans 'postinst' du paquet ubuntu
	@if [ -z $(DESTDIR) ]; then mandb -u; fi

	#install mime
	install -d $(MIME)
	@if [ -e $Sharedir/mime/packages/addappendix.xml ]; then cp -f $Sharedir/mime/package/addappendix.xml $(MIME)/packages/addappendix.xml; fi
	@if [ -e $Sharedir/mime/packages/annexer.xml ]; then cp -f $Sharedir/mime/packages/annexer.xml $(MIME)/packages/annexer.xml; fi
	# La ligne suivante est à inclure dans 'postinst' du paquet ubuntu
	@if [ -z $(DESTDIR) ]; then sudo update-mime-database /usr/share/mime; fi

	
	#install archives
	#install -d $(ARCHIVES)/books
	#cp -rf ./archives/books/* $(ARCHIVES)/books/.
		
clean:
	rm -rf ./tmp
Résultat du test
~/tests$ find usr
usr
usr/share
usr/share/man
usr/share/man/es
usr/share/man/es/man1
usr/share/man/en
usr/share/man/en/man1
usr/share/man/de
usr/share/man/de/man1
usr/share/man/fr
usr/share/man/fr/man1
usr/share/man/man1
usr/share/man/fr.UTF-8
usr/share/man/fr.UTF-8/man1
usr/share/locale
usr/share/locale/es
usr/share/locale/es/LC_MESSAGES
usr/share/locale/en
usr/share/locale/en/LC_MESSAGES
usr/share/locale/de
usr/share/locale/de/LC_MESSAGES
usr/share/locale/fr
usr/share/locale/fr/LC_MESSAGES
usr/share/locale/fr/LC_MESSAGES/add_sclipwb.mo
usr/share/locale/fr/LC_MESSAGES/header.inc.mo
usr/share/locale/fr/LC_MESSAGES/en_sclipco.inc.mo
usr/share/locale/fr/LC_MESSAGES/en_sclt.inc.mo
usr/share/locale/fr/LC_MESSAGES/en_sclipwb.inc.mo
usr/share/locale/fr/LC_MESSAGES/annexer.mo
usr/share/locale/fr/LC_MESSAGES/scli.inc.mo
usr/share/locale/fr/LC_MESSAGES/addappendix.mo
usr/share/locale/fr/LC_MESSAGES/add_sclt.mo
usr/share/locale/fr/LC_MESSAGES/annex.mo
usr/share/locale/fr/LC_MESSAGES/fr_FR_addappendix.mo
usr/share/locale/fr/LC_MESSAGES/en_sclic.inc.mo
usr/share/locale/fr/LC_MESSAGES/add_sclipco.mo
usr/share/locale/fr/LC_MESSAGES/add_sclic.mo
usr/share/icons
usr/share/icons/hicolor
usr/share/icons/hicolor/48x48
usr/share/icons/hicolor/48x48/apps
usr/share/icons/hicolor/48x48/apps/addappendix.png
usr/share/icons/hicolor/16x16
usr/share/icons/hicolor/16x16/apps
usr/share/icons/hicolor/16x16/apps/addappendix.png
usr/share/icons/hicolor/256x256
usr/share/icons/hicolor/256x256/apps
usr/share/icons/hicolor/256x256/mimetypes
usr/share/icons/hicolor/256x256/mimetypes/addappendix.svg
usr/share/icons/hicolor/256x256/mimetypes/addappendix.png
usr/share/icons/hicolor/32x32
usr/share/icons/hicolor/32x32/apps
usr/share/icons/hicolor/32x32/apps/addappendix.png
usr/share/icons/hicolor/8x8
usr/share/icons/hicolor/8x8/apps
usr/share/icons/hicolor/8x8/apps/addappendix.png
usr/share/icons/hicolor/scalable
usr/share/icons/hicolor/scalable/mimetypes
usr/share/icons/hicolor/scalable/mimetypes/addappendix.svg
usr/share/mime
usr/local
usr/local/bin
usr/local/bin/add_sclic
usr/local/bin/testexecution
usr/local/bin/fr_sclt.inc
usr/local/bin/annex
usr/local/bin/site.txt
usr/local/bin/add_sclipwb
usr/local/bin/pre-annex
usr/local/bin/fr_sclipwb.inc
usr/local/bin/addappendix
usr/local/bin/en_sclic.inc
usr/local/bin/add_sclt
usr/local/bin/en_sclt.inc
usr/local/bin/header.inc
usr/local/bin/annexer
usr/local/bin/compilations.txt
usr/local/bin/mwbookurl.txt
usr/local/bin/en_sclipco.inc
usr/local/bin/add_appendix
usr/local/bin/updt-langs.bash
usr/local/bin/bookname.txt
usr/local/bin/en_sclipwb.inc
usr/local/bin/add_sclipco
usr/local/bin/scli.inc
usr/local/bin/README
usr/local/bin/list
usr/local/bin/fr_sclipco.inc
usr/local/bin/fr_sclic.inc
usr/local/bin/download
usr/local/share
usr/local/share/addappendix
usr/local/share/addappendix/doc
usr/local/src
usr/local/src/Add_appendix
usr/local/src/Add_appendix/add_sclic.sh
usr/local/src/Add_appendix/list.sh
usr/local/src/Add_appendix/en_sclic.inc.sh
usr/local/src/Add_appendix/files_list
usr/local/src/Add_appendix/en_sclipwb.inc.sh
usr/local/src/Add_appendix/add_sclipwb.sh
usr/local/src/Add_appendix/addappendix.sh
usr/local/src/Add_appendix/header.inc.sh
usr/local/src/Add_appendix/download.sh
usr/local/src/Add_appendix/fr_sclic.inc.sh
usr/local/src/Add_appendix/annexer.sh
usr/local/src/Add_appendix/FILES-VERSIONS.txt
usr/local/src/Add_appendix/add_sclipco.sh
usr/local/src/Add_appendix/fr_sclt.inc.sh
usr/local/src/Add_appendix/scli.inc.sh
usr/local/src/Add_appendix/annex.sh
usr/local/src/Add_appendix/en_sclipco.inc.sh
usr/local/src/Add_appendix/fr_sclipwb.inc.sh
usr/local/src/Add_appendix/fr_sclipco.inc.sh
usr/local/src/Add_appendix/en_sclt.inc.sh
usr/local/src/Add_appendix/pre-annex.sh
usr/local/src/Add_appendix/add_sclt.sh
usr/local/src/Add_appendix/add_appendix.sh
usr/local/lib
usr/local/lib/cpcleaned2bin.lib
usr/local/lib/ecf.lib
usr/local/lib/killalldoc.lib
usr/local/lib/findbook.lib
usr/local/lib/src
usr/local/lib/src/findbook.sh
usr/local/lib/src/files_list
usr/local/lib/src/FILES-VERSIONS.txt
usr/local/lib/src/ecfpc.sh
usr/local/lib/src/annex.lib.sh
usr/local/lib/src/killalldoc.sh
usr/local/lib/src/cpcleaned2bin.sh
usr/local/lib/src/ecfpb.sh
usr/local/lib/updt-annex-lib.sh
usr/local/lib/annex.lib
usr/local/sbin
usr/local/sbin/userman
usr/local/sbin/sbin_files.list
usr/local/sbin/sbin_files.versions.txt
usr/local/sbin/install_datasfiles
usr/local/sbin/install_annex
usr/local/sbin/users_install_annex
usr/local/sbin/htmlman
usr/local/sbin/BINFILES_VERSIONS
usr/local/sbin/makeman_annex
usr/local/sbin/sbin_files.versions2.txt
usr/local/sbin/src
usr/local/sbin/src/install_datasfiles.sh
usr/local/sbin/src/install_annex.sh
usr/local/sbin/src/users_install_annex.sh
usr/local/sbin/src/SRCFILES_VERSIONS
usr/local/sbin/src/compil2bin.sh
usr/local/sbin/src/findversions.sh
usr/local/sbin/src/makeman_annex.sh
usr/local/sbin/src/.txt
usr/local/sbin/src/list.txt
usr/local/sbin/compil2bin
usr/local/sbin/findversions
usr/local/sbin/textman
usr/local/sbin/docu2html
usr/local/sbin/updt-manuals
usr/local/etc
usr/local/datas
usr/local/datas/content_cleaner.dat
usr/local/datas/conversions.dat
usr/local/datas/unrecognized_links.dat
jpl@jpl-GE60-2OC-2OE:~/tests$ ls
usr  var
~/tests$ find var
var
var/cache
var/cache/man
var/cache/man/fr.UTF-8
var/cache/man/fr.UTF-8/cat1

liste des réperoires créésModifier