pack_in_onefile.sh 1.63 KB
Newer Older
1
#!/bin/sh
2 3 4 5 6 7
#
# Run for create one-file-scripts
#
# Copyright (C) 2012  Etersoft
# Copyright (C) 2012  Vitaly Lipatov <lav@etersoft.ru>
#
8 9 10
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
11 12 13 14 15
# (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
16
# GNU Affero General Public License for more details.
17
#
18 19
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20 21
#

22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38

incorporate_distr_info()
{
cat <<EOF >>$OUTPUT
internal_distr_info()
{
EOF

cat bin/distr_info >>$OUTPUT

cat <<EOF >>$OUTPUT
}
EOF
}

filter_out()
{
39
	grep -v "^load_helper " | sed -e 's|DISTRVENDOR=$PROGDIR/distr_info|DISTRVENDOR=internal_distr_info|g'
40 41 42 43 44 45
}

incorporate_all()
{
OUTPUT=$PACKCOMMAND-packed.sh
echo -n >$OUTPUT
46
awk 'BEGIN{desk=0}{if(/^load_helper epm-sh-functions/){desk++};if(desk==0) {print}}' <bin/$PACKCOMMAND | filter_out >>$OUTPUT
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65

for i in bin/epm-sh-functions $(ls -1 bin/$PACKCOMMAND-* | grep -v epm-sh-functions | sort) ; do
	echo
	echo "# File $i:"
	cat $i | grep -v "^#"
done | filter_out >>$OUTPUT

incorporate_distr_info

awk 'BEGIN{desk=0}{if(desk>0) {print} ; if(/^load_helper epm-sh-functions/){desk++}}' <bin/$PACKCOMMAND | filter_out >>$OUTPUT
}

###############
PACKCOMMAND=epm
incorporate_all

###############
PACKCOMMAND=serv
incorporate_all