Ravenports generated: 06 Jun 2018 16:11
[ravenports.git] / bucket_33 / beadm
1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
2
3 NAMEBASE=               beadm
4 VERSION=                1.2.7
5 KEYWORDS=               sysutils
6 VARIANTS=               standard
7 SDESC[standard]=        Shell script to manage ZFS boot environments
8 HOMEPAGE=               https://github.com/vermaden/beadm
9 CONTACT=                Michael_Reim[kraileth@elderlinux.org]
10
11 DOWNLOAD_GROUPS=        main
12 SITES[main]=            GITHUB/vermaden:beadm:1.2.7
13 DISTFILE[1]=            generated:main
14 DF_INDEX=               1
15 SPKGS[standard]=        single
16
17 OPTIONS_AVAILABLE=      none
18 OPTIONS_STANDARD=       none
19
20 ONLY_FOR_OPSYS=         freebsd
21
22 LICENSE=                BSD2CLAUSE:single
23 LICENSE_FILE=           BSD2CLAUSE:{{WRKDIR}}/LICENSE
24 LICENSE_SCHEME=         solo
25
26 FPC_EQUIVALENT=         sysutils/beadm
27
28 SKIP_BUILD=             yes
29
30 post-extract:
31         head -n 26 beadm | tail -n 24 > ${WRKSRC}/LICENSE
32
33 do-install:
34         ${INSTALL_SCRIPT} ${WRKSRC}/beadm ${STAGEDIR}${PREFIX}/sbin
35         ${INSTALL_MAN} ${WRKSRC}/beadm.1 ${STAGEDIR}${PREFIX}/share/man/man1
36
37 [FILE:130:descriptions/desc.single]
38 Beadm is a utility for managing ZFS Boot Environments in an 
39 Illumos/Solaris-like way on FreeBSD. It's written as a shell script.
40
41
42 [FILE:106:distinfo]
43 6982b4d495d954d971470a1b3bcc8bf886e0a412fdf70c034dbaf74f9216f866        14924 vermaden-beadm-1.2.7.tar.gz
44
45
46 [FILE:37:manifests/plist.single]
47 sbin/beadm
48 share/man/man1/beadm.1.gz
49
50
51 [FILE:4208:patches/patch-beadm]
52 --- beadm.orig  2017-01-13 23:25:44 UTC
53 +++ beadm
54 @@ -128,6 +128,24 @@ __be_new() { # 1=SOURCE 2=TARGET
55    unset NAME_NEW
56    unset NAME_SANITY
57    local SOURCE=$( echo ${1} | cut -d '@' -f 1 )
58 +  local ENTROPY=0
59 +  # secure current /boot/entropy file
60 +  if [ -f /boot/entropy ]
61 +  then
62 +    if ! cp -p /boot/entropy /boot/entropy.OLD 1> /dev/null 2> /dev/null
63 +    then
64 +      echo "ERROR: Can not copy current '/boot/entropy' file"
65 +      exit 1
66 +    fi
67 +    ENTROPY=1
68 +  fi
69 +  # create new /boot/entropy file that would be used in new boot environment
70 +  if ! dd if=/dev/random of=/boot/entropy bs=4096 count=1 1> /dev/null 2> /dev/null
71 +  then
72 +    echo "ERROR: Can not generate new '/boot/entropy' file"
73 +    exit 1
74 +  fi
75 +  # create snapshot that will be used as a base for new boot environment
76    if __be_snapshot ${1}
77    then
78      # create boot environment from snapshot
79 @@ -138,6 +156,13 @@ __be_new() { # 1=SOURCE 2=TARGET
80            if ! zfs list -H -o name ${FS}@${SNAPSHOT} 1> /dev/null 2> /dev/null
81            then
82              echo "ERROR: Child snapshot '${FS}@${SNAPSHOT}' does not exist"
83 +            if [ ${ENTROPY} -ne 0 ]
84 +            then
85 +              if ! mv /boot/entropy.OLD /boot/entropy 1> /dev/null 2> /dev/null
86 +              then
87 +                echo "WARNING: Can not bring back original '/boot/entropy' file"
88 +              fi
89 +            fi
90              exit 1
91            fi
92          done
93 @@ -146,6 +171,13 @@ __be_new() { # 1=SOURCE 2=TARGET
94      if zfs list -H -o name ${1}@${2##*/} 1> /dev/null 2> /dev/null
95      then
96        echo "ERROR: Snapshot '${1}@${2##*/}' already exists"
97 +      if [ ${ENTROPY} -ne 0 ]
98 +      then
99 +        if ! mv /boot/entropy.OLD /boot/entropy 1> /dev/null 2> /dev/null
100 +        then
101 +          echo "WARNING: Can not bring back original '/boot/entropy' file"
102 +        fi
103 +      fi
104        exit 1
105      fi
106      # snapshot format
107 @@ -153,9 +185,25 @@ __be_new() { # 1=SOURCE 2=TARGET
108      if ! zfs snapshot -r ${1}@${FMT} 1> /dev/null 2> /dev/null
109      then
110        echo "ERROR: Cannot create snapshot '${1}@${FMT}'"
111 +      if [ ${ENTROPY} -ne 0 ]
112 +      then
113 +        if ! mv /boot/entropy.OLD /boot/entropy 1> /dev/null 2> /dev/null
114 +        then
115 +          echo "WARNING: Can not bring back original '/boot/entropy' file"
116 +        fi
117 +      fi
118        exit 1
119      fi
120    fi
121 +  # bring back secured /boot/entropy.OLD file
122 +  if [ -f /boot/entropy.OLD ]
123 +  then
124 +    if ! mv /boot/entropy.OLD /boot/entropy 1> /dev/null 2> /dev/null
125 +    then
126 +      echo "WARNING: Can not bring back original '/boot/entropy' file"
127 +    fi
128 +  fi
129 +  unset ENTROPY
130    # clone properties of source boot environment
131    zfs list -H -o name -r ${SOURCE} \
132      | grep -v '@' \
133 @@ -303,7 +351,7 @@ case ${1} in
134          while(CMD_ZFS_LIST BENAME_BEGINS_WITH | getline) {
135            if($1 != BENAME_BEGINS_WITH) {
136              FSNAME = $1
137 -            FSNAMES[length(FSNAME) + 1] = FSNAME
138 +            FSNAMES[length(FSNAMES) + 1] = FSNAME
139              USED              = __normalize($2)
140              USEDBYDATASET     = __normalize($3)
141              USEDBYSNAPSHOTS   = __normalize($4)
142 @@ -492,6 +540,7 @@ case ${1} in
143          fi
144        fi
145        # do not change root (/) mounted boot environment mountpoint
146 +      HAVE_ZFSBE=0
147        if [ "${ROOTFS}" != "${POOL}/${BEDS}/${2}" ]
148        then
149          TMPMNT=$( mktemp -d -t BE-${2} )
150 @@ -519,6 +568,9 @@ EOF
151          else
152            TMPMNT=${MOUNT}
153          fi
154 +        if [ -f ${TMPMNT}/etc/rc.d/zfsbe ]; then
155 +          HAVE_ZFSBE=1
156 +        fi
157          if [ -f /boot/zfs/zpool.cache ]
158          then
159            cp /boot/zfs/zpool.cache ${TMPMNT}/boot/zfs/zpool.cache
160 @@ -555,11 +607,16 @@ EOF
161            zfs set canmount=noauto ${NAME}
162          done
163      # enable automatic mount for active boot environment and promote it
164 +    if [ ${HAVE_ZFSBE} -eq 1 ]; then
165 +      ZFSBE_CANMOUNT=noauto
166 +    else
167 +      ZFSBE_CANMOUNT=on
168 +    fi
169      echo "${ZFS_LIST}" \
170        | grep -E "^${POOL}/${BEDS}/${2}(/|$)" \
171        | while read NAME
172          do
173 -          zfs set canmount=on ${NAME}
174 +          zfs set canmount=${ZFSBE_CANMOUNT} ${NAME}
175            while __be_clone ${NAME}
176            do
177              zfs promote ${NAME}
178
179
180 [FILE:500:patches/patch-beadm.1]
181 commit 25a066def7cddd0f9178d07531b1f18703308db0
182 Author: Alan Somers <asomers@gmail.com>
183 Date:   Wed Sep 6 09:17:00 2017 -0600
184
185     Fix indentation in man page
186
187 --- beadm.1.orig        2017-01-13 23:25:44 UTC
188 +++ beadm.1
189 @@ -87,9 +87,11 @@ If the -e param is specified, the new environment will
190  Creates a snapshot of the existing boot environment named
191  .Ar beName .
192  .Pp
193 -.It
194 -.Ic destroy Op Fl F
195 +.It Xo
196 +.Ic destroy
197 +.Op Fl F
198  .Ao Ar beName | beName@snapshot Ac
199 +.Xc
200  .Pp
201  Destroys the given
202  .Ar beName
203