aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/update-zfs.sh
blob: 158457a35e888c869fb47f69fcd5d1bd43a62542 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
#
# WARNING: This script removes the entire zfs subtree and will
# repopulate it using the requested OpenSolaris source release.
# This script should only be used when rebasing the TopGit tree
# against the latest release.  
#
trap die_int INT

RELEASE=$1
PROG=update-zfs.sh
REMOTE_SRC=http://dlc.sun.com/osol/on/downloads/${RELEASE}/on-src.tar.bz2

die() {
	rm -Rf ${SRC}
	echo "${PROG}: $1" >&2
	exit 1
}

die_int() {
	die "Ctrl-C abort"
}

DST=`pwd`
if [ `basename $DST` != "scripts" ]; then
	die "Must be run from scripts directory"
fi

SRC=`mktemp -d /tmp/os-${RELEASE}.XXXXXXXXXX`
DST=`dirname $DST`

echo "----------------------------------------------------------------------"
echo "Remote Source: ${REMOTE_SRC}"
echo "Local Source:  ${SRC}"
echo "Local Dest:    ${DST}"
echo
echo "------------- Fetching OpenSolaris ${RELEASE} archive ----------------"
wget ${REMOTE_SRC} -P ${SRC} ||
	die "Error 'wget ${REMOTE_SRC}'"

echo "------------- Unpacking OperSolaris ${RELEASE} archive ---------------"
tar -xjf ${SRC}/on-src.tar.bz2 -C ${SRC} ||
	die "Error 'tar -xjf ${SRC}/on-src.tar.bz2 -C ${SRC}'"

SRC_LIB=${SRC}/usr/src/lib
SRC_CMD=${SRC}/usr/src/cmd
SRC_CM=${SRC}/usr/src/common
SRC_UTS=${SRC}/usr/src/uts
SRC_UCM=${SRC}/usr/src/uts/common
SRC_ZLIB=${SRC}/usr/src/uts/common/fs/zfs

DST_MOD=${DST}/module
DST_LIB=${DST}/lib
DST_CMD=${DST}/cmd

rm -Rf ${DST}/zfs

echo
echo "------------- Updating ZFS from OpenSolaris ${RELEASE} ---------------"
echo "* module/avl + lib/libavl"
mkdir -p ${DST_MOD}/avl/include/sys/
cp ${SRC_CM}/avl/avl.c				${DST_MOD}/avl/
cp ${SRC_UCM}/sys/avl.h				${DST_MOD}/avl/include/sys/
cp ${SRC_UCM}/sys/avl_impl.h			${DST_MOD}/avl/include/sys/

echo "* module/nvpair + lib/libnvpair"
mkdir -p ${DST_MOD}/nvpair/include/sys/
cp ${SRC_CM}/nvpair/nvpair.c			${DST_MOD}/nvpair/
cp ${SRC_LIB}/libnvpair/libnvpair.c		${DST_MOD}/nvpair/
cp ${SRC_UCM}/os/nvpair_alloc_system.c		${DST_MOD}/nvpair/
cp ${SRC_CM}/nvpair/nvpair_alloc_fixed.c	${DST_MOD}/nvpair/
cp ${SRC_LIB}/libnvpair/libnvpair.h		${DST_MOD}/nvpair/include/
cp ${SRC_UCM}/sys/nvpair.h			${DST_MOD}/nvpair/include/sys/
cp ${SRC_UCM}/sys/nvpair_impl.h			${DST_MOD}/nvpair/include/sys/

