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