]> git.sur5r.net Git - kconfig-frontends/blob - scripts/ksync.sh
ksync: move to scripts/
[kconfig-frontends] / scripts / ksync.sh
1 #!/bin/sh
2
3 my_name="${0##*/}"
4
5 # If an argument is given, it's the location
6 # of the Linux kernel source tree
7 k_dir="${1}"
8 if [ ! \( -n "${k_dir}" -a -d "${k_dir}/kernel" \) ]; then
9     if [ -n "${k_dir}" ]; then
10         printf "%s: \`%s': not a Linux kernel source tree\n"    \
11                "${my_name}" "${k_dir}"
12     else
13         printf "Usage: %s /path/to/kernel/dir\n" "${my_name}"
14     fi
15     exit 1
16 fi
17
18 # Get the kernel version
19 eval $( head -n 5 "${k_dir}/Makefile"                       \
20         |sed -r -e 's/^/K_/; s/"//g; s/ = ?/="/; s/$/"/;'   \
21       )
22 k_cset="$( cd "${k_dir}";                   \
23            git log -n 1 --pretty='format:%H' \
24          )"
25 printf "Found Linux kernel %d.%d.%d%s '%s' (%7.7s)\n"   \
26        "${K_VERSION}" "${K_PATCHLEVEL}" "${K_SUBLEVEL}" \
27        "${K_EXTRAVERSION}" "${K_NAME}" "${k_cset}"
28
29 # Get the kconfig-frontends version
30 kf_version="$( tail -n 1 .version )"
31
32 # Store the new version
33 printf "%d.%d.%d%s %s %s\n%s\n"             \
34        "${K_VERSION}" "${K_PATCHLEVEL}"     \
35        "${K_SUBLEVEL}" "${K_EXTRAVERSION}"  \
36        "${k_cset}" "${K_NAME}"              \
37        "${kf_version}"                      \
38        >.version
39
40 exec <misc/kernel2kfrontends.list
41 while read k_file trash kf_file; do
42     cp -v "${k_dir}/${k_file}" "${kf_file}"
43     if [ -f "${kf_file}.patch" ]; then
44         patch --no-backup-if-mismatch -g0 -F1 -p1 -f <"${kf_file}.patch"
45     fi
46 done