echo "* module/zcommon + lib/libzcommon"
mkdir -p ${DST_MOD}/zcommon/include/sys/fs/
mkdir -p ${DST_MOD}/zcommon/include/sys/fm/fs/
cp ${SRC_CM}/zfs/*.c				${DST_MOD}/zcommon/
cp ${SRC_CM}/zfs/*.h				${DST_MOD}/zcommon/include/
cp ${SRC_UCM}/sys/fs/zfs.h			${DST_MOD}/zcommon/include/sys/fs/
cp ${SRC_UCM}/sys/fm/fs/zfs.h			${DST_MOD}/zcommon/include/sys/fm/fs/

echo "* module/zfs"
mkdir -p ${DST_MOD}/zpool/include/sys/
cp ${SRC_UTS}/intel/zfs/spa_boot.c		${DST_MOD}/zfs/
cp ${SRC_ZLIB}/*.c				${DST_MOD}/zfs/
cp ${SRC_ZLIB}/sys/*.h				${DST_MOD}/zfs/include/sys/
rm ${DST_MOD}/zfs/vdev_disk.c
rm ${DST_MOD}/zfs/include/sys/vdev_disk.h

echo " lib/libzpool"
mkdir -p ${DST_LIB}/libzpool/include/sys/
cp ${SRC_LIB}/libzpool/common/kernel.c		${DST_LIB}/libzpool/
cp ${SRC_LIB}/libzpool/common/taskq.c		${DST_LIB}/libzpool/
cp ${SRC_LIB}/libzpool/common/util.c		${DST_LIB}/libzpool/
cp ${SRC_LIB}/libzpool/common/sys/zfs_context.h	${DST_LIB}/libzpool/include/sys/

echo "* lib/libspl"
mkdir -p ${DST_LIB}/libspl/include/sys/
cp ${SRC_LIB}/libc/port/gen/strlcat.c		${DST_LIB}/libspl/
cp ${SRC_LIB}/libc/port/gen/strlcpy.c		${DST_LIB}/libspl/
cp ${SRC_LIB}/libc/port/gen/strnlen.c		${DST_LIB}/libspl/
cp ${SRC_LIB}/libgen/common/mkdirp.c		${DST_LIB}/libspl/
cp ${SRC_CM}/unicode/u8_textprep.c		${DST_LIB}/libspl/
cp ${SRC_UCM}/os/list.c				${DST_LIB}/libspl/
cp ${SRC_UCM}/sys/list.h			${DST_LIB}/libspl/include/sys/
cp ${SRC_UCM}/sys/list_impl.h			${DST_LIB}/libspl/include/sys/

echo "* lib/libuutil"
mkdir -p ${DST_LIB}/libuutil/include/
cp ${SRC_LIB}/libuutil/common/*.c		${DST_LIB}/libuutil/
cp ${SRC_LIB}/libuutil/common/*.h		${DST_LIB}/libuutil/include/

echo "* lib/libzfs"
mkdir -p ${DST_LIB}/libzfs/include/
cp ${SRC_LIB}/libzfs/common/*.c			${DST_LIB}/libzfs/
cp ${SRC_LIB}/libzfs/common/*.h			${DST_LIB}/libzfs/include/

echo "* cmd/zpool"
mkdir -p ${DST_CMD}/zpool
cp ${SRC_CMD}/zpool/*.c				${DST_CMD}/zpool/
cp ${SRC_CMD}/zpool/*.h				${DST_CMD}/zpool/

echo "* cmd/zfs"
mkdir -p ${DST_CMD}/zfs
cp ${SRC_CMD}/zfs/*.c				${DST_CMD}/zfs/
cp ${SRC_CMD}/zfs/*.h				${DST_CMD}/zfs/

echo "* cmd/zdb"
mkdir -p ${DST_CMD}/zdb/
cp ${SRC_CMD}/zdb/*.c				${DST_CMD}/zdb/

echo "* cmd/zdump"
mkdir -p ${DST_CMD}/zdump
cp ${SRC_CMD}/zdump/*.c				${DST_CMD}/zdump/

echo "* cmd/zinject"
mkdir -p ${DST_CMD}/zinject
cp ${SRC_CMD}/zinject/*.c			${DST_CMD}/zinject/
cp ${SRC_CMD}/zinject/*.h			${DST_CMD}/zinject/

echo "* cmd/ztest"
mkdir -p ${DST_CMD}/ztest
cp ${SRC_CMD}/ztest/*.c				${DST_CMD}/ztest/

rm -Rf ${SRC}