2 # $NetBSD: prepare-import.sh,v 1.6 2012/01/16 22:42:40 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* */Makefile* */*/Makefile*"
18 CLEAN_PATTERNS
="${CLEAN_PATTERNS} admin"
19 CLEAN_PATTERNS
="${CLEAN_PATTERNS} atf-*/atf-*.m4"
20 CLEAN_PATTERNS
="${CLEAN_PATTERNS} bconfig.h.in"
21 CLEAN_PATTERNS
="${CLEAN_PATTERNS} bootstrap"
22 CLEAN_PATTERNS
="${CLEAN_PATTERNS} configure*"
23 CLEAN_PATTERNS
="${CLEAN_PATTERNS} m4"
26 echo "${ProgName}:" "${@}" 1>&2
31 echo "${ProgName}:" "${@}"
35 if [ -d dist.old
]; then
36 log
"Removing dist; dist.old exists"
39 log
"Backing up dist as dist.old"
45 local distfile
="${1}"; shift
46 local distname
="${1}"; shift
48 log
"Extracting ${distfile}"
49 tar -xzf "${distfile}"
50 [ -d "${distname}" ] || err
"Distfile did not create ${distname}"
51 log
"Renaming ${distname} to dist"
56 local distfile
="${1}"; shift
57 basename "${distfile}" |
sed -e 's,\.tar.*,,'
61 log
"Removing unnecessary files from dist"
62 ( cd dist
&& rm -rf ${CLEAN_PATTERNS} )
66 local old_dir
="${1}"; shift
67 local new_dir
="${1}"; shift
69 local old_list
=$
(mktemp
-t atf-import.XXXXXX
)
70 local new_list
=$
(mktemp
-t atf-import.XXXXXX
)
71 local diff=$
(mktemp
-t atf-import.XXXXXX
)
72 trap "rm -f '${old_list}' '${new_list}' '${diff}'; exit 1" \
75 ( cd "${old_dir}" && find . |
sort >>"${old_list}" )
76 ( cd "${new_dir}" && find . |
sort >>"${new_list}" )
78 diff -u "${old_list}" "${new_list}" | grep '^+\.' >>"${diff}" || true
79 if [ -s "${diff}" ]; then
81 diff -u "${old_list}" "${new_list}" |
grep '^+\.'
82 log
"Check if any files have to be cleaned up and update" \
83 "the prepare-import.sh script accordingly"
85 log
"No new files; all good!"
88 rm -f "${old_list}" "${new_list}" "${diff}"
92 [ ${#} -eq 1 ] || err
"Must provide a distfile name"
93 local distfile
="${1}"; shift
95 [ -f Makefile
-a -f prepare-import.sh
] || \
96 err
"Must be run from the src/external/bsd/atf subdirectory"
98 local distname
="$(get_distname ${distfile})"
101 extract_distfile
"${distfile}" "${distname}"
103 diff_dirs dist.old dist