Remove building with NOCRYPTO option
[minix.git] / external / bsd / kyua-atf-compat / prepare-import.sh
blob2462b8f8fb011a8f5d20bd27197c787d0a7bfdf5
1 #!/bin/sh
2 # $NetBSD: prepare-import.sh,v 1.1 2013/02/25 00:20:08 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*"
18 CLEAN_PATTERNS="${CLEAN_PATTERNS} admin"
19 CLEAN_PATTERNS="${CLEAN_PATTERNS} configure*"
21 err() {
22 echo "${ProgName}:" "${@}" 1>&2
23 exit 1
26 log() {
27 echo "${ProgName}:" "${@}"
30 backup_dist() {
31 if [ -d dist.old ]; then
32 log "Removing dist; dist.old exists"
33 rm -rf dist
34 else
35 log "Backing up dist as dist.old"
36 mv dist dist.old
40 extract_distfile() {
41 local distfile="${1}"; shift
42 local distname="${1}"; shift
44 log "Extracting ${distfile}"
45 tar -xzf "${distfile}"
46 [ -d "${distname}" ] || err "Distfile did not create ${distname}"
47 log "Renaming ${distname} to dist"
48 mv "${distname}" dist
51 get_distname() {
52 local distfile="${1}"; shift
53 basename "${distfile}" | sed -e 's,\.tar.*,,'
56 cleanup_dist() {
57 log "Removing unnecessary files from dist"
58 ( cd dist && rm -rf ${CLEAN_PATTERNS} )
61 diff_dirs() {
62 local old_dir="${1}"; shift
63 local new_dir="${1}"; shift
65 local old_list=$(mktemp -t kyua-atf-compat-import.XXXXXX)
66 local new_list=$(mktemp -t kyua-atf-compat-import.XXXXXX)
67 local diff=$(mktemp -t kyua-atf-compat-import.XXXXXX)
68 trap "rm -f '${old_list}' '${new_list}' '${diff}'; exit 1" \
69 HUP INT QUIT TERM
71 ( cd "${old_dir}" && find . | sort >>"${old_list}" )
72 ( cd "${new_dir}" && find . | sort >>"${new_list}" )
74 diff -u "${old_list}" "${new_list}" | grep '^+\.' >>"${diff}" || true
75 if [ -s "${diff}" ]; then
76 log "New files found"
77 diff -u "${old_list}" "${new_list}" | grep '^+\.'
78 log "Check if any files have to be cleaned up and update" \
79 "the prepare-import.sh script accordingly"
80 else
81 log "No new files; all good!"
84 rm -f "${old_list}" "${new_list}" "${diff}"
87 main() {
88 [ ${#} -eq 1 ] || err "Must provide a distfile name"
89 local distfile="${1}"; shift
91 [ -f Makefile -a -f prepare-import.sh ] || \
92 err "Must be run from the src/external/bsd/kyua-atf-compat" \
93 "subdirectory"
95 local distname="$(get_distname ${distfile})"
97 backup_dist
98 extract_distfile "${distfile}" "${distname}"
99 cleanup_dist
100 diff_dirs dist.old dist
103 main "${@}"