]> git.ipfire.org Git - ipfire-3.x.git/blame - tools/make-rootfiles
Added new package: dosfstools.
[ipfire-3.x.git] / tools / make-rootfiles
CommitLineData
b07899d1
MT
1#!/bin/bash
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
5# Copyright (C) 2008, 2009 Michael Tremer & Christian Schmidt #
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
21
22for path in \
23 $BASEDIR/src/rootfiles/{core,debug,extras}/$TARGET/ \
24 $BASEDIR/src/rootfiles/{core,debug,extras}/; do
25 [ -d "$path" ] && ROOTFILES_DIR="$ROOTFILES_DIR $path"
26done
27
28rootfiles_check() {
29 ACTION=$1
30
31 echo -n " Running rootfile checks"
32
33 ROOTFILES=$(find $BASEDIR/src/rootfiles/{core,extras,debug}/ -type f)
34
35 case "$ACTION" in
36 --fix)
37 echo -n " and fix"
38
39 # Remove leading pluses and replace them by '#'
40 for i in $ROOTFILES; do
41 [ ! -f $i ] && continue
42 sed -e "s/^+/#/g" -i $i
43 done
44 ;;
45 "")
46 : # If no option was given we do nothing.
47 ;;
48 *)
49 exiterror "This is not a valid option: $ACTION"
50 ;;
51 esac
52
53 echo -n "..." # End the line
54
55 for i in $ROOTFILES; do
56 # Leading slashes
57 grep -q ^/ $i
58 if [ "$?" -eq "0" ]; then
59 dialogerror "Please check your rootfile of \"$(basename $i)\" for leading slashes."
60 exit 1
61 fi
62
63 # Leading plusses
64 grep -q ^+ $i
65 if [ "$?" -eq "0" ]; then
66 dialogerror "Please check your rootfile of \"$(basename $i)\" for leading plusses."
67 exit 1
68 fi
69
70 # Empty lines
71 grep -q ^$ $i
72 if [ "$?" -eq "0" ]; then
73 dialogerror "Please check your rootiles of \"$(basename $i)\" for empty lines."
74 exit 1
75 fi
76 done
77 beautify message DONE
78}
79
80rootfiles_commit() {
ee9afcd6 81 TEMPFILE=$(mktemp)
481f655d 82 echo "Rootfile update." > $TEMPFILE
ee9afcd6
MT
83 git_commit -F $TEMPFILE src/rootfiles
84 rm -f $TEMPFILE
b07899d1
MT
85}
86
87rootfiles_copy() {
88 for i in $@; do
89 ( unset NAME VERSION
90 ROOTFILE=$(rootfiles_findone $i)
91 if [ "$ROOTFILE" = "" ]; then
92 dialogerror "Rootfile of \"$i\" not found. Create it first."
93 return 1
94 fi
95 eval $(pkg_info $i)
96 for j in $NAME{-$VERSION,} \
97 $(sed 's/\([a-z]\)\([a-zA-Z0-9]*\)/\u\1\2/g' <<< $NAME){,$VERSION}; do
98 LOGFILE=$(find $BASEDIR/log_$TARGET/ -type f -name $j ! -name *_old)
99 [ -n "$LOGFILE" ] && break
100 done
101 if [ -z "$LOGFILE" ]; then
102 dialogerror "No rootfile of \"$i\" in $LOG_DIR."
103 return 1
104 fi
105 echo -n "Copying rootfile from \"$(basename $LOGFILE)\" to $ROOTFILE."
106 cp -f $LOGFILE $ROOTFILE
107 if [ "$?" -eq "0" ]; then
108 beautify message DONE
109 else
110 beautify message FAIL
111 fi
112 ) || break
113 done
114}
115
116rootfiles_findone() {
117 echo $(find $ROOTFILES_DIR -maxdepth 1 -type f ! -name *_changed \
118 ! -name *_no_rootfile -name $1 | head -n 1)
119}
120
121rootfiles_find() {
122 for i in $@; do
123 rootfiles_findone $i
124 done
125}