Remove building with NOCRYPTO option
[minix3.git] / external / bsd / atf / prepare-import.sh
bloba17abd6339bd294f51316d1cbc56d5736719e469
1 #!/bin/sh
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.
10 set -e
12 ProgName=${0##*/}
14 CLEAN_PATTERNS=
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"
27 err() {
28 echo "${ProgName}:" "${@}" 1>&2
29 exit 1
32 log() {
33 echo "${ProgName}:" "${@}"
36 backup_dist() {
37 if [ -d dist.old ]; then
38 log "Removing dist; dist.old exists"
39 rm -rf dist
40 else
41 log "Backing up dist as dist.old"
42 mv dist dist.old
46 extract_distfile() {
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"
54 mv "${distname}" dist
57 get_distname() {
58 local distfile="${1}"; shift
59 basename "${distfile}" | sed -e 's,\.tar.*,,'
62 cleanup_dist() {
63 log "Removing unnecessary files from dist"
64 ( cd dist && rm -rf ${CLEAN_PATTERNS} )
67 diff_dirs() {
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"
85 cat "${removed}"
87 if [ -s "${added}" ]; then
88 log "New files found"
89 cat "${added}"
90 log "Check if any files have to be cleaned up and update" \
91 "the prepare-import.sh script accordingly"
94 rm -rf "${tmpdir}"
97 main() {
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})"
106 backup_dist
107 extract_distfile "${distfile}" "${distname}"
108 cleanup_dist
109 diff_dirs dist.old dist
112 main "${@}"