set -x

# Quick
## Create all the languages
## Delete everyone with lang_module except the one selected
## Create iso from test_fs

# Not So Quick but more neat
## Create only the selected language by playing with sdg_module file.
## Create tar from test_fs
## Run the command:



build_the_cdrom () {


IMAGE_NAME="$MAGIC_TARGET_FOLDER""/""$1"".iso"

./build_cdrom_iso.sh "${IMAGE_NAME}" 

}
#********************
#MAIN PROGRAM
#**************************#

# I will maybe put these variables to sgrub_configure.sh file.

# We want floppies in all languages
source ./util/all_languages.sh
+ source ./util/all_languages.sh
#!/bin/bash
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

SGD_MODULE_FILE=sdg_module
++ SGD_MODULE_FILE=sdg_module


for n_language in tr/*; do

if [ ! -e ${n_language}/${SGD_MODULE_FILE} ] ; then
  touch ${n_language}/${SGD_MODULE_FILE}
fi

done
++ for n_language in 'tr/*'
++ '[' '!' -e tr/S10en/sdg_module ']'
++ for n_language in 'tr/*'
++ '[' '!' -e tr/S20es/sdg_module ']'
++ touch tr/S20es/sdg_module
++ for n_language in 'tr/*'
++ '[' '!' -e tr/S21ca/sdg_module ']'
++ touch tr/S21ca/sdg_module
++ for n_language in 'tr/*'
++ '[' '!' -e tr/S25eu/sdg_module ']'
++ touch tr/S25eu/sdg_module
++ for n_language in 'tr/*'
++ '[' '!' -e tr/S27ga/sdg_module ']'
++ touch tr/S27ga/sdg_module
++ for n_language in 'tr/*'
++ '[' '!' -e tr/S30deu/sdg_module ']'
++ touch tr/S30deu/sdg_module
++ for n_language in 'tr/*'
++ '[' '!' -e tr/S30fra/sdg_module ']'
++ touch tr/S30fra/sdg_module
++ for n_language in 'tr/*'
++ '[' '!' -e tr/S30hun/sdg_module ']'
++ touch tr/S30hun/sdg_module
++ for n_language in 'tr/*'
++ '[' '!' -e tr/S30slo/sdg_module ']'
++ touch tr/S30slo/sdg_module



source ./sgrub_configure.sh
+ source ./sgrub_configure.sh
#!/bin/bash
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

read_sgd_version () 
{ 

# Update SGD version
#======================
# We are supposed to be inside dev_sgd folder
# We will go to ../
# Take the last 7 bytes (i.e. 0.9345) and put them somewhere on introduccion.txt
CURRENTPWD=`pwd`
cd ..
SGD_VERSION=`echo $PWD | tail -c 7 -`
# Go back to former folder.
cd ${CURRENTPWD}
}



# sgrub_configure.sh configures common folders for dev_sgd, dev_slb and dev_grub scripts

source ../sgrub_configure.sh
++ source ../sgrub_configure.sh
#!/bin/bash
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


# sgrub_configure.sh configures common folders for dev_sgd, dev_slb and dev_grub scripts
export FS_TARGET=`pwd`"/../test_fs"
pwd
++++ pwd
+++ export FS_TARGET=/home/adrian/Desktop/gnu/sgd/source_code/sgd_source_code_0.9656/dev_sgd/../test_fs
+++ FS_TARGET=/home/adrian/Desktop/gnu/sgd/source_code/sgd_source_code_0.9656/dev_sgd/../test_fs
export GRUB_RELATIVE="boot/grub"
+++ export GRUB_RELATIVE=boot/grub
+++ GRUB_RELATIVE=boot/grub
export GRUB_TARGET="${FS_TARGET}""/""${GRUB_RELATIVE}"
+++ export GRUB_TARGET=/home/adrian/Desktop/gnu/sgd/source_code/sgd_source_code_0.9656/dev_sgd/../test_fs/boot/grub
+++ GRUB_TARGET=/home/adrian/Desktop/gnu/sgd/source_code/sgd_source_code_0.9656/dev_sgd/../test_fs/boot/grub
export PROGRAM_RELATIVE="boot/sgd"
++ export PROGRAM_RELATIVE=boot/sgd
++ PROGRAM_RELATIVE=boot/sgd
export PROGRAM_TARGET="${FS_TARGET}""/""${PROGRAM_RELATIVE}"
++ export PROGRAM_TARGET=/home/adrian/Desktop/gnu/sgd/source_code/sgd_source_code_0.9656/dev_sgd/../test_fs/boot/sgd
++ PROGRAM_TARGET=/home/adrian/Desktop/gnu/sgd/source_code/sgd_source_code_0.9656/dev_sgd/../test_fs/boot/sgd
SDG_MODULE_ID="sdg_module"
+ SDG_MODULE_ID=sdg_module
SDG_LANG_ID="lang_module"
+ SDG_LANG_ID=lang_module
MAGIC_TARGET_FOLDER="../release"
+ MAGIC_TARGET_FOLDER=../release

# Check sudoers permissions

# Let's do one lang per lang.

for DIR2 in *
do
  # We want only the folders.
  if [ -d "$DIR2" ] && [ -e "$DIR2"/"${SDG_LANG_ID}" ] ; then
  
  for DIR in *
  do
  # We want only the folders 
	  if [ -d "$DIR" ] && [ -e "$DIR"/"${SDG_LANG_ID}" ] ; then
  # We want to process only folders with sdg_module on them
		        if [[ "$DIR" == "$DIR2" ]] ; then # The lang folder selected
			  if [ ! -e "$DIR"/"${SDG_MODULE_ID}" ] ; then # No module found... we create it.
			    cp "$DIR"/"${SDG_LANG_ID}" "$DIR"/"${SDG_MODULE_ID}" ;
			  fi
		        else # This is not the lang folder we want to make.
			  if [ -e "$DIR"/"${SDG_MODULE_ID}" ] ; then # If there's a module file... let's delete it.
			     rm "$DIR"/"${SDG_MODULE_ID}"
			  fi
			fi
	  fi
  done
build_the_cdrom "$DIR2"
  fi
done
+ for DIR2 in '*'
+ '[' -d brs ']'
+ '[' -e brs/lang_module ']'
+ for DIR2 in '*'
+ '[' -d build_cdrom_fs.sh ']'
+ for DIR2 in '*'
+ '[' -d build_cdrom_iso_from_fs.sh ']'
+ for DIR2 in '*'
+ '[' -d build_cdrom_iso.sh ']'
+ for DIR2 in '*'
+ '[' -d build_floppies.sh ']'
+ for DIR2 in '*'
+ '[' -d build_monolinguals_cds.sh ']'
+ for DIR2 in '*'
+ '[' -d build_monolinguals_usbs.sh ']'
+ for DIR2 in '*'
+ '[' -d build.sh ']'
+ for DIR2 in '*'
+ '[' -d build_usb_tar_bz2_from_fs.sh ']'
+ for DIR2 in '*'
+ '[' -d build_usb_tar_bz2.sh ']'
+ for DIR2 in '*'
+ '[' -d common ']'
+ '[' -e common/lang_module ']'
+ for DIR2 in '*'
+ '[' -d conf ']'
+ '[' -e conf/lang_module ']'
+ for DIR2 in '*'
+ '[' -d edition.txt ']'
+ for DIR2 in '*'
+ '[' -d errores.txt ']'
+ for DIR2 in '*'
+ '[' -d gpl ']'
+ '[' -e gpl/lang_module ']'
+ for DIR2 in '*'
+ '[' -d head_menu.lst ']'
+ for DIR2 in '*'
+ '[' -d lng ']'
+ '[' -e lng/lang_module ']'
+ for DIR2 in '*'
+ '[' -d mkfloppyimage.sh ']'
+ for DIR2 in '*'
+ '[' -d prueba3 ']'
+ for DIR2 in '*'
+ '[' -d prueba4 ']'
+ for DIR2 in '*'
+ '[' -d readme.txt ']'
+ for DIR2 in '*'
+ '[' -d root_cd_menu.lst ']'
+ for DIR2 in '*'
+ '[' -d sgd.lst ']'
+ for DIR2 in '*'
+ '[' -d sgrub_configure.sh ']'
+ for DIR2 in '*'
+ '[' -d tail_menu.lst ']'
+ for DIR2 in '*'
+ '[' -d test_any_cdrom_with_qemu.sh ']'
+ for DIR2 in '*'
+ '[' -d test_cdrom_with_qemu_from_fs.sh ']'
+ for DIR2 in '*'
+ '[' -d test_cdrom_with_qemu.sh ']'
+ for DIR2 in '*'
+ '[' -d tr ']'
+ '[' -e tr/lang_module ']'
+ for DIR2 in '*'
+ '[' -d util ']'
+ '[' -e util/lang_module ']'

# We want only one language for developing
source ./util/only_english.sh
+ source ./util/only_english.sh
#!/bin/bash
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

ENGLISH_LANGUAGE="tr/S10en"
++ ENGLISH_LANGUAGE=tr/S10en
SGD_MODULE_FILE=sdg_module
++ SGD_MODULE_FILE=sdg_module



for n_language in tr/* ; do

if [ -e ${n_language}/${SGD_MODULE_FILE} ] ; then
  rm ${n_language}/${SGD_MODULE_FILE}
fi


done
++ for n_language in 'tr/*'
++ '[' -e tr/S10en/sdg_module ']'
++ rm tr/S10en/sdg_module
++ for n_language in 'tr/*'
++ '[' -e tr/S20es/sdg_module ']'
++ rm tr/S20es/sdg_module
++ for n_language in 'tr/*'
++ '[' -e tr/S21ca/sdg_module ']'
++ rm tr/S21ca/sdg_module
++ for n_language in 'tr/*'
++ '[' -e tr/S25eu/sdg_module ']'
++ rm tr/S25eu/sdg_module
++ for n_language in 'tr/*'
++ '[' -e tr/S27ga/sdg_module ']'
++ rm tr/S27ga/sdg_module
++ for n_language in 'tr/*'
++ '[' -e tr/S30deu/sdg_module ']'
++ rm tr/S30deu/sdg_module
++ for n_language in 'tr/*'
++ '[' -e tr/S30fra/sdg_module ']'
++ rm tr/S30fra/sdg_module
++ for n_language in 'tr/*'
++ '[' -e tr/S30hun/sdg_module ']'
++ rm tr/S30hun/sdg_module
++ for n_language in 'tr/*'
++ '[' -e tr/S30slo/sdg_module ']'
++ rm tr/S30slo/sdg_module

# make sure that English has its sgd_module

if [ ! -e ${ENGLISH_LANGUAGE}/${SGD_MODULE_FILE} ] ; then
  touch ${ENGLISH_LANGUAGE}/${SGD_MODULE_FILE}
fi
++ '[' '!' -e tr/S10en/sdg_module ']'
++ touch tr/S10en/sdg_module


