4 # Usage: cd /usr/src/contrib/jemalloc
5 # ./FREEBSD-upgrade <command> [args]
7 # At least the following ports are required when importing jemalloc:
11 # - textproc/docbook-xsl
14 # The normal workflow for importing a new release is:
16 # cd /usr/src/contrib/jemalloc
18 # Merge local changes that were made since the previous import:
20 # ./FREEBSD-upgrade merge-changes
21 # ./FREEBSD-upgrade rediff
23 # Extract latest jemalloc release.
25 # ./FREEBSD-upgrade extract <rev>
27 # Fix patch conflicts as necessary, then regenerate diffs to update line
30 # ./FREEBSD-upgrade rediff
31 # ./FREEBSD-upgrade extract <rev>
33 # Do multiple buildworld/installworld rounds. If problems arise and patches
34 # are needed, edit the code in ${work} as necessary, then:
36 # ./FREEBSD-upgrade rediff
37 # ./FREEBSD-upgrade extract <rev>
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
43 # Finally, to clean up:
45 # ./FREEBSD-upgrade clean
50 if [ ! -x "FREEBSD-upgrade" ] ; then
51 echo "Run from within src/contrib/jemalloc/" >&2
55 if [ "x${JEMALLOC_REPO}" = "x" ] ; then
56 JEMALLOC_REPO=https://github.com/jemalloc/jemalloc.git
61 jemalloc_tmp="jemalloc.tmp"
62 tmpdir="${src}/../${jemalloc_tmp}"
63 bare_repo="${tmpdir}/jemalloc_bare.git"
64 work="jemalloc_work.git"
65 work_repo="${tmpdir}/${work}"
66 namespace_repo="${tmpdir}/jemalloc_namespace.git"
67 changes="${src}/FREEBSD-changes"
71 if [ ! -d "${bare_repo}" ] ; then
72 mkdir -p "${bare_repo}"
73 git clone --bare ${JEMALLOC_REPO} ${bare_repo}
77 git fetch origin ${rev}
86 git clone ${bare_repo} ${repo}
89 if [ "x${rev}" != "x" ] ; then
90 # Use optional rev argument to check out a revision other than HEAD on
98 ./autogen.sh --enable-xmalloc --enable-utrace \
99 --with-malloc-conf=abort_conf:false \
100 --with-xslroot=/usr/local/share/xsl/docbook --with-private-namespace=__ \
101 --with-lg-page-sizes=12,13,14,16
107 do_extract_helper ${rev} ${repo}
110 # Apply diffs before generating files.
111 patch -p1 < "${src}/FREEBSD-diffs"
112 find . -name '*.orig' -delete
119 do_extract_namespace() {
122 do_extract_helper ${rev} ${repo}
127 gmake include/jemalloc/internal/private_namespace.h
134 do_extract_diff ${rev} ${work_repo}
135 do_extract_namespace ${rev} ${namespace_repo}
141 find . -name '*.orig' -delete
142 find . -name '*.rej' -delete
151 merge-changes) # Merge local changes that were made since the previous import.
152 rev=`cat VERSION |tr 'g' ' ' |awk '{print $2}'`
153 # Extract code corresponding to most recent import.
155 # Compute local differences to the upstream+patches and apply them.
158 diff -ru -X ${src}/FREEBSD-Xlist ${work} ../jemalloc > ${changes} || true
162 patch -p1 < ${changes} || true
163 find . -name '*.orig' -delete
168 extract) # Extract upstream sources, apply patches, copy to contrib/jemalloc.
171 # Delete existing files so that cruft doesn't silently remain.
172 rm -rf ChangeLog COPYING VERSION doc include src
174 tar cf - -C ${work_repo} -X FREEBSD-Xlist . |tar xvf -
175 internal_dir="include/jemalloc/internal"
176 grep -v ' isthreaded ' \
177 "${namespace_repo}/${internal_dir}/private_namespace.h" \
178 > "${internal_dir}/private_namespace.h"
180 rediff) # Regenerate diffs based on working tree.
183 clean) # Remove working tree and temporary files.
184 rm -rf ${tmpdir} ${changes}
187 echo "Unsupported command: \"${command}\"" >&2