summaryrefslogtreecommitdiff
path: root/scripts/refresh-compat
blob: 6846d3e9e65dfe0469c983fa758d01ad2a8edb10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
#
# Copyright 2012    Luis R. Rodriguez <mcgrof@frijolero.org>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

# The purpose of this script is to enable developers use compat-drivers
# backport work without having to carry code on their tree. This lets
# developers synch to newer compat-drivers releases to gain more backport
# work. If you use this throw the files into your .gitignore:
#
# compat/
# udev/
# include/
# scripts/
# .compat_base_tree
# .compat_base_tree_version
# .compat_version
# config.mk
#
# An example git tree for standalone development will be provided later.
# Once run you can then just run on your standalone development tree:
#
# ./refresh-compat
#
# This is a copy of refresh-compat-local that we maintain here
# You can keep that in your git tree as otherwise its hard for users to
# know what to run.

# Pretty colors
GREEN="\033[01;32m"
YELLOW="\033[01;33m"
NORMAL="\033[00m"
BLUE="\033[34m"
RED="\033[31m"
PURPLE="\033[35m"
CYAN="\033[36m"
UNDERLINE="\033[02m"

COMPAT_SRC="$HOME/devel/compat-drivers/"
EXTRA_COPY=""

if [[ -f .compat_copy ]]; then
	source .compat_copy
fi

COPY=""
COPY="$COPY compat/"
COPY="$COPY include/"
COPY="$COPY udev/"
COPY="$COPY scripts/check_config.sh"
COPY="$COPY scripts/check_depmod"
COPY="$COPY scripts/compress_modules"
COPY="$COPY scripts/gen-compat-autoconf.sh"
COPY="$COPY scripts/modlib.sh"
COPY="$COPY scripts/update-initramfs"
COPY="$COPY scripts/skip-colors"
COPY="$COPY .compat_base"
COPY="$COPY .compat_base_tree"
COPY="$COPY .compat_base_tree_version"
COPY="$COPY .compat_version"
COPY="$COPY config.mk"
COPY="$COPY $EXTRA_COPY"

REFRESH_LOCAL="scripts/refresh-compat-local"
REFRESH_TARGET="refresh-compat"

WORK_DIR="$(pwd)"
cd ${COMPAT_SRC}
# Only copy the base files
./scripts/admin-update.sh -b
cd ${WORK_DIR}

for i in $COPY ; do
	if [[ -d ${COMPAT_SRC}${i} ]]; then
		echo -e "Copying ${BLUE}${i}${NORMAL} ..."
		cp -a ${COMPAT_SRC}/$i .
		continue
	fi
	if [[ -f ${COMPAT_SRC}${i} ]]; then
		DIR=$(dirname $i)
		if [[ ! -d $DIR ]]; then
			mkdir -p $DIR
		fi

		if [[ -x ${COMPAT_SRC}${i} ]]; then
			echo -e "Copying ${GREEN}${i}${NORMAL} ..."
		else
			echo -e "Copying ${i}${NORMAL} ..."
		fi

		cp -f ${COMPAT_SRC}/${i} $i
		continue
	fi
done

rm -f include/linux/compat_autoconfig.h
rm -f .config

cp -f ${COMPAT_SRC}/${REFRESH_LOCAL} ${REFRESH_TARGET}

if [[ ! -f .compat_base_tree_version ]]; then
	echo -e "Failed at copying files over..."
	exit 1
fi

echo
echo -e "Synched with ${CYAN}$(cat .compat_version)${NORMAL}"