~ubuntu-branches/ubuntu/hardy/linux-backports-modules-2.6.24/hardy-security

« back to all changes in this revision

Viewing changes to updates/wireless/iwlwifi/mac80211/scripts/generate_modified

  • Committer: Bazaar Package Importer
  • Author(s): , Ben Collins
  • Date: 2008-04-02 06:59:04 UTC
  • Revision ID: james.westby@ubuntu.com-20080402065904-e5knh2gn2hms3xbb
Tags: 2.6.24-14.11
[Ben Collins]

* iwlwifi: Update to iwlwifi-1.2.25 and mac80211-10.0.4
  - LP: #200950
* ubuntu: Slight cleanups to module hiearchy and Makefiles
* mac80211: Enable LED triggers
* iwlwifi: Add LED trigger support (rx and tx only)
  - LP: #176090

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env /bin/bash
 
2
script=generate_modified
 
3
prog=$0
 
4
[ "${prog/*$script/$script}" = "$script" ] || {
 
5
    echo "This script must not be sourced."
 
6
    return 1
 
7
} || return 1
 
8
 
 
9
DEBUG=1
 
10
 
 
11
function die() {
 
12
        ret=$1
 
13
        shift
 
14
        echo -e $@ >&2
 
15
        (( DEBUG )) && 
 
16
                echo "If patch or script failed, check pre/ and post/ for current stage." ||
 
17
                echo "Try setting DEBUG=1 to maintain pre/ and post/ staging."
 
18
        exit $ret
 
19
}
 
20
 
 
21
SRC=origin
 
22
DST=modified
 
23
 
 
24
[ -d $SRC ]  ||
 
25
die 5 "\n$SRC/ tree does not exist.  Run 'make $SRC' to build the\n$SRC directory."
 
26
 
 
27
SRC=${SRC/%\/}/
 
28
DST=${DST/%\/}/
 
29
 
 
30
[ ! -e $DST ] || {
 
31
    die 1 "$DST already exists.  You must remove it before continuing."
 
32
}
 
33
 
 
34
echo "Building modified version in '$DST' directory:"
 
35
 
 
36
mkdir $DST
 
37
echo -n "Copying $DST from $SRC..."
 
38
cp -r ${SRC}* $DST || die $? "Copy failed."
 
39
echo "done"
 
40
 
 
41
(( DEBUG != 0 )) && rsync --delete -aprl $DST post/ > /dev/null
 
42
 
 
43
function do_patch {
 
44
    [ -e "$2" ] ||
 
45
    die 3 "$2 does not exist.  Terminating."
 
46
    echo -ne " + Applying: $2\n\t"
 
47
    cat "$2" | while read command rest; do
 
48
        case $command in
 
49
            "Commit:" | "Author:" | "")
 
50
                ;;
 
51
            *) echo "$command $rest"
 
52
                break
 
53
                ;;
 
54
        esac
 
55
    done
 
56
 
 
57
    patch -p1 -d $1 < "$2" > .patch.output || {
 
58
        echo "-----patch failure output-----"
 
59
        cat .patch.output
 
60
        echo ""
 
61
        die 1 "$2 failed.  Terminating."
 
62
    } 
 
63
    [ -e .patch.output ] && rm .patch.output
 
64
    return 0
 
65
}
 
66
 
 
67
function do_script {
 
68
    [ -x "$2" ] ||
 
69
    die 3 "$2 does not exist.  Terminating."
 
70
    echo -ne " + Running: $2\n\t"
 
71
    head -n 2 "$2" | tail -n 1 | sed -e 's,^#[[:space:]]*,,g' || 
 
72
    die $? "Terminating."
 
73
 
 
74
    $2 $1 || die 1 "$2 failed."
 
75
 
 
76
    return 0
 
77
}
 
78
 
 
79
echo "Applying patches and scripts from pending/."
 
80
for i in pending/*; do 
 
81
        [ -d $i ] && continue
 
82
    [ ! -e $i ] && break
 
83
    file=${i/%.patch/}.patch
 
84
    [ "$file" == "$i" ] && {
 
85
        (( DEBUG != 0 )) && {
 
86
                [ -d pre ] && rm -rf pre
 
87
                rsync --delete -aprl --exclude "*.orig" --exclude "*.rej" post/ pre/ 
 
88
                do_patch post/ $file
 
89
                continue
 
90
        } 
 
91
        do_patch $DST $file || die 3 "Patch failed."
 
92
        continue
 
93
    }
 
94
 
 
95
    file=${i/%.sh/}.sh
 
96
    [ "$file" == "$i" ] && [ -x "$i" ] && {
 
97
        (( DEBUG != 0 )) && {
 
98
                [ -d pre ] && rm -rf pre
 
99
                rsync --delete -aprl --exclude "*.orig" --exclude "*.rej" post/ pre/ 
 
100
                do_script post/ $file
 
101
                continue
 
102
        } 
 
103
        do_script $DST $file
 
104
        continue
 
105
    }
 
106
    echo " ! Skipping $i..."
 
107
done
 
108
 
 
109
(( DEBUG )) || exit 0
 
110
 
 
111
rsync --delete -avprl post/ $DST > /dev/null && 
 
112
rm -rf pre/ post/