1#!/bin/sh 2# $FreeBSD$ 3# 4# Usage: cd /usr/src/contrib/jemalloc 5# ./FREEBSD-upgrade <command> [args] 6# 7# At least the following ports are required when importing jemalloc: 8# - devel/autoconf 9# - devel/git 10# - devel/gmake 11# - textproc/docbook-xsl 12# - textproc/libxslt 13# 14# The normal workflow for importing a new release is: 15# 16# cd /usr/src/contrib/jemalloc 17# 18# Merge local changes that were made since the previous import: 19# 20# ./FREEBSD-upgrade merge-changes 21# ./FREEBSD-upgrade rediff 22# 23# Extract latest jemalloc release. 24# 25# ./FREEBSD-upgrade extract 26# 27# Fix patch conflicts as necessary, then regenerate diffs to update line 28# offsets: 29# 30# ./FREEBSD-upgrade rediff 31# ./FREEBSD-upgrade extract 32# 33# Do multiple buildworld/installworld rounds. If problems arise and patches 34# are needed, edit the code in ${work} as necessary, then: 35# 36# ./FREEBSD-upgrade rediff 37# ./FREEBSD-upgrade extract 38# 39# The rediff/extract order is important because rediff saves the local 40# changes, then extract blows away the work tree and re-creates it with the 41# diffs applied. 42# 43# Finally, to clean up: 44# 45# ./FREEBSD-upgrade clean 46 47set -e 48 49if [ ! -x "FREEBSD-upgrade" ] ; then 50 echo "Run from within src/contrib/jemalloc/" >&2 51 exit 1 52fi 53 54src=`pwd` 55workname="jemalloc.git" 56work="${src}/../${workname}" # merge-changes expects ${workname} in "..". 57changes="${src}/FREEBSD-changes" 58 59do_extract() { 60 local rev=$1 61 # Clone. 62 rm -rf ${work} 63 git clone https://github.com/jemalloc/jemalloc.git ${work} 64 ( 65 cd ${work} 66 if [ "x${rev}" != "x" ] ; then 67 # Use optional rev argument to check out a revision other than HEAD on 68 # master. 69 git checkout ${rev} 70 fi 71 # Apply diffs before generating files. 72 patch -p1 < "${src}/FREEBSD-diffs" 73 find . -name '*.orig' -delete 74 # Generate various files. 75 ./autogen.sh --enable-cc-silence --enable-xmalloc --enable-utrace \ 76 --with-xslroot=/usr/local/share/xsl/docbook --with-private-namespace=__ \ 77 --with-lg-page-sizes=12,13,14,16 78 gmake dist 79 ) 80} 81 82do_diff() { 83 ( 84 cd ${work} 85 find . -name '*.orig' -delete 86 find . -name '*.rej' -delete 87 git add -A 88 git diff --cached 89 ) > FREEBSD-diffs 90} 91 92command=$1 93shift 94case "${command}" in 95 merge-changes) # Merge local changes that were made since the previous import. 96 rev=`cat VERSION |tr 'g' ' ' |awk '{print $2}'` 97 # Extract code corresponding to most recent import. 98 do_extract ${rev} 99 # Compute local differences to the upstream+patches and apply them. 100 ( 101 cd .. 102 diff -ru -X ${src}/FREEBSD-Xlist ${workname} jemalloc > ${changes} || true 103 ) 104 ( 105 cd ${work} 106 patch -p1 < ${changes} 107 find . -name '*.orig' -delete 108 ) 109 # Update diff. 110 do_diff 111 ;; 112 extract) # Extract upstream sources, apply patches, copy to contrib/jemalloc. 113 rev=$1 114 do_extract ${rev} 115 # Delete existing files so that cruft doesn't silently remain. 116 rm -rf ChangeLog COPYING VERSION doc include src 117 # Copy files over. 118 tar cf - -C ${work} -X FREEBSD-Xlist . |tar xvf - 119 ;; 120 rediff) # Regenerate diffs based on working tree. 121 do_diff 122 ;; 123 clean) # Remove working tree and temporary files. 124 rm -rf ${work} ${changes} 125 ;; 126 *) 127 echo "Unsupported command: \"${command}\"" >&2 128 exit 1 129 ;; 130esac 131