amanda-3.3.7.ebuild 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. # Copyright 1999-2015 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. inherit autotools eutils perl-module user systemd
  5. DESCRIPTION="The Advanced Maryland Automatic Network Disk Archiver"
  6. HOMEPAGE="http://www.amanda.org/"
  7. SRC_URI="mirror://sourceforge/amanda/${P}.tar.gz"
  8. LICENSE="HPND BSD BSD-2 GPL-2+ GPL-3+"
  9. SLOT="0"
  10. IUSE="curl gnuplot ipv6 kerberos minimal nls readline s3 samba systemd xfs"
  11. KEYWORDS="amd64 ~ppc ppc64 ~sparc ~x86"
  12. RDEPEND="sys-libs/readline
  13. virtual/awk
  14. app-arch/tar
  15. dev-lang/perl:=
  16. app-arch/dump
  17. net-misc/openssh
  18. >=dev-libs/glib-2.26.0
  19. nls? ( virtual/libintl )
  20. s3? ( >=net-misc/curl-7.10.0 )
  21. !s3? ( curl? ( >=net-misc/curl-7.10.0 ) )
  22. samba? ( net-fs/samba )
  23. kerberos? ( app-crypt/mit-krb5 )
  24. xfs? ( sys-fs/xfsdump )
  25. readline? ( sys-libs/readline )
  26. !minimal? (
  27. dev-perl/XML-Simple
  28. virtual/mailx
  29. app-arch/mt-st
  30. sys-block/mtx
  31. gnuplot? ( sci-visualization/gnuplot )
  32. app-crypt/aespipe
  33. app-crypt/gnupg
  34. )"
  35. DEPEND="${RDEPEND}
  36. virtual/pkgconfig
  37. nls? ( sys-devel/gettext )
  38. >=app-text/docbook-xsl-stylesheets-1.72.0
  39. app-text/docbook-xml-dtd
  40. dev-libs/libxslt
  41. "
  42. MYFILESDIR="${T}/files"
  43. ENVDIR="/etc/env.d"
  44. ENVDFILE="97amanda"
  45. TMPENVFILE="${T}/${ENVDFILE}"
  46. # This is a complete list of Amanda settings that the ebuild takes from the
  47. # build environment. This allows users to alter the behavior of the package as
  48. # upstream intended, but keeping with Gentoo style. We store a copy of them in
  49. # /etc/env.d/97amanda during the install, so that they are preserved for future
  50. # installed. This variable name must not start with AMANDA_, as we do not want
  51. # it captured into the env file.
  52. ENV_SETTINGS_AMANDA="
  53. AMANDA_GROUP_GID AMANDA_GROUP_NAME
  54. AMANDA_USER_NAME AMANDA_USER_UID AMANDA_USER_SH AMANDA_USER_HOMEDIR AMANDA_USER_GROUPS
  55. AMANDA_SERVER AMANDA_SERVER_TAPE AMANDA_SERVER_INDEX
  56. AMANDA_TAR_LISTDIR AMANDA_TAR
  57. AMANDA_PORTS_UDP AMANDA_PORTS_TCP AMANDA_PORTS_BOTH AMANDA_PORTS
  58. AMANDA_CONFIG_NAME AMANDA_TMPDIR"
  59. amanda_variable_setup() {
  60. # Setting vars
  61. local currentamanda
  62. # Grab the current settings
  63. currentamanda="$(set | egrep "^AMANDA_" | grep -v '^AMANDA_ENV_SETTINGS' | xargs)"
  64. # First we set the defaults
  65. [ -z "${AMANDA_GROUP_GID}" ] && AMANDA_GROUP_GID=87
  66. [ -z "${AMANDA_GROUP_NAME}" ] && AMANDA_GROUP_NAME=amanda
  67. [ -z "${AMANDA_USER_NAME}" ] && AMANDA_USER_NAME=amanda
  68. [ -z "${AMANDA_USER_UID}" ] && AMANDA_USER_UID=87
  69. [ -z "${AMANDA_USER_SH}" ] && AMANDA_USER_SH=/bin/bash
  70. [ -z "${AMANDA_USER_HOMEDIR}" ] && AMANDA_USER_HOMEDIR=/var/spool/amanda
  71. [ -z "${AMANDA_USER_GROUPS}" ] && AMANDA_USER_GROUPS="${AMANDA_GROUP_NAME}"
  72. # This installs Amanda, with the server. However, it could be a client,
  73. # just specify an alternate server name in AMANDA_SERVER.
  74. [ -z "${AMANDA_SERVER}" ] && AMANDA_SERVER="${HOSTNAME}"
  75. [ -z "${AMANDA_SERVER_TAPE}" ] && AMANDA_SERVER_TAPE="${AMANDA_SERVER}"
  76. [ -z "${AMANDA_SERVER_INDEX}" ] && AMANDA_SERVER_INDEX="${AMANDA_SERVER}"
  77. [ -z "${AMANDA_TAR_LISTDIR}" ] && AMANDA_TAR_LISTDIR=${AMANDA_USER_HOMEDIR}/tar-lists
  78. [ -z "${AMANDA_CONFIG_NAME}" ] && AMANDA_CONFIG_NAME=DailySet1
  79. [ -z "${AMANDA_TMPDIR}" ] && AMANDA_TMPDIR=/var/tmp/amanda
  80. [ -z "${AMANDA_DBGDIR}" ] && AMANDA_DBGDIR="$AMANDA_TMPDIR"
  81. # These are left empty by default
  82. [ -z "${AMANDA_PORTS_UDP}" ] && AMANDA_PORTS_UDP=
  83. [ -z "${AMANDA_PORTS_TCP}" ] && AMANDA_PORTS_TCP=
  84. [ -z "${AMANDA_PORTS_BOTH}" ] && AMANDA_PORTS_BOTH=
  85. [ -z "${AMANDA_PORTS}" ] && AMANDA_PORTS=
  86. # What tar to use
  87. [ -z "${AMANDA_TAR}" ] && AMANDA_TAR=/bin/tar
  88. # Now pull in the old stuff
  89. if [ -f "${ROOT}${ENVDIR}/${ENVDFILE}" ]; then
  90. # We don't just source it as we don't want everything in there.
  91. eval $(egrep "^AMANDA_" "${ROOT}${ENVDIR}/${ENVDFILE}" | grep -v '^AMANDA_ENV_SETTINGS')
  92. fi
  93. # Re-apply the new settings if any
  94. [ -n "${currentamanda}" ] && eval `echo "${currentamanda}"`
  95. }
  96. pkg_setup() {
  97. amanda_variable_setup
  98. # If USE=minimal, give out a warning, if AMANDA_SERVER is not set to
  99. # another host than HOSTNAME.
  100. if use minimal && [ "${AMANDA_SERVER}" = "${HOSTNAME}" ] ; then
  101. elog "You are installing a client-only version of Amanda."
  102. elog "You should set the variable \$AMANDA_SERVER to point at your"
  103. elog "Amanda-tape-server, otherwise you will have to specify its name"
  104. elog "when using amrecover on the client."
  105. elog "For example: Use something like"
  106. elog "AMANDA_SERVER=\"myserver\" emerge amanda"
  107. elog
  108. fi
  109. enewgroup "${AMANDA_GROUP_NAME}" "${AMANDA_GROUP_GID}"
  110. enewuser "${AMANDA_USER_NAME}" "${AMANDA_USER_UID}" "${AMANDA_USER_SH}" "${AMANDA_USER_HOMEDIR}" "${AMANDA_USER_GROUPS}"
  111. }
  112. src_unpack() {
  113. # we do not want the perl src_unpack
  114. default_src_unpack
  115. }
  116. src_prepare() {
  117. # gentoo bug #331111
  118. sed -i '/^check-local: check-perl$/d' "${S}"/config/automake/scripts.am
  119. sed -i '/^check-local:/s,syntax-check,,g' "${S}"/perl/Makefile.am
  120. # bug with glibc-2.16.0
  121. sed -i -e '/gets is a security/d' "${S}"/gnulib/stdio.in.h
  122. eautoreconf
  123. # places for us to work in
  124. mkdir -p "${MYFILESDIR}"
  125. # Now we store the settings we just created
  126. set | egrep "^AMANDA_" | grep -v '^AMANDA_ENV_SETTINGS' > "${TMPENVFILE}"
  127. # Prepare our custom files
  128. einfo "Building custom configuration files"
  129. local i # our iterator
  130. local sedexpr # var for sed expr
  131. sedexpr=''
  132. for i in ${ENV_SETTINGS_AMANDA} ; do
  133. local val
  134. eval "val=\"\${${i}}\""
  135. sedexpr="${sedexpr}s|__${i}__|${val}|g;"
  136. done
  137. # now apply the sed expr
  138. for i in "${FILESDIR}"/amanda-* ; do
  139. sed -re "${sedexpr}" <"${i}" >"${MYFILESDIR}/`basename ${i}`"
  140. done
  141. (
  142. cat "${MYFILESDIR}"/amanda-amandahosts-client-2.5.1_p3-r1
  143. use minimal || cat "${MYFILESDIR}"/amanda-amandahosts-server-2.5.1_p3-r1
  144. ) > "${T}"/amandahosts
  145. if ! use minimal; then
  146. sed -i -e 's:^\(my $amandahomedir\)=.*:\1 = $localstatedir;:' \
  147. server-src/am{addclient,serverconfig}.pl || die
  148. fi
  149. }
  150. src_configure() {
  151. # fix bug #36316
  152. addpredict /var/cache/samba/gencache.tdb
  153. # fix bug #376169
  154. addpredict /run/blkid
  155. addpredict /etc/blkid.tab
  156. [ ! -f "${TMPENVFILE}" ] && die "Variable setting file (${TMPENVFILE}) should exist!"
  157. source "${TMPENVFILE}"
  158. local myconf
  159. einfo "Using ${AMANDA_SERVER_TAPE} for tape server."
  160. myconf="${myconf} --with-tape-server=${AMANDA_SERVER_TAPE}"
  161. einfo "Using ${AMANDA_SERVER_INDEX} for index server."
  162. myconf="${myconf} --with-index-server=${AMANDA_SERVER_INDEX}"
  163. einfo "Using ${AMANDA_USER_NAME} for amanda user."
  164. myconf="${myconf} --with-user=${AMANDA_USER_NAME}"
  165. einfo "Using ${AMANDA_GROUP_NAME} for amanda group."
  166. myconf="${myconf} --with-group=${AMANDA_GROUP_NAME}"
  167. einfo "Using ${AMANDA_TAR} as Tar implementation."
  168. myconf="${myconf} --with-gnutar=${AMANDA_TAR}"
  169. einfo "Using ${AMANDA_TAR_LISTDIR} as tar listdir."
  170. myconf="${myconf} --with-gnutar-listdir=${AMANDA_TAR_LISTDIR}"
  171. einfo "Using ${AMANDA_CONFIG_NAME} as default config name."
  172. myconf="${myconf} --with-config=${AMANDA_CONFIG_NAME}"
  173. einfo "Using ${AMANDA_TMPDIR} as Amanda temporary directory."
  174. myconf="${myconf} --with-tmpdir=${AMANDA_TMPDIR}"
  175. if [ -n "${AMANDA_PORTS_UDP}" ] && [ -n "${AMANDA_PORTS_TCP}" ] && [ -z "${AMANDA_PORTS_BOTH}" ] ; then
  176. eerror "If you want _both_ UDP and TCP ports, please use only the"
  177. eerror "AMANDA_PORTS environment variable for identical ports, or set"
  178. eerror "AMANDA_PORTS_BOTH."
  179. die "Bad port setup!"
  180. fi
  181. if [ -n "${AMANDA_PORTS_UDP}" ]; then
  182. einfo "Using UDP ports ${AMANDA_PORTS_UDP/,/-}"
  183. myconf="${myconf} --with-udpportrange=${AMANDA_PORTS_UDP}"
  184. fi
  185. if [ -n "${AMANDA_PORTS_TCP}" ]; then
  186. einfo "Using TCP ports ${AMANDA_PORTS_TCP/,/-}"
  187. myconf="${myconf} --with-tcpportrange=${AMANDA_PORTS_TCP}"
  188. fi
  189. if [ -n "${AMANDA_PORTS}" ]; then
  190. einfo "Using ports ${AMANDA_PORTS/,/-}"
  191. myconf="${myconf} --with-portrange=${AMANDA_PORTS}"
  192. fi
  193. # Extras
  194. # Speed option
  195. myconf="${myconf} --with-buffered-dump"
  196. # "debugging" in the configuration is NOT debug in the conventional sense.
  197. # It is actually just useful output in the application, and should remain
  198. # enabled. There are some cases of breakage with MTX tape changers as of
  199. # 2.5.1p2 that it exposes when turned off as well.
  200. myconf="${myconf} --with-debugging"
  201. # Where to put our files
  202. myconf="${myconf} --localstatedir=${AMANDA_USER_HOMEDIR}"
  203. # Samba support
  204. myconf="${myconf} `use_with samba smbclient /usr/bin/smbclient`"
  205. # Support for BSD, SSH, BSDUDP, BSDTCP security methods all compiled in by
  206. # default
  207. myconf="${myconf} --with-bsd-security"
  208. myconf="${myconf} --with-ssh-security"
  209. myconf="${myconf} --with-bsdudp-security"
  210. myconf="${myconf} --with-bsdtcp-security"
  211. # kerberos-security mechanism version 5
  212. myconf="${myconf} `use_with kerberos krb5-security`"
  213. # Amazon S3 support
  214. myconf="${myconf} `use_enable s3 s3-device`"
  215. # libcurl is required for S3 but otherwise optional
  216. if ! use s3; then
  217. myconf="${myconf} $(use_with curl libcurl)"
  218. fi
  219. # Client only, as requested in bug #127725
  220. if use minimal ; then
  221. myconf="${myconf} --without-server"
  222. else
  223. # amplot
  224. myconf="${myconf} $(use_with gnuplot)"
  225. fi
  226. # IPv6 fun.
  227. myconf="${myconf} `use_with ipv6`"
  228. # This is to prevent the IPv6-is-working test
  229. # As the test fails on binpkg build hosts with no IPv6.
  230. use ipv6 && export amanda_cv_working_ipv6=yes
  231. # I18N
  232. myconf="${myconf} `use_enable nls`"
  233. # Bug #296634: Perl location
  234. perl_set_version
  235. myconf="${myconf} --with-amperldir=${VENDOR_LIB}"
  236. # Bug 296633: --disable-syntax-checks
  237. # Some tests are not safe for production systems
  238. myconf="${myconf} --disable-syntax-checks"
  239. # build manpages
  240. myconf="${myconf} --enable-manpage-build"
  241. # bug #483120
  242. tc-export AR
  243. econf \
  244. $(use_with readline) \
  245. ${myconf}
  246. }
  247. src_compile() {
  248. # Again, do not want the perl-module src_compile
  249. default_src_compile
  250. }
  251. src_install() {
  252. [ ! -f "${TMPENVFILE}" ] && die "Variable setting file (${TMPENVFILE}) should exist!"
  253. source ${TMPENVFILE}
  254. einfo "Doing stock install"
  255. emake DESTDIR="${D}" install || die
  256. # Build the envdir file
  257. # Don't forget this..
  258. einfo "Building environment file"
  259. (
  260. echo "# These settings are what was present in the environment when this"
  261. echo "# Amanda was compiled. Changing anything below this comment will"
  262. echo "# have no effect on your application, but it merely exists to"
  263. echo "# preserve them for your next emerge of Amanda"
  264. cat "${TMPENVFILE}" | sed "s,=\$,='',g"
  265. ) >> "${MYFILESDIR}/${ENVDFILE}"
  266. # Env.d
  267. einfo "Installing environment config file"
  268. doenvd "${MYFILESDIR}/${ENVDFILE}"
  269. # Lock down next section (up until docs).
  270. insopts -m0640
  271. # Installing Amanda Xinetd Services Definition
  272. einfo "Installing xinetd service file"
  273. insinto /etc/xinetd.d
  274. if use minimal ; then
  275. newins "${MYFILESDIR}"/amanda-xinetd-2.6.1_p1-client amanda
  276. else
  277. newins "${MYFILESDIR}"/amanda-xinetd-2.6.1_p1-server amanda
  278. fi
  279. if ! use minimal; then
  280. einfo "Installing Sample Daily Cron Job for Amanda"
  281. insinto /etc/cron.daily
  282. newins "${MYFILESDIR}/amanda-cron" amanda
  283. fi
  284. einfo "Installing systemd service and socket files for Amanda"
  285. systemd_dounit "${FILESDIR}"/amanda.socket || die
  286. systemd_newunit "${FILESDIR}"/amanda.service-r1 'amanda@.service' || die
  287. insinto /etc/amanda
  288. einfo "Installing .amandahosts File for ${AMANDA_USER_NAME} user"
  289. doins "${T}/amandahosts"
  290. fperms 600 /etc/amanda/amandahosts
  291. dosym /etc/amanda/amandahosts "${AMANDA_USER_HOMEDIR}/.amandahosts"
  292. insinto "${AMANDA_USER_HOMEDIR}"
  293. einfo "Installing .profile for ${AMANDA_USER_NAME} user"
  294. newins "${MYFILESDIR}/amanda-profile" .profile
  295. insinto /etc/amanda
  296. doins "${S}/example/amanda-client.conf"
  297. if ! use minimal ; then
  298. insinto "/etc/amanda/${AMANDA_CONFIG_NAME}"
  299. doins "${S}/example/amanda.conf"
  300. doins "${S}/example/disklist"
  301. keepdir "${AMANDA_USER_HOMEDIR}/${AMANDA_CONFIG_NAME}/index"
  302. fi
  303. keepdir "${AMANDA_TAR_LISTDIR}"
  304. keepdir "${AMANDA_USER_HOMEDIR}/amanda"
  305. keepdir "${AMANDA_TMPDIR}/dumps"
  306. # Just make sure it exists for XFS to work...
  307. use xfs && keepdir /var/xfsdump/inventory
  308. local i
  309. for i in "${AMANDA_USER_HOMEDIR}" "${AMANDA_TAR_LISTDIR}" \
  310. "${AMANDA_TMPDIR}" /etc/amanda; do
  311. einfo "Securing directory (${i})"
  312. fowners -R ${AMANDA_USER_NAME}:${AMANDA_GROUP_NAME} ${i}
  313. done
  314. # Do NOT use -R
  315. fperms 0700 \
  316. "${AMANDA_USER_HOMEDIR}" "${AMANDA_TAR_LISTDIR}" \
  317. "${AMANDA_TMPDIR}" "${AMANDA_TMPDIR}/dumps" \
  318. "${AMANDA_USER_HOMEDIR}/amanda" \
  319. /etc/amanda
  320. if ! use minimal ; then
  321. fperms 0700 \
  322. "${AMANDA_USER_HOMEDIR}/${AMANDA_CONFIG_NAME}" \
  323. /etc/amanda/${AMANDA_CONFIG_NAME}
  324. fi
  325. einfo "Setting setuid permissions"
  326. amanda_permissions_fix "${D}"
  327. # Relax permissions again
  328. insopts -m0644
  329. # docs
  330. einfo "Installing documentation"
  331. dodoc AUTHORS ChangeLog DEVELOPING NEWS README ReleaseNotes UPGRADING
  332. # our inetd sample
  333. einfo "Installing standard inetd sample"
  334. newdoc "${MYFILESDIR}/amanda-inetd.amanda.sample-2.6.0_p2-r2" amanda-inetd.amanda.sample
  335. # Amanda example configs
  336. einfo "Installing example configurations"
  337. rm "${D}"/usr/share/amanda/{COPYRIGHT,ChangeLog,NEWS,ReleaseNotes}
  338. mv "${D}/usr/share/amanda/example" "${D}/usr/share/doc/${PF}/"
  339. docinto example1
  340. newdoc "${FILESDIR}/example_amanda.conf" amanda.conf
  341. newdoc "${FILESDIR}/example_disklist-2.5.1_p3-r1" disklist
  342. newdoc "${FILESDIR}/example_global.conf" global.conf
  343. einfo "Cleaning up dud .la files"
  344. perl_set_version
  345. find "${D}"/"${VENDOR_LIB}" -name '*.la' -print0 |xargs -0 rm -f
  346. }
  347. pkg_postinst() {
  348. [ ! -f "${TMPENVFILE}" -a "$MERGE_TYPE" == "binary" ] && \
  349. TMPENVFILE="${ROOT}${ENVDIR}/${ENVDFILE}"
  350. [ ! -f "${TMPENVFILE}" ] && die "Variable setting file (${TMPENVFILE}) should exist!"
  351. source "${TMPENVFILE}"
  352. # Migration of amandates from /etc to $localstatedir/amanda
  353. if [ -f "${ROOT}/etc/amandates" -a \
  354. ! -f "${ROOT}/${AMANDA_USER_HOMEDIR}/amanda/amandates" ]; then
  355. einfo "Migrating amandates from /etc/ to ${AMANDA_USER_HOMEDIR}/amanda"
  356. einfo "A backup is also placed at /etc/amandates.orig"
  357. cp -dp "${ROOT}/etc/amandates" "${ROOT}/etc/amandates.orig"
  358. mkdir -p "${ROOT}/${AMANDA_USER_HOMEDIR}/amanda/"
  359. cp -dp "${ROOT}/etc/amandates" "${ROOT}/${AMANDA_USER_HOMEDIR}/amanda/amandates"
  360. fi
  361. if [ -f "${ROOT}/etc/amandates" ]; then
  362. einfo "If you have migrated safely, please delete /etc/amandates"
  363. fi
  364. einfo "Checking setuid permissions"
  365. amanda_permissions_fix "${ROOT}"
  366. elog "You should configure Amanda in /etc/amanda now."
  367. elog
  368. elog "If you use xinetd, Don't forget to check /etc/xinetd.d/amanda"
  369. elog "and restart xinetd afterwards!"
  370. elog
  371. elog "Otherwise, please look at /usr/share/doc/${PF}/inetd.amanda.sample"
  372. elog "as an example of how to configure your inetd."
  373. elog
  374. elog "systemd-users: enable and start amanda.socket or the relevant services"
  375. elog "regarding what auth method you use."
  376. elog
  377. elog "NOTICE: If you need raw access to partitions you need to add the"
  378. elog "amanda user to the 'disk' group."
  379. elog
  380. elog "NOTICE: If you have a tape changer, you need to add the amanda user"
  381. elog "to the 'tape' group."
  382. elog
  383. elog "If you use localhost in your disklist your restores may break."
  384. elog "You should replace it with the actual hostname!"
  385. elog "Please also see the syntax changes to amandahosts."
  386. elog
  387. elog "Please note that this package no longer explicitly depends on"
  388. elog "virtual/inetd, as it supports modes where an inetd is not needed"
  389. elog "(see bug #506028 for details)."
  390. elog "The only exception is when you use the authentication method 'local'."
  391. }
  392. # We have had reports of amanda file permissions getting screwed up.
  393. # Losing setuid, becoming too lax etc.
  394. # ONLY root and users in the amanda group should be able to run these binaries!
  395. amanda_permissions_fix() {
  396. local root="$1"
  397. [ -z "${root}" ] && die "Failed to pass root argument to amanda_permissions_fix!"
  398. local le="/usr/libexec/amanda"
  399. for i in /usr/sbin/amcheck "${le}"/calcsize "${le}"/killpgrp \
  400. "${le}"/rundump "${le}"/runtar "${le}"/dumper \
  401. "${le}"/planner ; do
  402. chown root:${AMANDA_GROUP_NAME} "${root}"/${i}
  403. chmod u=srwx,g=rx,o= "${root}"/${i}
  404. done
  405. }