Auto-éditer un wikilivre/Annexer (Version internationalisée)/cp-src2bin.sh
Compil2bin.sh
modifier- 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 Header of compil2bin.sh
#H ------------------------
#H File : compil2bin.sh product compiled files in bindir and doumentation,
#H : pot files and more. See cpcleadned2bin.sh in lib directory
#H Syntax : compil2bin [--v|srcdir] [bindir|sbindir|libdir] [list-of-files.sh] [--t]
#H OPTIONS : --v, print version of compil2bin in test mode
#H : --t, clear screen and print parameters: version, srcdir, bindir, third parameter is present in test mode
#H : srcdir bindir, is source .sh shell directory, bindir is bin directory to receive compiled files
#H : list-of-files.sh, is the list of files in srcdir to convert for bin directory
#H
VERSION=211113
pwd > pwd.txt
read Currentdir<pwd.txt
cat pwd.txt | cut -d "/" -f4 > workname.txt
read Workname<workname.txt
#T echo -n "Working name directory= $Workname"
if [ $Workname = "Annexer" ] || [ $Workname = "Add_appendix" ]
then echo -n "" #T echo " is found";
else echo " Currentdir is not a working name directory"; exit -1
fi
rm workname.txt pwd.txt
Workdir=~/$Workname
Libdir=$Workdir/lib
source $Workdir/vars/installdir.var
#T echo "Install directory : $Installdir"
#T echo "Working dir : $Workdir"
#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 [--v|srcdir] [bindir|sbindir|libdir] [list-of-shell-files] [--t]"
exit -1
fi
#O Afficher la version si le premier argument est --v
if [ "$1" = "--v" ]; then echo "compil2bin : VERSION $VERSION"; exit 0; fi
#O If file-list is empty create file_list from SRC
#if test -z $3; then ls -1 $1 > file-list; fi
#O Afficher les paramètres si
N=$#
if [ "$N" = "--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 (#P if then else détaillé à cause des pertes d'information. éviter les ';')
if test -d $1
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
echo "Bin directory is found: $2"
Bindir=$2
else
echo "Bin directory is not found"
exit -1
fi
#O Affect Resourcesdir variable
if test -d "$Workdir/share/addappendix/resources"
then
Resourcesdir="$Workdir/share/addappendix/resources"
echo "Variable Resources 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 If the commandline hat only two parameters then compile all lines
if [ "$N" = "2" ]
then
Pwd=$PWD; cd $1; ls -1 *.sh > $Pwd/list.txt; cd $Pwd
while read line
do
echo "Line of list.txt: $line"
cpcleaned2bin $line
done < $Pwd/list.txt
#O Else create loop to ...for i in `seq 1 $#`
else
for i in "$@"
do
if test $i != $1 && test $i != $2
then
echo "$i"
cpcleaned2bin $i
fi
done
fi
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 [--v|srcdir] [bindir|sbindir|libdir] [list-of-shell-files] [--t]
#D
#D Examples: with file-list: users_install_annex.sh and install_annex.sh in SRC.
#D compil2bin srcdir bindir
#D or: compil2bin srcdir bindir $Parameters
#D $Parameters is variable content the list of files with .sh extensions
#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 with cpcleaned2bin function, 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 | grep "#M " | sed "s/#M //g" | grep -v "#P" > compil2bin_en.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 "5 nov 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)]\ [files-list]\ in\ Makefile
#M .br
#M .B compil2bin
#M .RI [--v|srcdir]\ [bindir|sbindir|libdir]\ [files-list]\ [--t]
#M .br
#M in\ Add-appendix\ software
#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\-\ [--v]\fP
#M Print the compil2bin version
#M .IP \fB\-\ $(SRC)\ and\ srcdir\fP
#M This variable is used in makefile example: SRC=/usr/local/src or srcdir=$Workdir/src\ in \fBAdd_appendix\fP software
#M .IP \fB\-\ [$(BIN)|$(SBIN)|$(LIB)]\ and\ [bindir|sbindir|libdir]\fP
#M This variables are used in makefile example: SBIN=/usr/local/sbin or bindir=$Bindir sbindir=$Sbindir libdir=$Libdir in \fBAdd_appendix\fP software
#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 .IP \fB\-\ [--t]\fP
#M Print the compil2bin variables in current command execution
#M .br
#M .SH EXAMPLES
#M .B compil2bin
#M .RI $Srcdir\ $Bindir
#M .br
#M .B compil2bin
#M .RI $Currentdir/src\ $Currentdir/bin\ $Parameters
#M .br
#M Variable \fB$Parameters\fP content the list of files to convert
#M .br
#M .SH NOTES
#M To complete 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- 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 exé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
test_compil2bin.bash
modifier- test program is in $Testdir/01-sbsrc/O11/compil2bin.sh/
- This test program also makes the manual copyable to /usr/share/man/man1/.
- syntax: sudo cp compil2bin_en.1.gz /usr/share/man/man1/compil2bin.1.gz
#!/bin/bash
#H File test_compil2bin.bash
#H
VERSION=211105
pwd > pwd.txt
read Currentdir<pwd.txt
cat pwd.txt | cut -d "/" -f4 > workname.txt
read Workname<workname.txt
#T echo -n "Working name directory= $Workname"
if [ $Workname = "Annexer" ] || [ $Workname = "Add_appendix" ]
then echo -n "" #T echo " is found";
else echo " Currentdir is not a working name directory"; exit -1
fi
rm workname.txt pwd.txt
Workdir=~/$Workname
Libdir=$Workdir/lib
source $Workdir/vars/installdir.var
Testsdir=$Workdir/tests
clear
if [ "$1" = "--v" ]; then echo "Version of test_compil2bin.bash $VERSION";exit 0;fi
echo -e "\033[1;33mcommande ./compil2bin.sh --v \033[0m"
./compil2bin.sh --v
sleep 3
echo "----"
echo -e "\033[1;33mcommande ./compil2bin.sh --v --t \033[0m"
./compil2bin.sh --v --t
sleep 3
echo "----"
echo -e "\033[1;33mcommande ./compil2bin.sh src bin --t \033[0m"
./compil2bin.sh src bin --t
sleep 3
echo "----"
echo -e "\033[1;33mcommande ./compil2bin.sh src bin compil2bin.sh --t; ls -1 bin after 3 sec \033[0m"
./compil2bin.sh src bin compil2bin.sh --t
sleep 3
echo -e "\033[1;33m ls -1 bin: \033[0m"; ls -1 bin
echo -e "\033[1;33m make local manual of compil2bin wtith compil2bin.sh \033[0m"
cat compil2bin.sh | grep "#M " | sed "s/#M //g" | grep -v "#P" > compil2bin_en.1
gzip compil2bin_en.1 compil2bin_en.1.gz
mv compil2bin_en.1.gz man/compil2bin_en.1.gz
man man/compil2bin_en.1.gz
sleep 3
echo "----"
echo -e "\033[1;33m./compil2bin.sh $Currentdir/src $Currentdir/bin \033[0m"
./compil2bin.sh $Currentdir/src $Currentdir/bin
sleep 3
ls -al bin
echo "----"
echo -e "\033[1;33m./compil2bin.sh $Currentdir/src $Currentdir/bin compil2bin.sh cp-src2bin.sh docu2html.sh findversions.sh install_annex.sh install_datasfiles.sh makeman_annex.sh users_install_annex.sh \033[0m"
./compil2bin.sh $Currentdir/src $Currentdir/bin compil2bin.sh cp-src2bin.sh docu2html.sh findversions.sh install_annex.sh install_datasfiles.sh makeman_annex.sh users_install_annex.sh
sleep 3
ls -al bin
echo "----"
clear
cd src;ls -m *.sh | sed "s/,//g"|tr "\n" " ">listm.txt
echo "List of files in srcdir:"; cat listm.txt; echo
cd $Currentdir
read Parameters < src/listm.txt
echo "Parameters: $Parameters"
echo -e "\033[1;33m./compil2bin.sh $Currentdir/src $Currentdir/bin $Parameters \033[0m"
./compil2bin.sh $Currentdir/src $Currentdir/bin $Parameters
ls -al bin
echo "----"
Manuel
modifiercompil2bin(1) Linux User's Manual compil2bin(1) NAME 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. SYNOPSIS compil2bin $(SRC) [$(BIN)|$(SBIN)|$(LIB)] [files-list] in Makefile compil2bin [--v|srcdir] [bindir|sbindir|libdir] [files-list] [--t] in Add-appendix software DESCRIPTION This manual page explains the compil2bin program. The compil2bin pro‐ gram is included in Makefile to install sources files in binary direc‐ tories 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/. OPTIONS - [--v] Print the compil2bin version - $(SRC) and srcdir This variable is used in makefile example: SRC=/usr/local/src or srcdir=$Workdir/src in Add_appendix software - [$(BIN)|$(SBIN)|$(LIB)] and [bindir|sbindir|libdir] This variables are used in makefile example: SBIN=/usr/lo‐ cal/sbin or bindir=$Bindir sbindir=$Sbindir libdir=$Libdir in Add_appendix software - [file-list] This arguments list are list of files to convert and install to $(BIN) or $(SBIN) or $(LIB) - [--t] Print the compil2bin variables in current command execution EXAMPLES compil2bin $Srcdir $Bindir compil2bin $Currentdir/src $Currentdir/bin $Parameters Variable $Parameters content the list of files to convert NOTES To complete your information: https://fr.wikibooks.org/wiki/An‐ nexes_de_wikibooks#Makefile_proposé_aux_essais SEE ALSO addapendix packages compil2bin(1) 5 nov 2021 compil2bin(1)