Menu

[r7210]: / trunk / build / create_servicepack.sh  Maximize  Restore  History

Download this file

141 lines (105 with data), 4.5 kB

  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
#!/bin/sh
#-
# Copyright (c) 2011 iXsystems, Inc., All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Intended for use internally only to make 'service pack' style images.
# This script does not tolerate any errors.
#
# Configurable
PREFIX=/tmp/servicepack
if [ $# != 2 ]; then
echo Usage: $0 release-image new-image
echo Note: both images needs to be raw and not compressed with xz
exit 1
fi
echo -n "Clearing out and recreating working directory at ${PREFIX}... "
rm -fr ${PREFIX}
mkdir -p ${PREFIX}
echo "Done!"
echo -n "Creating vnode-based mds... "
# Original image
MD1=`mdconfig -a -t vnode -f $1`
# Latest image
MD2=`mdconfig -a -t vnode -f $2`
echo "Done!"
echo -n "Mounting mds... "
# Trees to mount
rm -fr ${PREFIX}/release ${PREFIX}/patched ${PREFIX}/servicepack
mkdir -p ${PREFIX}/release ${PREFIX}/patched
mkdir -p ${PREFIX}/servicepack
# Mount images at mountpoints
mount -o rdonly /dev/${MD1}a ${PREFIX}/release
mount -o rdonly /dev/${MD2}a ${PREFIX}/patched
echo "Done!"
echo -n "Computing SHA256 checksums... "
# Generate sha256 checksums
cd ${PREFIX}/release
find . | sort > ${PREFIX}/release.files
find . -type f | sort | xargs sha256 > ${PREFIX}/release.sha256
cd ${PREFIX}/patched
find . | sort > ${PREFIX}/patched.files
find . -type f | sort | xargs sha256 > ${PREFIX}/patched.sha256
comm -23 ${PREFIX}/release.files ${PREFIX}/patched.files > ${PREFIX}/removed.list
comm -13 ${PREFIX}/release.sha256 ${PREFIX}/patched.sha256 | cut -c9- | rev | cut -c69- | rev > ${PREFIX}/changed.list.tmp
grep ^\./conf/base/ ${PREFIX}/changed.list.tmp | cut -c12- | sed -e s/^/./ > ${PREFIX}/changed.list.exclude
comm -23 ${PREFIX}/changed.list.tmp ${PREFIX}/changed.list.exclude > ${PREFIX}/changed.list
rm -f ${PREFIX}/changed.list.tmp ${PREFIX}/changed.list.exclude
echo "Done!"
echo -n "Copying changed files... "
tar cf - -T ${PREFIX}/changed.list | tar xf - -C ${PREFIX}/servicepack
echo "Done!"
echo -n "Generating post-install files... "
mkdir -p ${PREFIX}/servicepack/etc/servicepack
cp ${PREFIX}/release/etc/version.freenas ${PREFIX}/servicepack/etc/servicepack/version.expected
POSTINSTALL=${PREFIX}/servicepack/etc/servicepack/post-install
echo '#!/bin/sh' > ${POSTINSTALL}
echo 'mount -uw /' >> ${POSTINSTALL}
echo 'rm -f /etc/servicepack/version.expected' >> ${POSTINSTALL}
sed -e 's/^/rm -fr /' ${PREFIX}/removed.list >> ${POSTINSTALL}
echo '# All changes to firmware volume must be done before this line'
echo 'mount -ur /' >> ${POSTINSTALL}
chmod +x ${POSTINSTALL}
echo "Done!"
echo "Packing the service pack... "
rm -f ${PREFIX}/servicepack.tar.xz
cd ${PREFIX}
tar cf servicepack.tar -C ${PREFIX}/servicepack .
xz -9ve servicepack.tar
echo -n "Unmounting and destroying md devices... "
umount -f ${PREFIX}/release
mdconfig -d -u `echo ${MD1} | cut -c3-`
umount -f ${PREFIX}/patched
mdconfig -d -u `echo ${MD2} | cut -c3-`
echo "Done!"
echo "All done! If you want to make any changes to the service pack as a"
echo "post-install action, change ${POSTINSTALL} then:"
echo
cat << E*O*F
rm -f ${PREFIX}/servicepack.tar.xz
cd ${PREFIX}
tar cf servicepack.tar -C ${PREFIX}/servicepack .
xz -9ve servicepack.tar
E*O*F
echo
echo "To re-roll the service pack."
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.