pkg.sh (2377B)
1 #!/bin/bash 2 # 3 # Copyright (C) 2017-2018 |Meso|Star> 4 # 5 # This program is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation, either version 3 of the License, or 8 # (at your option) any later version. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 set -e 19 20 if [ $# -lt 2 ]; then 21 echo "Usage: $0 SOLSTICE-PP-PATH VERSION" 22 exit 1 23 fi 24 25 solpp=$1 26 version=$2 27 28 29 if [ ! -d $solpp \ 30 -o ! -f $solpp/Makefile \ 31 -o ! -f $solpp/Makefile.in ]; then 32 echo "Invalid SOLSTICE-PP-PATH \"$1\"" 33 exit 1 34 fi 35 36 dir_curr=$(pwd) # Current directory 37 dir_temp=$(mktemp -d) # Working directory 38 dir_solpp=Solstice-PP-Sources-$version 39 40 # Create the pkg directory 41 mkdir $dir_temp/$dir_solpp 42 43 # Define the solpp sources 44 src=$(cd $solpp; find -maxdepth 1 -name "*.c" -o -name "*.h" | sed 's/\.\///g') 45 46 # Copy the sources and the COPYING file into the pkg directory 47 cp $solpp/COPYING $dir_temp/$dir_solpp 48 for i in $src; do 49 cp $solpp/$i $dir_temp/$dir_solpp 50 done 51 52 # Generate the Makefile 53 { 54 echo "# Copying and distribution of this file, with or without modification," 55 echo "# are permitted in any medium without royalty provided the copyright" 56 echo "# notice and this notice are preserved. This file is offered as-is," 57 echo "# without any warranty." 58 echo "" 59 cat $solpp/Makefile.in | sed -n '/^CFLAGS/p' 60 echo "SOURCES = $(echo $src | sed 's/[ \t]*[a-z0-9]\+\.h//g')" 61 echo 'PROG = $(SOURCES:%.c=%)' 62 echo "" 63 echo '.PHONY: default all clean' 64 echo 'default: $(PROG)' 65 echo "" 66 echo '$(PROG): %: %.c solpp.h' 67 echo -e '\t@echo -e "CC $<"; $(CC) -o $@ $(CFLAGS) $<' 68 echo "" 69 echo 'clean:' 70 echo -e '\t@rm $(PROG)' 71 } > $dir_temp/$dir_solpp/Makefile 72 73 # Generate the README.md file 74 { 75 echo "# Solstice Post-Process" 76 echo "" 77 cat $solpp/README.md | sed '/Release notes/,$!d' 78 } > $dir_temp/$dir_solpp/README.md 79 80 #Make the package 81 cd $dir_temp 82 tar czf ${dir_solpp}.tar.gz $dir_solpp 83 cp ${dir_solpp}.tar.gz $dir_curr 84 85 echo "${dir_solpp}.tar.gz" 86