[BACK]Return to prepare-import.sh CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / external / bsd / tmux

File: [cvs.NetBSD.org] / src / external / bsd / tmux / prepare-import.sh (download)

Revision 1.5, Sun Apr 23 02:01:59 2017 UTC (3 years, 3 months ago) by christos
Branch: MAIN
CVS Tags: prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, phil-wifi-20190609, phil-wifi, pgoyette-localcount-20170426, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, perseant-stdc-iso10646-base, perseant-stdc-iso10646, netbsd-9-base, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9, netbsd-8-base, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, matt-nb8-mediatek-base, matt-nb8-mediatek, is-mlppp-base, is-mlppp, HEAD
Changes since 1.4: +1 -8 lines

merge conflicts
XXX: Does not work; core-dumps!

#! /bin/sh
# $NetBSD: prepare-import.sh,v 1.5 2017/04/23 02:01:59 christos Exp $
# Use this script to recreate the 'dist' subdirectory from a newly released
# distfile.  The script takes care of unpacking the distfile, removing any
# files that are not relevant to NetBSD and checking if there are any new
# files in the new release that need to be addressed.
# See the README file for general instructions.

set -e


err() {
	echo "${ProgName}:" "${@}" 1>&2
	exit 1

log() {
	echo "${ProgName}:" "${@}"

backup_dist() {
	if [ -d dist.old ]; then
		log "Removing dist; dist.old exists"
		rm -rf dist
		log "Backing up dist as dist.old"
		mv dist dist.old

extract_distfile() {
	local distfile="${1}"; shift
	local distname="${1}"; shift

	log "Extracting ${distfile}"
	tar -xzf "${distfile}"
	[ -d "${distname}" ] || err "Distfile did not create ${distname}"
	log "Renaming ${distname} to dist"
	mv "${distname}" dist

get_distname() {
	local distfile="${1}"; shift
	basename "${distfile}" | sed -e 's,\.tar.*,,'

cleanup_dist() {
	log "Removing unnecessary files from dist"
	find dist -name .deps -exec rm -fr {} +
	find dist -name .dirstamp -exec rm -f {} +

diff_dirs() {
	local old_dir="${1}"; shift
	local new_dir="${1}"; shift

	local old_list=$(mktemp -t tmux-import.XXXXXX)
	local new_list=$(mktemp -t tmux-import.XXXXXX)
	local diff=$(mktemp -t tmux-import.XXXXXX)
	trap "rm -f '${old_list}' '${new_list}' '${diff}'; exit 1" \

	( cd "${old_dir}" && find . | sort >>"${old_list}" )
	( cd "${new_dir}" && find . | sort >>"${new_list}" )

	diff -u "${old_list}" "${new_list}" | grep '^+\.' >>"${diff}" || true
	if [ -s "${diff}" ]; then
		log "New files found"
		diff -u "${old_list}" "${new_list}" | grep '^+\.'
		log "Check if any files have to be cleaned up and update" \
		    "the prepare-import.sh script accordingly"
		log "No new files; all good!"

	rm -f "${old_list}" "${new_list}" "${diff}"

main() {
	[ ${#} -eq 1 ] || err "Must provide a distfile name"
	local distfile="${1}"; shift

	[ -f Makefile -a -f prepare-import.sh ] || \
	    err "Must be run from the src/external/bsd/tmux subdirectory"

	local distname="$(get_distname ${distfile})"

	extract_distfile "${distfile}" "${distname}"
	diff_dirs dist.old dist
	cleantags dist
	log "Don't forget to update the -D flags in usr.bin/tmux/Makefile" \
	    "and to update the version in doc/3RDPARTY"

main "${@}"