Moving lib/libspl to linux-libspl branch
[zfs.git] / scripts / update-zfs.sh
1 #!/bin/bash
2 #
3 # WARNING: This script removes the entire zfs subtree and will
4 # repopulate it using the requested OpenSolaris source release.
5 # This script should only be used when rebasing the TopGit tree
6 # against the latest release.  
7 #
8 trap die_int INT
9
10 RELEASE=$1
11 PROG=update-zfs.sh
12 REMOTE_SRC=http://dlc.sun.com/osol/on/downloads/${RELEASE}/on-src.tar.bz2
13
14 die() {
15         rm -Rf ${SRC}
16         echo "${PROG}: $1" >&2
17         exit 1
18 }
19
20 die_int() {
21         die "Ctrl-C abort"
22 }
23
24 DST=`pwd`
25 if [ `basename $DST` != "scripts" ]; then
26         die "Must be run from scripts directory"
27 fi
28
29 SRC=`mktemp -d /tmp/os-${RELEASE}.XXXXXXXXXX`
30 DST=`dirname $DST`
31
32 echo "----------------------------------------------------------------------"
33 echo "Remote Source: ${REMOTE_SRC}"
34 echo "Local Source:  ${SRC}"
35 echo "Local Dest:    ${DST}"
36 echo
37 echo "------------- Fetching OpenSolaris ${RELEASE} archive ----------------"
38 wget ${REMOTE_SRC} -P ${SRC} ||
39         die "Error 'wget ${REMOTE_SRC}'"
40
41 echo "------------- Unpacking OpenSolaris ${RELEASE} archive ---------------"
42 tar -xjf ${SRC}/on-src.tar.bz2 -C ${SRC} ||
43         die "Error 'tar -xjf ${SRC}/on-src.tar.bz2 -C ${SRC}'"
44
45 SRC_LIB=${SRC}/usr/src/lib
46 SRC_CMD=${SRC}/usr/src/cmd
47 SRC_CM=${SRC}/usr/src/common
48 SRC_UTS=${SRC}/usr/src/uts
49 SRC_UCM=${SRC}/usr/src/uts/common
50 SRC_ZLIB=${SRC}/usr/src/uts/common/fs/zfs
51
52 DST_MOD=${DST}/module
53 DST_LIB=${DST}/lib
54 DST_CMD=${DST}/cmd
55
56 rm -Rf ${DST}/zfs
57
58 echo
59 echo "------------- Updating ZFS from OpenSolaris ${RELEASE} ---------------"
60 echo "* module/avl"
61 mkdir -p ${DST_MOD}/avl/include/sys/
62 cp ${SRC_CM}/avl/avl.c                          ${DST_MOD}/avl/
63 cp ${SRC_UCM}/sys/avl.h                         ${DST_MOD}/avl/include/sys/
64 cp ${SRC_UCM}/sys/avl_impl.h                    ${DST_MOD}/avl/include/sys/
65
66 echo "* module/nvpair"
67 mkdir -p ${DST_MOD}/nvpair/include/sys/
68 cp ${SRC_CM}/nvpair/nvpair.c                    ${DST_MOD}/nvpair/
69 cp ${SRC_UCM}/sys/nvpair.h                      ${DST_MOD}/nvpair/include/sys/
70 cp ${SRC_UCM}/sys/nvpair_impl.h                 ${DST_MOD}/nvpair/include/sys/
71
72 echo "* module/zcommon"
73 mkdir -p ${DST_MOD}/zcommon/include/sys/fs/
74 mkdir -p ${DST_MOD}/zcommon/include/sys/fm/fs/
75 cp ${SRC_CM}/zfs/*.c                            ${DST_MOD}/zcommon/
76 cp ${SRC_CM}/zfs/*.h                            ${DST_MOD}/zcommon/include/
77 cp ${SRC_UCM}/sys/fs/zfs.h                      ${DST_MOD}/zcommon/include/sys/fs/
78 cp ${SRC_UCM}/sys/fm/fs/zfs.h                   ${DST_MOD}/zcommon/include/sys/fm/fs/
79
80 echo "* module/zfs"
81 mkdir -p ${DST_MOD}/zpool/include/sys/
82 cp ${SRC_UTS}/intel/zfs/spa_boot.c              ${DST_MOD}/zfs/
83 cp ${SRC_ZLIB}/*.c                              ${DST_MOD}/zfs/
84 cp ${SRC_ZLIB}/sys/*.h                          ${DST_MOD}/zfs/include/sys/
85 rm ${DST_MOD}/zfs/vdev_disk.c
86 rm ${DST_MOD}/zfs/include/sys/vdev_disk.h
87
88 echo "* lib/libavl"
89 # Full source available in 'module/avl'
90
91 echo "* lib/libnvpair"
92 mkdir -p ${DST_LIB}/libnvpair/include/
93 cp ${SRC_UCM}/os/nvpair_alloc_system.c          ${DST_LIB}/libnvpair/
94 cp ${SRC_LIB}/libnvpair/libnvpair.c             ${DST_LIB}/libnvpair/
95 cp ${SRC_LIB}/libnvpair/libnvpair.h             ${DST_LIB}/libnvpair/include/
96
97 echo "* lib/libuutil"
98 mkdir -p ${DST_LIB}/libuutil/include/
99 cp ${SRC_LIB}/libuutil/common/*.c               ${DST_LIB}/libuutil/
100 cp ${SRC_LIB}/libuutil/common/*.h               ${DST_LIB}/libuutil/include/
101
102 echo "* lib/libzcommon"
103 # Full source available in 'module/zcommon'
104
105 echo "* lib/libzpool"
106 mkdir -p ${DST_LIB}/libzpool/include/sys/
107 cp ${SRC_LIB}/libzpool/common/kernel.c          ${DST_LIB}/libzpool/
108 cp ${SRC_LIB}/libzpool/common/taskq.c           ${DST_LIB}/libzpool/
109 cp ${SRC_LIB}/libzpool/common/util.c            ${DST_LIB}/libzpool/
110 cp ${SRC_LIB}/libzpool/common/sys/zfs_context.h ${DST_LIB}/libzpool/include/sys/
111
112 echo "* lib/libzfs"
113 mkdir -p ${DST_LIB}/libzfs/include/
114 cp ${SRC_LIB}/libzfs/common/*.c                 ${DST_LIB}/libzfs/
115 cp ${SRC_LIB}/libzfs/common/*.h                 ${DST_LIB}/libzfs/include/
116
117 echo "* cmd/zpool"
118 mkdir -p ${DST_CMD}/zpool
119 cp ${SRC_CMD}/zpool/*.c                         ${DST_CMD}/zpool/
120 cp ${SRC_CMD}/zpool/*.h                         ${DST_CMD}/zpool/
121
122 echo "* cmd/zfs"
123 mkdir -p ${DST_CMD}/zfs
124 cp ${SRC_CMD}/zfs/*.c                           ${DST_CMD}/zfs/
125 cp ${SRC_CMD}/zfs/*.h                           ${DST_CMD}/zfs/
126
127 echo "* cmd/zdb"
128 mkdir -p ${DST_CMD}/zdb/
129 cp ${SRC_CMD}/zdb/*.c                           ${DST_CMD}/zdb/
130
131 echo "* cmd/zdump"
132 mkdir -p ${DST_CMD}/zdump
133 cp ${SRC_CMD}/zdump/*.c                         ${DST_CMD}/zdump/
134
135 echo "* cmd/zinject"
136 mkdir -p ${DST_CMD}/zinject
137 cp ${SRC_CMD}/zinject/*.c                       ${DST_CMD}/zinject/
138 cp ${SRC_CMD}/zinject/*.h                       ${DST_CMD}/zinject/
139
140 echo "* cmd/ztest"
141 mkdir -p ${DST_CMD}/ztest
142 cp ${SRC_CMD}/ztest/*.c                         ${DST_CMD}/ztest/
143
144 echo "${REMOTE_SRC}" >${DST}/ZFS.RELEASE
145
146 rm -Rf ${SRC}