]> git.sur5r.net Git - kconfig-frontends/blob - scripts/ksync.sh
0e3e9a88745862b1508c73ed0b887b7c7ee4f1ef
[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 # Save current version
19 k_cset_old=$( head -n 1 .version |awk '{ print $(2); }' )
20
21 # Get the kernel version
22 eval $( head -n 5 "${k_dir}/Makefile"                       \
23         |sed -e 's/^/K_/; s/"//g; s/ = \{0,1\}/="/; s/$/"/;'  \
24       )
25 k_cset="$( cd "${k_dir}";                   \
26            git log -n 1 --pretty='format:%H' \
27          )"
28 printf "Found Linux kernel %d.%d.%d%s '%s' (%7.7s)\n"   \
29        "${K_VERSION}" "${K_PATCHLEVEL}" "${K_SUBLEVEL}" \
30        "${K_EXTRAVERSION}" "${K_NAME}" "${k_cset}"
31
32 # Get the kconfig-frontends version
33 kf_version="$( tail -n 1 .version )"
34
35 # Store the new version
36 printf "%d.%d.%d%s %s %s\n%s\n"             \
37        "${K_VERSION}" "${K_PATCHLEVEL}"     \
38        "${K_SUBLEVEL}" "${K_EXTRAVERSION}"  \
39        "${k_cset}" "${K_NAME}"              \
40        "${kf_version}"                      \
41        >.version
42
43 # Sync-up the files
44 k_files=""
45 while read k_file trash kf_file; do
46     k_files="${k_files} ${k_file}"
47     mkdir -p "${kf_file%/*}"
48     cp -v "${k_dir}/${k_file}" "${kf_file}"
49     if [ -f "${kf_file}.patch" ]; then
50         patch --no-backup-if-mismatch -g0 -F1 -p1 -f <"${kf_file}.patch"
51     fi
52 done <scripts/ksync.list
53
54 # Save the changelog between the old cset and now
55 printf "Synced-up these changes:\n"
56 ( cd "${k_dir}"
57   git log --no-merges --pretty='tformat:%h %s'  \
58     "${k_cset_old}..${k_cset}"                  \
59     ${k_files}                                  \
60 )|tac                                           \
61  |tee -a "scripts/ksync.log"                    \
62  |sed -e 's/^/    /;'