tools/llvm: Do not build with symbols
[minix3.git] / external / bsd / atf / prepare-import.sh
blob37ea0fce2f7932e1850400920b0df5d55cf8396b
1 #!/bin/sh
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.
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} 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"
25 err() {
26 echo "${ProgName}:" "${@}" 1>&2
27 exit 1
30 log() {
31 echo "${ProgName}:" "${@}"
34 backup_dist() {
35 if [ -d dist.old ]; then
36 log "Removing dist; dist.old exists"
37 rm -rf dist
38 else
39 log "Backing up dist as dist.old"
40 mv dist dist.old
44 extract_distfile() {
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"
52 mv "${distname}" dist
55 get_distname() {
56 local distfile="${1}"; shift
57 basename "${distfile}" | sed -e 's,\.tar.*,,'
60 cleanup_dist() {
61 log "Removing unnecessary files from dist"
62 ( cd dist && rm -rf ${CLEAN_PATTERNS} )
65 diff_dirs() {
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" \
73 HUP INT QUIT TERM
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
80 log "New files found"
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"
84 else
85 log "No new files; all good!"
88 rm -f "${old_list}" "${new_list}" "${diff}"
91 main() {
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})"
100 backup_dist
101 extract_distfile "${distfile}" "${distname}"
102 cleanup_dist
103 diff_dirs dist.old dist
106 main "${@}"