android-raptor – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | #! /bin/sh |
2 | # |
||
3 | # opkg config checker and upgrade script |
||
4 | # |
||
5 | # Copyright (C) 2014 Paul Barker |
||
6 | # |
||
7 | # This program is free software; you can redistribute it and/or modify it |
||
8 | # under the terms of the GNU General Public License as published by the |
||
9 | # Free Software Foundation; either version 2, or (at your option) any |
||
10 | # later version. |
||
11 | # |
||
12 | # This program is distributed in the hope that it will be useful, but |
||
13 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
||
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||
15 | # General Public License for more details. |
||
16 | |||
17 | set -e |
||
18 | |||
19 | if [ "$#" -eq 2 ]; then |
||
20 | file_in=$1 |
||
21 | file_out=$2 |
||
22 | inplace=0 |
||
23 | elif [ "$#" -eq 1 ]; then |
||
24 | file_in=$1 |
||
25 | file_out=`mktemp` |
||
26 | inplace=1 |
||
27 | else |
||
28 | cat 1>&2 << EOF |
||
29 | Usage: $0 <file_in> <file_out> |
||
30 | |||
31 | The script reads an opkg config file specified by <file_in> and performs |
||
32 | sanity checks. It may automatically fix some errors, especially those where the |
||
33 | config syntax or option names have changed during an opkg upgrade. The fixed |
||
34 | file will be written to <file_out> if this argument is given, otherwise |
||
35 | <file_in> will be fixed in place. Warning and error messages will be printed to |
||
36 | stderr. |
||
37 | EOF |
||
38 | exit 1 |
||
39 | fi |
||
40 | |||
41 | # v0.2.x to v0.3.0 upgrade: lists_dir syntax has changed |
||
42 | # |
||
43 | # The old lists_dir statement had the syntax 'lists_dir ext path' where 'ext' |
||
44 | # was ignored. The new syntax is 'option lists_dir path'. |
||
45 | awk_lists_dir='$1 == "lists_dir" { print "option lists_dir " $3 ; \ |
||
46 | print "Fixed: " $0 " -> option lists_dir " $3 > "/dev/stderr" ; \ |
||
47 | next }' |
||
48 | |||
49 | # Combine scripts and add terminating '1' statement which will print all |
||
50 | # unmatched lines (assuming each match finishes with 'next'). |
||
51 | awk_script="$awk_lists_dir 1" |
||
52 | |||
53 | # Run awk_script |
||
54 | awk "$awk_script" < $file_in > $file_out |
||
55 | |||
56 | if [ "$inplace" -eq 1 ]; then |
||
57 | mv $file_out $file_in |
||
58 | fi |