Auto-éditer un wikilivre/Annexer (Version internationalisée)/cp-src2bin.sh

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

Compil2bin.sh[modifier | modifier le wikicode]

  • Attention this script is common for lib, sbin, and src for Add_appendix software
  • this script is used in package addappendix-O~210927
#!/bin/bash
#H File   : use compil2bin.shell for compress to compil2bin executable

VERSION=211016

#T echo "Sources = $1 ; Bin is : $2"; exit 0

#O Si le premier paramètre est vide afficher la syntaxe
    if test -z "$1";then echo "Syntax : compil2bin $(SRC) [ $(BIN) | $(SBIN) | $(LIB) ] <file-list>"

#O Afficher la version si le premier argument est --v
    if [ "$1" = "--t" ] 
	then 
	  clear screen 
	  echo "compil2bin version $VERSION"
	  echo "Directories: "
	  echo "SRC=?$1, BIN=?$2"
	  if test -e $3; then echo "file list is not empty, see forward."; fi
	  exit 0
	fi
	
#O if [ "$1" = "compil2bin.sh" ]; then echo "cannot self extracting compil2bin.sh"; exit -1; 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 Resouces is found: $Resourcesdir"; fi

#O Indicate the number of pameters
	echo "Number of parameter : $#"
	
#T 
exit 0

#P include $Libdir/annex.lib to access at cpcleaned2bin function
source $Libdir/annex.lib

#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
exit 0  

#D
#D Documentation for compil2bin shell file
#D ----------------------------------------
#D Compil2bin is used in package to product addappendix-<version>.deb and
#D   to copy sources files to bin directories.
#D
#D Makefile syntax: compil2bin SRC-OPTIONS BIN-OPTIONS <file-list>
#D   SRC-OPTIONS: [ $(SRCS) | $(SBINS) | $(SLIBS) ]
#D   BIN-OPTIONS: [ $(BIN) | $(SBIN) | $(LIB) ]
#D   <file-list> are shell files list to compil from SRC directory
#D
#D Shell syntax: compil2bin <SRC> <BIN> <file-list>
#D   SRC OPTIONS: $Installdir/src or $Workdir/tests/xx-shell.sh-directories
#D   BIN OPTIONS: [ $BIN | $SBIN | $LIB ]
#D
#D Examples: with file-list: users_install_annex.sh and install_annex.sh in SRC.
#D  SRC=$HOME/Add_appendix/tests/01-sbsrc SBIN=$HOME/Add_appendix/sbin file-list
#D or: compil2bin $Testsdir/01-sbsrc $Sbindir users_install_annex.sh compil2bin.sh
#D or: ~/Add_appendix/sbin/compil2bin $Testsdir/01-sbsrc $Sbindir install_annex.sh
#D or: ~/Add_appendix/sbin/compil2bin $HOME/Add_appendix/tests/01-sbsrc $HOME/Add_appendix/sbin install_annex.sh
#D Compilation shell bash file-list product files to directories specified by
#D   first parameter.
#D
#D The compilation consists of eliminating the tags of Documentation, Manual,
#D   Organization-charts, Programmers-doc Tests-doc and producing .pot .po files
#D   for the translations, can also update .mo files.
#D

#P Note: The manuals must be extracted with the command grep -v "#M ". 
#P There must always be a space between #M and the text to extract.
#M .\ Manual man1 extraction: cat compil2bin.sh | sed "s/#M//g" | grep -v "cat" > compil2bin.1 
#M .\ This manual is included in compil2bin.sh source file
#M .\"Replace <program> with the program name, x with the Section Number
#M .TH compil2bin 1 "9 oct 2021" "compil2bin(1)" "Linux User's Manual"
#M .SH NAME
#M compi2bin \- compilation program consists of eliminating the tags of Documentation, Manual, Organization-charts, Programmers-doc Tests-doc and producing .pot .po files for the translations, can also update .mo files.
#M .SH SYNOPSIS
#M .B compil2bin
#M .RI $(SRC) [$(BIN)|$(SBIN)|$(LIB)] <file-list> 
#M .br
#M .SH DESCRIPTION
#M This manual page explains the \fBcompil2bin\fP program. The \fBcompil2bin\fP program is included in Makefile to install sources files in binary directories such as bin lib sbin  and product .pot  .po .mo files to lang resources directories. If you are edit and saved po files you can copy .mo files to /usr/share/locale/lang/LC_MESSAGES/.
#M .SH OPTIONS
#M .IP \fB\-$(SRC)\fP
#M This variable is used in makefile example: SRC = /usr/local/src
#M .IP \fB\-[$(BIN)|$(SBIN)|$(LIB)]\fP
#M This variables are used in makefile example: SBIN = /usr/local/sbin
#M .IP \fB\-<file-list>\fP
#M This arguments list are list of files to convert and install to $(BIN) or $(SBIN) or $(LIB)
#M .SH NOTES
#M To compete your information:
#M https://fr.wikibooks.org/wiki/Annexes_de_wikibooks#Makefile_proposé_aux_essais
#M .SH "SEE ALSO"
#M addapendix packages
#M
#O End of compil2bin

old version cp-src2bin.sh[modifier | modifier le wikicode]

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