2 # $NetBSD: prepare-import.sh,v 1.1 2013/02/23 14:16:49 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} Doxyfile*"
18 CLEAN_PATTERNS
="${CLEAN_PATTERNS} Makefile* */Makefile* */*/Makefile*"
19 CLEAN_PATTERNS
="${CLEAN_PATTERNS} admin"
20 CLEAN_PATTERNS
="${CLEAN_PATTERNS} api-docs"
21 CLEAN_PATTERNS
="${CLEAN_PATTERNS} config.h.in"
22 CLEAN_PATTERNS
="${CLEAN_PATTERNS} configure*"
23 CLEAN_PATTERNS
="${CLEAN_PATTERNS} m4"
24 CLEAN_PATTERNS
="${CLEAN_PATTERNS} utils/defs.hpp"
27 echo "${ProgName}:" "${@}" 1>&2
32 echo "${ProgName}:" "${@}"
36 if [ -d dist.old
]; then
37 log
"Removing dist; dist.old exists"
40 log
"Backing up dist as dist.old"
46 local distfile
="${1}"; shift
47 local distname
="${1}"; shift
49 log
"Extracting ${distfile}"
50 tar -xzf "${distfile}"
51 [ -d "${distname}" ] || err
"Distfile did not create ${distname}"
52 log
"Renaming ${distname} to dist"
57 local distfile
="${1}"; shift
58 basename "${distfile}" |
sed -e 's,\.tar.*,,'
62 log
"Removing unnecessary files from dist"
63 ( cd dist
&& rm -rf ${CLEAN_PATTERNS} )
67 local old_dir
="${1}"; shift
68 local new_dir
="${1}"; shift
70 local old_list
=$
(mktemp
-t kyua-cli-import.XXXXXX
)
71 local new_list
=$
(mktemp
-t kyua-cli-import.XXXXXX
)
72 local diff=$
(mktemp
-t kyua-cli-import.XXXXXX
)
73 trap "rm -f '${old_list}' '${new_list}' '${diff}'; exit 1" \
76 ( cd "${old_dir}" && find . |
sort >>"${old_list}" )
77 ( cd "${new_dir}" && find . |
sort >>"${new_list}" )
79 diff -u "${old_list}" "${new_list}" | grep '^+\.' >>"${diff}" || true
80 if [ -s "${diff}" ]; then
82 diff -u "${old_list}" "${new_list}" |
grep '^+\.'
83 log
"Check if any files have to be cleaned up and update" \
84 "the prepare-import.sh script accordingly"
86 log
"No new files; all good!"
89 rm -f "${old_list}" "${new_list}" "${diff}"
93 [ ${#} -eq 1 ] || err
"Must provide a distfile name"
94 local distfile
="${1}"; shift
96 [ -f Makefile
-a -f prepare-import.sh
] || \
97 err
"Must be run from the src/external/bsd/kyua-cli subdirectory"
99 local distname
="$(get_distname ${distfile})"
102 extract_distfile
"${distfile}" "${distname}"
104 diff_dirs dist.old dist