Drop main() prototype. Syncs with NetBSD-8
[minix.git] / external / bsd / tmux / prepare-import.sh
blob1785b5bf8776eae532d0b869beaa1482e475a5d7
1 #! /bin/sh
2 # $NetBSD: prepare-import.sh,v 1.4 2014/07/24 15:16:26 christos 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.
9 # See the README file for general instructions.
12 set -e
14 ProgName=${0##*/}
16 CLEAN_PATTERNS=
17 CLEAN_PATTERNS="${CLEAN_PATTERNS} [A-Z]*"
18 CLEAN_PATTERNS="${CLEAN_PATTERNS} aclocal.m4"
19 CLEAN_PATTERNS="${CLEAN_PATTERNS} etc"
20 CLEAN_PATTERNS="${CLEAN_PATTERNS} configure*"
22 err() {
23 echo "${ProgName}:" "${@}" 1>&2
24 exit 1
27 log() {
28 echo "${ProgName}:" "${@}"
31 backup_dist() {
32 if [ -d dist.old ]; then
33 log "Removing dist; dist.old exists"
34 rm -rf dist
35 else
36 log "Backing up dist as dist.old"
37 mv dist dist.old
41 extract_distfile() {
42 local distfile="${1}"; shift
43 local distname="${1}"; shift
45 log "Extracting ${distfile}"
46 tar -xzf "${distfile}"
47 [ -d "${distname}" ] || err "Distfile did not create ${distname}"
48 log "Renaming ${distname} to dist"
49 mv "${distname}" dist
52 get_distname() {
53 local distfile="${1}"; shift
54 basename "${distfile}" | sed -e 's,\.tar.*,,'
57 cleanup_dist() {
58 log "Removing unnecessary files from dist"
59 ( cd dist && rm -rf ${CLEAN_PATTERNS} )
60 find dist -name .deps -exec rm -fr {} +
61 find dist -name .dirstamp -exec rm -f {} +
64 diff_dirs() {
65 local old_dir="${1}"; shift
66 local new_dir="${1}"; shift
68 local old_list=$(mktemp -t tmux-import.XXXXXX)
69 local new_list=$(mktemp -t tmux-import.XXXXXX)
70 local diff=$(mktemp -t tmux-import.XXXXXX)
71 trap "rm -f '${old_list}' '${new_list}' '${diff}'; exit 1" \
72 HUP INT QUIT TERM
74 ( cd "${old_dir}" && find . | sort >>"${old_list}" )
75 ( cd "${new_dir}" && find . | sort >>"${new_list}" )
77 diff -u "${old_list}" "${new_list}" | grep '^+\.' >>"${diff}" || true
78 if [ -s "${diff}" ]; then
79 log "New files found"
80 diff -u "${old_list}" "${new_list}" | grep '^+\.'
81 log "Check if any files have to be cleaned up and update" \
82 "the prepare-import.sh script accordingly"
83 else
84 log "No new files; all good!"
87 rm -f "${old_list}" "${new_list}" "${diff}"
90 main() {
91 [ ${#} -eq 1 ] || err "Must provide a distfile name"
92 local distfile="${1}"; shift
94 [ -f Makefile -a -f prepare-import.sh ] || \
95 err "Must be run from the src/external/bsd/tmux subdirectory"
97 local distname="$(get_distname ${distfile})"
99 backup_dist
100 extract_distfile "${distfile}" "${distname}"
101 cleanup_dist
102 diff_dirs dist.old dist
103 cleantags dist
104 log "Don't forget to update the -D flags in usr.bin/tmux/Makefile" \
105 "and to update the version in doc/3RDPARTY"
108 main "${@}"