2 # $NetBSD: prepare-import.sh,v 1.1 2013/02/25 00:20:08 jmmv Exp $
4 # Use this script to recreate the 'dist' subdirectory from a newly released
5 # distfile. The script takes care of unpacking the distfile, removing any
6 # files that are not relevant to NetBSD and checking if there are any new
7 # files in the new release that need to be addressed.
15 CLEAN_PATTERNS
="${CLEAN_PATTERNS} *.m4"
16 CLEAN_PATTERNS
="${CLEAN_PATTERNS} INSTALL TODO"
17 CLEAN_PATTERNS
="${CLEAN_PATTERNS} Makefile*"
18 CLEAN_PATTERNS
="${CLEAN_PATTERNS} admin"
19 CLEAN_PATTERNS
="${CLEAN_PATTERNS} configure*"
22 echo "${ProgName}:" "${@}" 1>&2
27 echo "${ProgName}:" "${@}"
31 if [ -d dist.old
]; then
32 log
"Removing dist; dist.old exists"
35 log
"Backing up dist as dist.old"
41 local distfile
="${1}"; shift
42 local distname
="${1}"; shift
44 log
"Extracting ${distfile}"
45 tar -xzf "${distfile}"
46 [ -d "${distname}" ] || err
"Distfile did not create ${distname}"
47 log
"Renaming ${distname} to dist"
52 local distfile
="${1}"; shift
53 basename "${distfile}" |
sed -e 's,\.tar.*,,'
57 log
"Removing unnecessary files from dist"
58 ( cd dist
&& rm -rf ${CLEAN_PATTERNS} )
62 local old_dir
="${1}"; shift
63 local new_dir
="${1}"; shift
65 local old_list
=$
(mktemp
-t kyua-atf-compat-import.XXXXXX
)
66 local new_list
=$
(mktemp
-t kyua-atf-compat-import.XXXXXX
)
67 local diff=$
(mktemp
-t kyua-atf-compat-import.XXXXXX
)
68 trap "rm -f '${old_list}' '${new_list}' '${diff}'; exit 1" \
71 ( cd "${old_dir}" && find . |
sort >>"${old_list}" )
72 ( cd "${new_dir}" && find . |
sort >>"${new_list}" )
74 diff -u "${old_list}" "${new_list}" | grep '^+\.' >>"${diff}" || true
75 if [ -s "${diff}" ]; then
77 diff -u "${old_list}" "${new_list}" |
grep '^+\.'
78 log
"Check if any files have to be cleaned up and update" \
79 "the prepare-import.sh script accordingly"
81 log
"No new files; all good!"
84 rm -f "${old_list}" "${new_list}" "${diff}"
88 [ ${#} -eq 1 ] || err
"Must provide a distfile name"
89 local distfile
="${1}"; shift
91 [ -f Makefile
-a -f prepare-import.sh
] || \
92 err
"Must be run from the src/external/bsd/kyua-atf-compat" \
95 local distname
="$(get_distname ${distfile})"
98 extract_distfile
"${distfile}" "${distname}"
100 diff_dirs dist.old dist