2 # $NetBSD: prepare-import.sh,v 1.8 2014/02/11 16:11:28 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} Atffile */Atffile */*/Atffile"
18 CLEAN_PATTERNS
="${CLEAN_PATTERNS} Makefile* */Makefile* */*/Makefile*"
19 CLEAN_PATTERNS
="${CLEAN_PATTERNS} admin"
20 CLEAN_PATTERNS
="${CLEAN_PATTERNS} atf-*/atf-*.m4"
21 CLEAN_PATTERNS
="${CLEAN_PATTERNS} bconfig.h.in"
22 CLEAN_PATTERNS
="${CLEAN_PATTERNS} bootstrap"
23 CLEAN_PATTERNS
="${CLEAN_PATTERNS} configure*"
24 CLEAN_PATTERNS
="${CLEAN_PATTERNS} m4"
25 CLEAN_PATTERNS
="${CLEAN_PATTERNS} tools/generate-revision.sh"
28 echo "${ProgName}:" "${@}" 1>&2
33 echo "${ProgName}:" "${@}"
37 if [ -d dist.old
]; then
38 log
"Removing dist; dist.old exists"
41 log
"Backing up dist as dist.old"
47 local distfile
="${1}"; shift
48 local distname
="${1}"; shift
50 log
"Extracting ${distfile}"
51 tar -xzf "${distfile}"
52 [ -d "${distname}" ] || err
"Distfile did not create ${distname}"
53 log
"Renaming ${distname} to dist"
58 local distfile
="${1}"; shift
59 basename "${distfile}" |
sed -e 's,\.tar.*,,'
63 log
"Removing unnecessary files from dist"
64 ( cd dist
&& rm -rf ${CLEAN_PATTERNS} )
68 local old_dir
="${1}"; shift
69 local new_dir
="${1}"; shift
71 local tmpdir
="$(mktemp -d -t atf-import)"
72 trap "rm -rf '${tmpdir}'; exit 1" HUP INT QUIT TERM
74 local old_list
="${tmpdir}/old-list.txt"
75 ( cd "${old_dir}" && find .
-type f |
sort >>"${old_list}" )
76 local new_list
="${tmpdir}/new-list.txt"
77 ( cd "${new_dir}" && find .
-type f |
sort >>"${new_list}" )
79 local added
="${tmpdir}/added.txt"
80 comm -13 "${old_list}" "${new_list}" >"${added}"
81 local removed
="${tmpdir}/removed.txt"
82 comm -23 "${old_list}" "${new_list}" | grep -v '/CVS' >"${removed}"
83 if [ -s "${removed}" ]; then
84 log
"Removed files found"
87 if [ -s "${added}" ]; then
90 log
"Check if any files have to be cleaned up and update" \
91 "the prepare-import.sh script accordingly"
98 [ ${#} -eq 1 ] || err
"Must provide a distfile name"
99 local distfile
="${1}"; shift
101 [ -f Makefile
-a -f prepare-import.sh
] || \
102 err
"Must be run from the src/external/bsd/atf subdirectory"
104 local distname
="$(get_distname ${distfile})"
107 extract_distfile
"${distfile}" "${distname}"
109 diff_dirs dist.old dist