ChangeLog

# ChangeLog for app-backup/amanda
# Copyright 2000-2008 Gentoo Foundation; Distributed under the GPL v2
# $Header: /var/cvsroot/gentoo-x86/app-backup/amanda/ChangeLog,v 1.36 2008/06/26 01:20:32 robbat2 Exp $

*amanda-2.5.2_p1-r4 (26 Jun 2008)

26 Jun 2008; Robin H. Johnson
+files/amanda-2.5.2_p1-chg-multi.patch,
+files/amanda-2.5.2_p1-fix-asneeded.patch, +amanda-2.5.2_p1-r4.ebuild:
Fix bugs #212970, #192296, #217507. Text dbmode is the only one left
supported by upstream.

08 Feb 2008; Robin H. Johnson metadata.xml:
Change proxyied maintainer email.

09 Oct 2007; Robin H. Johnson amanda-2.4.5.ebuild,
amanda-2.4.5_p1.ebuild, amanda-2.5.1_p3-r1.ebuild,
amanda-2.5.1_p3-r2.ebuild, amanda-2.5.1_p3-r4.ebuild,
amanda-2.5.2_p1.ebuild, amanda-2.5.2_p1-r1.ebuild,
amanda-2.5.2_p1-r2.ebuild, amanda-2.5.2_p1-r3.ebuild:
Fix quoting in all ebuilds.

*amanda-2.5.2_p1-r3 (06 Sep 2007)

06 Sep 2007; Robin H. Johnson
+amanda-2.5.2_p1-r3.ebuild:
Fix problem with env.d generation. If you see errors about some vars during
upgrading, please ignore them.

*amanda-2.5.2_p1-r2 (01 Aug 2007)

01 Aug 2007; Robin H. Johnson
+amanda-2.5.2_p1-r2.ebuild:
Document the custom env.d foo that our Amanda package does to allow users to
customize their install. Add AMANDA_TAR to the list of settings, to allow
users to specify implementation like STar instead of GNU tar.

*amanda-2.5.2_p1-r1 (24 Jul 2007)

24 Jul 2007; Robin H. Johnson
+amanda-2.5.2_p1-r1.ebuild:
The default configuration that was installed did not have the subsitutations
for the user config made to it.

*amanda-2.5.2_p1 (20 Jul 2007)

20 Jul 2007; Robin H. Johnson
+amanda-2.5.2_p1.ebuild:
New upstream version, bump thanks to Stefan G. Weichinger .

20 May 2007; Robin H. Johnson :
Please note that amanda-2.5.2 should NOT be added to the Portage tree.
It has upstream issues, and it's recommended that we wait for 2.5.3
instead.

20 May 2007; Robin H. Johnson metadata.xml:
Add sgw as a proxy developer for Amanda. Please CC him on all Amanda bugs.

*amanda-2.5.1_p3-r4 (10 Apr 2007)

10 Apr 2007; Robin H. Johnson
-amanda-2.5.1_p3-r3.ebuild, +amanda-2.5.1_p3-r4.ebuild:
Bug #173898 - fix IUSE. Bug #173354 - krb4 is being dropped from Gentoo.

09 Apr 2007; Robin H. Johnson amanda-2.4.5.ebuild,
amanda-2.4.5_p1.ebuild, amanda-2.5.1_p3-r1.ebuild,
amanda-2.5.1_p3-r2.ebuild, amanda-2.5.1_p3-r3.ebuild:
Bug #173884, move to doenvd instead of insinto env.d.

*amanda-2.5.1_p3-r3 (07 Apr 2007)

07 Apr 2007; Robin H. Johnson
+amanda-2.5.1_p3-r3.ebuild:
Add support for nearly all other authentication methods - bug #171812, patch
thanks to Stefan G. Weichinger . Also do a cleanup of
several bits of lingering oldness in the ebuild, and ensure that the right
binaries are always locked down setuid properly.

26 Mar 2007; Alec Warner amanda-2.4.5.ebuild,
amanda-2.5.1_p3-r1.ebuild, amanda-2.5.1_p3-r2.ebuild:
Remove dependency on portage: ref bug 162516

*amanda-2.5.1_p3-r2 (08 Mar 2007)

08 Mar 2007; Robin H. Johnson
+amanda-2.5.1_p3-r2.ebuild:
Make sure --with-debugging is always enabled per upstream, to avoid
breakages with tape changers.

07 Mar 2007; Robin H. Johnson
-amanda-2.5.1_p2.ebuild, -amanda-2.5.1_p3.ebuild:
Remove the builds of amanda-2.5.1_p[23] that caused brokenness. You must
upgrade to p3-r1!.

*amanda-2.5.1_p3-r1 (07 Mar 2007)

07 Mar 2007; Robin H. Johnson
+files/amanda-amandahosts-client-2.5.1_p3-r1,
+files/amanda-amandahosts-server-2.5.1_p3-r1,
+files/amanda-inetd.amanda.sample-2.5.1_p3-r1,
+files/amanda-xinetd-2.5.1_p3-r1, +files/example_disklist-2.5.1_p3-r1,
+files/amanda-2.5.1_p3-displayunit.patch, +amanda-2.5.1_p3-r1.ebuild:
Add proper p3 changes from upstream developer Stefan G. Weichinger
(monitor@oops.co.at). This moves the builds to using the new Amanda auth
system. If you use localhost in your disklist you should replace it with the
actual hostname! Please also see the syntax changes to amandahosts. We also
support USE=minimal now to build clients.

*amanda-2.5.1_p3 (05 Mar 2007)

05 Mar 2007; Jeroen Roovers +amanda-2.5.1_p3.ebuild:
Version bump.

24 Jan 2007; Marius Mauch amanda-2.4.5.ebuild,
amanda-2.4.5_p1.ebuild, amanda-2.5.1_p2.ebuild:
Replacing einfo with elog

13 Dec 2006; Jeroen Roovers
+files/amanda-2.5.1_p2-tar-1.16.patch, amanda-2.5.1_p2.ebuild:
Added tar 1.16 patch, added IUSE=minimal, both requested in bug #127725.

*amanda-2.5.1_p2 (12 Dec 2006)

12 Dec 2006; Jeroen Roovers metadata.xml,
+amanda-2.5.1_p2.ebuild:
Version bump (bug #127725).

09 Aug 2006; Brent Baude amanda-2.4.5_p1.ebuild:
Marking amanda-2.4.5_p1 ~ppc64 for bug # 142829

13 Jul 2006; Robin H. Johnson amanda-2.4.5.ebuild,
amanda-2.4.5_p1.ebuild:
Bug #140119, double $D/$D.

14 Jun 2006; Robin H. Johnson metadata.xml:
Update metadata.

27 Apr 2006; Alec Warner files/digest-amanda-2.4.5,
files/digest-amanda-2.4.5_p1, Manifest:
Fixing duff SHA256 digests: Bug # 131293

30 Jan 2006; Robin H. Johnson Manifest:
Manifest fix.

29 Jan 2006; Marcus D. Hanwell amanda-2.4.5_p1.ebuild:
Dependency update: media-gfx/gnuplot -> sci-visualization/gnuplot.

29 Jan 2006; Marcus D. Hanwell amanda-2.4.5.ebuild:
Dependency update: media-gfx/gnuplot -> sci-visualization/gnuplot.

31 Dec 2005; Diego Pettenò amanda-2.4.5.ebuild,
amanda-2.4.5_p1.ebuild:
Use -1 instead of /bin/false as default shell.

12 Dec 2005; Robin H. Johnson
-amanda-2.4.4-r3.ebuild, -amanda-2.4.4_p2.ebuild,
-amanda-2.4.4_p2-r1.ebuild, -amanda-2.4.4_p2-r2.ebuild,
-amanda-2.4.4_p3.ebuild:
Remove old versions of amanda, 2.4.5 has been in tree for 6 months.

*amanda-2.4.5_p1 (12 Dec 2005)

12 Dec 2005; Robin H. Johnson
+amanda-2.4.5_p1.ebuild:
Version bump. Security fixes in fd handling.

14 Aug 2005; Michael Hanselmann amanda-2.4.5.ebuild:
Stable on ppc.

12 Aug 2005; Robin H. Johnson amanda-2.4.5.ebuild:
Stable 2.4.5 on x86.

05 Aug 2005; Aron Griffis amanda-2.4.4_p3.ebuild,
amanda-2.4.5.ebuild:
Add -j1 to emake cmdline. This package doesn't build reliably when make is
parallelized

04 Jul 2005; Robin H. Johnson
+files/patch-tar-1.14.90, +files/amanda-2.4.5-4tb-holding-disk.patch,
+files/amanda-2.4.5-amverify-loop-detect.patch,
+files/amanda-2.4.5-samba-printf.patch, +files/amanda-amandahosts,
+files/amanda-cron, +files/amanda-devfs,
+files/amanda-inetd.amanda.sample, +files/amanda-profile,
+files/amanda-xinetd, +files/example_amanda.conf, +files/example_disklist,
+files/example_global.conf, +metadata.xml, +amanda-2.4.4-r3.ebuild,
+amanda-2.4.4_p2.ebuild, +amanda-2.4.4_p2-r1.ebuild,
+amanda-2.4.4_p2-r2.ebuild, +amanda-2.4.4_p3.ebuild, +amanda-2.4.5.ebuild:
Moved from app-admin/amanda to app-backup/amanda.

*amanda-2.4.5 (08 Jun 2005)

08 Jun 2005; Robin H. Johnson
+files/amanda-2.4.5-4tb-holding-disk.patch,
+files/amanda-2.4.5-amverify-loop-detect.patch,
+files/amanda-2.4.5-samba-printf.patch, +amanda-2.4.5.ebuild:
Amanda version bump to 2.4.5. Fixed bugs 91084, 83829, 51370.

21 Apr 2005; Simon Stelling amanda-2.4.4_p3.ebuild:
stable on amd64

18 Apr 2005; Michael Hanselmann
amanda-2.4.4_p3.ebuild:
Stable on ppc.

15 Mar 2005; Ciaran McCreesh amanda-2.4.4-r3.ebuild,
amanda-2.4.4_p2.ebuild, amanda-2.4.4_p2-r1.ebuild,
amanda-2.4.4_p2-r2.ebuild, amanda-2.4.4_p3.ebuild:
Dependency update: sys-apps/mtx -> sys-block/mtx.

18 Dec 2004; Simon Stelling amanda-2.4.4_p3.ebuild:
removed myconf=" `use_with pic`" line, it's apparently not needed and
prevented from building amanda on amd64

10 Dec 2004; Andrej Kacian amanda-2.4.4-r3.ebuild,
amanda-2.4.4_p2-r1.ebuild, amanda-2.4.4_p2-r2.ebuild,
amanda-2.4.4_p2.ebuild, amanda-2.4.4_p3.ebuild:
Changed mail-client/mailx to virtual/mailx in DEPEND. See bug #73972.

24 Nov 2004; Robin H. Johnson amanda-2.4.4_p3.ebuild:
Fix bug #66842 properly.

21 Nov 2004; Robin H. Johnson
+files/patch-tar-1.14.90:
Fix bugs #51370, #66842, #69105.

05 Oct 2004; Pieter Van den Abeele
amanda-2.4.4-r3.ebuild, amanda-2.4.4_p2-r1.ebuild:
Masked amanda-2.4.4_p2-r1.ebuild stable for ppc

05 Oct 2004; Pieter Van den Abeele
amanda-2.4.4-r3.ebuild:
Masked amanda-2.4.4-r3.ebuild stable for ppc

*amanda-2.4.4_p3 (15 Jul 2004)

15 Jul 2004; Robin H. Johnson amanda-2.4.4_p3.ebuild:
new upstream version.

*amanda-2.4.4_p2-r2 (15 Jul 2004)

15 Jul 2004; Robin H. Johnson
amanda-2.4.4_p2-r2.ebuild:
fix bug #56931.

04 Jul 2004; Robin H. Johnson
amanda-2.4.4_p2-r1.ebuild, files/amanda-profile:
fix bug #52941, #52944.

30 May 2004; Robin H. Johnson amanda-2.4.4-r3.ebuild,
amanda-2.4.4_p2-r1.ebuild, amanda-2.4.4_p2.ebuild:
mailx move

29 May 2004; Robin H. Johnson
amanda-2.4.4_p2-r1.ebuild:
stable on x86 (only a tiny change from -r0)

*amanda-2.4.4_p2-r1 (29 May 2004)

29 May 2004; Robin H. Johnson
amanda-2.4.4_p2-r1.ebuild, amanda-2.4.4_p2.ebuild, files/amanda-devfs:
add note for tape changer, and enable qde support.

20 Apr 2004; Daniel Black amanda-2.4.4-r3.ebuild,
amanda-2.4.4_p2.ebuild:
QA - removed runtime dependance on automake and autoconf

*amanda-2.4.4_p2 (13 Apr 2004)

13 Apr 2004; Robin H. Johnson amanda-2.4.4_p2.ebuild,
metadata.xml:
add new version as per bug #38770, block out xfs for sparc only, so sparc can
use amanda too! Add metadata.xml.

31 Mar 2004; Daniel Ahlberg amanda-2.4.4-r3.ebuild:
Adding amd64 keyword, closing #46209.

15 Mar 2004; Michael Sterrett amanda-2.4.4-r3.ebuild:
don't assign default to S

15 Mar 2004; Michael Sterrett amanda-2.4.4-r1.ebuild,
amanda-2.4.4-r2.ebuild, amanda-2.4.4.ebuild:
clean extra ebuilds

*amanda-2.4.4-r3 (07 Jan 2004)

07 Jan 2004; Robin H. Johnson amanda-2.4.4-r1.ebuild,
amanda-2.4.4-r2.ebuild, amanda-2.4.4-r3.ebuild, amanda-2.4.4.ebuild:
fix bug #37400 with a better default

24 Dec 2003; Robin H. Johnson amanda-2.4.4-r1.ebuild,
amanda-2.4.4-r2.ebuild, amanda-2.4.4.ebuild:
fix bug #36316.

09 Dec 2003; Jason Wever amanda-2.4.4-r1.ebuild,
amanda-2.4.4-r2.ebuild, amanda-2.4.4.ebuild:
Masked on sparc as it needs xfsdump and xfs isn't available on sparc atm.

28 Nov 2003; Robin H. Johnson amanda-2.4.4-r1.ebuild,
amanda-2.4.4-r2.ebuild:
another typo fix

28 Nov 2003; Robin H. Johnson amanda-2.4.4-r2.ebuild:
fix minor blip in how i processed vars

*amanda-2.4.4-r2 (13 Nov 2003)

13 Nov 2003; Robin H. Johnson amanda-2.4.4-r2.ebuild:
fix amanda depend glitches per bug #33381

06 Nov 2003; Robin H. Johnson amanda-2.4.4-r1.ebuild,
amanda-2.4.4.ebuild:
: instead of . for chown

10 Jul 2003; Robin H. Johnson amanda-2.4.4-r1.ebuild:
Marking as stable on x86 as it works in a production environment for me.

10 Jul 2003; Robin H. Johnson amanda-2.4.4-r1.ebuild:
Fix bug #24158
Move the amandahosts file to /etc/amanda, and provide a symlink to it.

08 Jul 2003; Robin H. Johnson amanda-2.4.4-r1.ebuild:
Fix userpriv+sandbox issue in ebuild.

*amanda-2.4.4-r1 (08 Jul 2003)

08 Jul 2003; Robin H. Johnson amanda-2.4.4-r1.ebuild,
files/amanda-amandahosts, files/amanda-inetd.amanda.sample,
files/amanda-profile, files/amanda-xinetd:
Large improvements to the ebuild configuration system, using the same
environment variables. Now we also preserve them in an env.d file, which also
adds the CONFIG_PROTECT entry I missed before. Also update many config files
to be dynamically filled in from the env variables.

*amanda-2.4.4 (26 Jun 2003)

26 June 2003; Robin H. Johnson Manifest,
files/amanda-devfs, files/example_disklist, files/amanda-cron,
files/amanda-xinetd, files/amanda-profile, files/example_amanda.conf,
files/amanda-amandahosts, files/digest-amanda-2.4.4,
files/example_global.conf, amanda-2.4.4.ebuild, ChangeLog:
Initial import. Russell Adams submitted a reasonable
ebuild for amanda in bug #19403. I have merged the good elements of all
available amanda ebuild into this new ebuild. Bugs #10782, #13948, #16118,
#18466, #19403.

Manifest

AUX amanda-2.4.5-4tb-holding-disk.patch 457 RMD160 1537baf1acaf10a74b45371df85a921d2ac6a288 SHA1 10803145fe25c7345b6d5612f10e960e642f5a9b SHA256 96f07eb4ed85e6e634baa6130c932d17524e8c4ad0a6e2b46590f4df492ffaaa
AUX amanda-2.4.5-amverify-loop-detect.patch 1108 RMD160 617fc3f5db4ae20620d9d85a2e7793b0e96d454e SHA1 9ea134508f64f827e1821a3ee1d340a4f2ff0699 SHA256 f2222c85a95f0cca792d7611503a1685e3ff17b3052be995eb68cc4fa12ecb45
AUX amanda-2.4.5-samba-printf.patch 498 RMD160 1e445c04a59362a25cd35ac7800c7ed95829c9ff SHA1 e8ccee9e6446243a23c26698cc5787fcfcd6fc3a SHA256 e9a824c233fb2c167a66de4b70fe0b5288008eec0c49941db4ff3f0fdebd5f7a
AUX amanda-2.5.1_p2-tar-1.16.patch 296 RMD160 6851b8681056bde2101c9f4e16424d6de49acf30 SHA1 9a678cd83452de4019c90810e791cdcf8772bfc9 SHA256 f1bd6453e2d61f94ee63bee2c6d455b64810a0cb934f1c004234a01ec7dfa015
AUX amanda-2.5.1_p3-displayunit.patch 931 RMD160 c2ff2db44fde3c489a6bb660c17f44045f223f78 SHA1 0e2b9d3c4438002510e36d428bdc9deff6086c0d SHA256 7631a39667a67eed8ede8c1828c5d02657a8b114584fb224bd8b6f9058330e6b
AUX amanda-2.5.2_p1-chg-multi.patch 611 RMD160 f46873aee5318d346accec3bb771b28b2b0b06da SHA1 9cbe148a6d069072eafa81bdf67272e9b5d02f50 SHA256 0b81c541ea331324a070553236a5a893654f7f5155c53939c7fba56ad09ba4fd
AUX amanda-2.5.2_p1-fix-asneeded.patch 951 RMD160 2cd9bf9e4fd8dd63edba8ac35955af96a8841566 SHA1 daa9a25d73f1baf1548c9618237209e62253d28c SHA256 7e238d26ef8ffe62d99a8aa22e2066b0c261cd92796383a5a0612af9c4978593
AUX amanda-amandahosts 339 RMD160 534c47134ff53faac312ee21c4b5f27752452cce SHA1 8b8a3245681f6a203f2b60a64ee0ece2d4405c11 SHA256 52825d4feba9a74d42740e9807c2a563e52e08ae5c55092a54033dc6d49f517c
AUX amanda-amandahosts-client-2.5.1_p3-r1 343 RMD160 f5526644c7c9ec517f648b374d35dcbecd73de97 SHA1 c3e1e6a800b5b9ae26e218730d60817f8ddd8847 SHA256 26a446ae74aafcb90a05bb66430b70e35c5536ee9e42137abc7925bf1175e84e
AUX amanda-amandahosts-server-2.5.1_p3-r1 340 RMD160 0680e414089f5bec2540404f8d74708602d703b1 SHA1 8920c2adb0a9a0e55eb15238630d93e9d54433a2 SHA256 9e07c28b344ff42c6a8f31af2d9dac780a00ff28e40850a0b115e26990ecc0e7
AUX amanda-cron 419 RMD160 97b13e25afc88d64f0320a08189b4e7b4c7fa054 SHA1 ff4835e78c7a9abd10b8cd79c1d9d744a2782af1 SHA256 17e1a36c21264a9b254e64e9b7529d70402acd40772d158795490ac5fc08b01a
AUX amanda-devfs 349 RMD160 8ea1eb8f64c9e8238e95b92b5f6524e3170165d9 SHA1 f280b06b7a3ad205637daedaf170bf38f83918f0 SHA256 f21584bc65947e3ac671f89af04966aafd751360ef0465ce8ca1a249b0ee253a
AUX amanda-inetd.amanda.sample 194 RMD160 070aea45f4be953906ba8e91e9144bec8f78aad7 SHA1 67848d531fe7280375d10bd8bd12d00ab333a70f SHA256 a08952b4468ecc80fb8e140aca5d4fb8b849c7d5da24a2b1c550551b50fbee15
AUX amanda-inetd.amanda.sample-2.5.1_p3-r1 305 RMD160 72306e99703218b2b304c024e3bd624a7ea6aa7e SHA1 8bbdcee99527ec9ab5b4e7bd7afbc5b9a39d8199 SHA256 49bf1548ca8e3e640151b79a5c827ea3211bafb4036aa67572b7096b46ac6014
AUX amanda-profile 49 RMD160 2958487df40529f0d692f02f2343b633d34853a6 SHA1 80da3900ace9b4069b7cae11cfc5da5a6670f010 SHA256 5781459910f0f72b1bfe15d758f17e7d6c8e33b5856b62a8d5cedf64a2917e76
AUX amanda-xinetd 1502 RMD160 d09e925fce9a8a61be12735dd6d3fa0abd7129f5 SHA1 1f33fc86553b4c5434725cf736620dbaee9f25ac SHA256 d6f411ab0bfaadf03060a48bf29d68a7a039db6cea8f25b8b28ca9d01168a6aa
AUX amanda-xinetd-2.5.1_p3-r1 1558 RMD160 c23a1a86062dbe8d55b891c1bd7bba9186ba3036 SHA1 dbe41cf8a7969f77ba87e9125a2e87f719532988 SHA256 4952a00d0ece67da7cfb648baa2c758aebcebf5303e326e5aa30e04a57db8b6d
AUX example_amanda.conf 635 RMD160 1214396161457bb71cd6a31e23d6cb78482e20e7 SHA1 4368b8d7908e49963bc144c68119a32c047877ff SHA256 a1b0520fb0fca0f4146c59589987fffa637a0ce643a91d6d71dde6f538faf325
AUX example_disklist 55 RMD160 42e25ba19c331578cb6472926048defc7196ab2c SHA1 3d8ae2e4c17c16e216c6a9a5401dc87947ab24df SHA256 ce5fe7642fe0cbca7968007fb6fce393500eee3525aed97465d0b8b529941ef8
AUX example_disklist-2.5.1_p3-r1 177 RMD160 e9f8f4dda3d7f022e1e60b556a713a9b891b5845 SHA1 8d35a5fe8ba9f3f30659684e17bae0e69d51196b SHA256 bc0388e7de0cc36888d3b27430b4a6b138dd39c77263fdc53dfee9f0b93142f8
AUX example_global.conf 1377 RMD160 009e5039f94938c8521e58236da6027d7ec33766 SHA1 2e75914f18ed478c5cd1cd1bb9b0570fa2d20e82 SHA256 5223d061cd160b241e0d1fad1e328d241387fecb753e797d2e216f77d97a8808
AUX patch-tar-1.14.90 984 RMD160 8b5fdfbd84450a0b462ca64b4ff3cfaf0d697beb SHA1 2c88f1ddff0c2efce109894d046ec419c1da5c84 SHA256 9aa5da6b3ee484daf2d762ec51a5e3c6f329d545b225c3ee088265d4efdddda2
DIST amanda-2.4.5.tar.gz 1541761 RMD160 f7d57709de0b620e7b752c9a9273d501ab61084b SHA1 84bf1f2707b0d0f4a462fa19b8c5b8b8af5ddcbf SHA256 79f9d313b08220f9edb6557aabd75623a80b2adb3192cf01bbb0ca7f3a2223ce
DIST amanda-2.4.5p1.tar.gz 1557400 RMD160 269089edd9422800be89eb96186d54c544165a55 SHA1 ab4cc62037fb726d5480c5c54a715ce2c231bf4e SHA256 71e2716f1098f5ac6633e02e252e048ce0e76f880e2ddb531d9d261ad263fe64
DIST amanda-2.5.1p3.tar.gz 1905664 RMD160 90462c7d65736c5920bc2782e8666a34b3f32026 SHA1 c18e79029f7472c4eddb9816e74e324e350ff6ae SHA256 64e60f323a89a8a064936334335cfde6cf41e6127f7f8b1c9b6de2d393de3f72
DIST amanda-2.5.2p1.tar.gz 1967240 RMD160 31a81a7c5c0d953a6dffa575a7c3edc14d41f236 SHA1 0969376590a93b2c060dbe9d2573bf335614a4c2 SHA256 412d1fe98e8c23f2949c0fcbe94b355640c973b04c38ba444cf989641ace2640
EBUILD amanda-2.4.5.ebuild 12142 RMD160 20f68b2b396b8f61b22e40c3d145ca42f9b89bd1 SHA1 23e835e708e8c9e0578e0d6382bf3ec359192d1b SHA256 4c2c79e8e3903c166f556547dae3274b7d53f000d8442253d29998b16d593c1e
EBUILD amanda-2.4.5_p1.ebuild 12514 RMD160 dc2830ab50d862aa9ae1c0807fa7c2aa52ceb7ac SHA1 bda2d8e792c5e116f343f110cd9bdbbf1500f0f0 SHA256 1923426ff0f07e9d6066fc2d070fb78c9e18c05fca60643b5a3c92fea1d28f63
EBUILD amanda-2.5.1_p3-r1.ebuild 13707 RMD160 69e6363be0b4663f45d421a5d631b131a61ac3d8 SHA1 d45ae4b240bcf54e2110714733fd65e3446f9c56 SHA256 eb7f9b13741c72a71add97182f0f306649e6b9a57e40c8588d0bf54b58378f1d
EBUILD amanda-2.5.1_p3-r2.ebuild 13975 RMD160 5b263849b2c99056e24d3b93b7b678d7a81457de SHA1 96e6b6f0dd14ad528ba99b5ff36c50ac18934867 SHA256 0ebf8495dfb1cede03a62e02ec40c4802729761bbd3816eb18d50943b80757d2
EBUILD amanda-2.5.1_p3-r4.ebuild 15212 RMD160 cb8e86bd2dd30dbf4bbaf43fd1acdabe16269511 SHA1 6a21c1156b94ce1734759751f84d91423d64cc62 SHA256 438bfb2ca74a03d7443eb0f527ed7c7c146484cac7b18478e43f4d485aa3d748
EBUILD amanda-2.5.2_p1-r1.ebuild 14616 RMD160 f2d74e834ee06b155111c58b4e45be23fc7192ed SHA1 153eaba93fd85b0f9fd6330ae7ca667063be5e06 SHA256 2041814616f8070ce9b65ed757271ea05fd5d3b58cd892776246bfe0bb0f401e
EBUILD amanda-2.5.2_p1-r2.ebuild 15094 RMD160 0f3d7a5be3888738db3b3008dc1f2dbdbcd17902 SHA1 74178ffa079862fd40cd1ec395aac0328ae3e7c0 SHA256 235c46289769f0969cf899a8e6f0aa77d8c7af8a9cc414e9cd6ce01cf8b39af9
EBUILD amanda-2.5.2_p1-r3.ebuild 15292 RMD160 b251bf0057344965a74c70ec7413cac997cc7b43 SHA1 491ab727fa540c5efdc5dcee0b9e83f239e64f21 SHA256 4018fd2b9f3e871c3260fe3b6d742c6e1ad1103723fb312f6229a17ebcc7cbee
EBUILD amanda-2.5.2_p1-r4.ebuild 15710 RMD160 6489fa4e923de79280105a8a83bd277546ef887c SHA1 7127475135ba3840380ea4f642569e001534e71f SHA256 73701a48ff778475147454eb21844c5901df85658cb63cffe8ca06bfcaf5346f
EBUILD amanda-2.5.2_p1.ebuild 14606 RMD160 1ff28ebbaac144774f686821532069fcadbf322a SHA1 aeb87bff1bea11f70dcd6fde321aadb6912e2be5 SHA256 a47a44484d2f6bf493a97d2227d499e48e9a18992c7b8e8ebd447490de689e50
MISC ChangeLog 13542 RMD160 ed646eace1b3545e54e475e526dc48c06bff2791 SHA1 724984f7834e8bd9925296bd424e97e19db62434 SHA256 0feb01c4994739ae95ac98057907115172f989d7e1b3bc3ccf63443708a3034b
MISC metadata.xml 477 RMD160 6d63b87ada6015d0e7b5c3cd7107957410c0bce3 SHA1 eb0e624cbac47004d9f7efad1896be0550e89723 SHA256 3b09c1a206021c74f8e2310763c3559429cffc83c1d3cac4b4db0524642ea278

amanda-2.4.5.ebuild

# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-backup/amanda/amanda-2.4.5.ebuild,v 1.13 2007/10/09 09:23:15 robbat2 Exp $

inherit eutils

DESCRIPTION="The Advanced Maryland Automatic Network Disk Archiver"
HOMEPAGE="http://www.amanda.org/"
SRC_URI="mirror://sourceforge/amanda/${P/_/}.tar.gz"
LICENSE="as-is"
SLOT="0"
KEYWORDS="amd64 ppc ~sparc x86"
RDEPEND="sys-libs/readline
virtual/inetd
app-arch/mt-st
sci-visualization/gnuplot
sys-apps/gawk
app-arch/tar
dev-lang/perl
sys-block/mtx
app-arch/dump
virtual/mailx
samba? ( net-fs/samba )
berkdb? ( sys-libs/db )
gdbm? ( sys-libs/gdbm )
!sparc? ( xfs? ( sys-fs/xfsdump ) )"

DEPEND="${RDEPEND}
sys-devel/autoconf
sys-devel/automake"

IUSE="berkdb debug gdbm samba xfs"

S="${WORKDIR}/${P/_/}"
MYFILESDIR="${WORKDIR}/files"
MYTMPDIR="${WORKDIR}/tmp"
ENVDIR="/etc/env.d"
ENVDFILE="97amanda"
TMPENVFILE="${MYTMPDIR}/${ENVDFILE}"

amanda_variable_setup() {

# Setting vars
local currentamanda

# Grab the current settings
currentamanda="$(set | egrep "^AMANDA_" | xargs)"
use debug && einfo "Current settings: ${currentamanda}"
#for i in ${currentamanda}; do
# eval `eval echo ${i}`
# echo "Setting: ${i}"
#done;

# First we set the defaults
[ -z "${AMANDA_GROUP_GID}" ] && AMANDA_GROUP_GID=87
[ -z "${AMANDA_GROUP_NAME}" ] && AMANDA_GROUP_NAME=amanda
[ -z "${AMANDA_USER_NAME}" ] && AMANDA_USER_NAME=amanda
[ -z "${AMANDA_USER_UID}" ] && AMANDA_USER_UID=87
[ -z "${AMANDA_USER_SH}" ] && AMANDA_USER_SH=-1
[ -z "${AMANDA_USER_HOMEDIR}" ] && AMANDA_USER_HOMEDIR=/var/spool/amanda
[ -z "${AMANDA_USER_GROUPS}" ] && AMANDA_USER_GROUPS="${AMANDA_GROUP_NAME}"
# This installs Amanda, with the server. However, it could be a client,
# just specify an alternate server name in AMANDA_SERVER.
[ -z "${AMANDA_SERVER}" ] && AMANDA_SERVER="${HOSTNAME}"
[ -z "${AMANDA_SERVER_TAPE}" ] && AMANDA_SERVER_TAPE="${AMANDA_SERVER}"
[ -z "${AMANDA_SERVER_INDEX}" ] && AMANDA_SERVER_INDEX="${AMANDA_SERVER}"
[ -z "${AMANDA_TAR_LISTDIR}" ] && AMANDA_TAR_LISTDIR=${AMANDA_USER_HOMEDIR}/tar-lists
[ -z "${AMANDA_CONFIG_NAME}" ] && AMANDA_CONFIG_NAME=DailySet1
[ -z "${AMANDA_TMPDIR}" ] && AMANDA_TMPDIR=${AMANDA_USER_HOMEDIR}/tmp
# These are left empty by default
[ -z "${AMANDA_PORTS_UDP}" ] && AMANDA_PORTS_UDP=
[ -z "${AMANDA_PORTS_TCP}" ] && AMANDA_PORTS_TCP=
[ -z "${AMANDA_PORTS_BOTH}" ] && AMANDA_PORTS_BOTH=
[ -z "${AMANDA_PORTS}" ] && AMANDA_PORTS=

# This one is a little more complicated
# The priority list is this:
# 1. 'Berkely DB style' (only if USE="berkdb")
# 2. 'GDBM style' (only if USE="gdbm")
# 3. 'Text style'
[ -z "${AMANDA_DBMODE}" ] && use berkdb && AMANDA_DBMODE=db
[ -z "${AMANDA_DBMODE}" ] && use gdbm && AMANDA_DBMODE=gdbm
[ -z "${AMANDA_DBMODE}" ] && AMANDA_DBMODE=text

# Now pull in the old stuff
if [ -f "${ENVDIR}/${ENVDFILE}" ]; then
# We don't just source it as we don't want everything in there.
eval $(egrep "^AMANDA_" ${ENVDIR}/${ENVDFILE})
fi

# Re-apply the new settings if any
[ -n "${currentamanda}" ] && eval `echo "${currentamanda}"`

}

pkg_setup() {
# Now add users if needed
amanda_variable_setup
enewgroup "${AMANDA_GROUP_NAME}" "${AMANDA_GROUP_GID}"
enewuser "${AMANDA_USER_NAME}" "${AMANDA_USER_UID}" "${AMANDA_USER_SH}" "${AMANDA_USER_HOMEDIR}" "${AMANDA_USER_GROUPS}"
}

src_unpack() {
unpack "${A}"
# Fix glitch with recognizing tar-1.14.90
EPATCH_OPTS="-p1 -d ${S}" epatch "${FILESDIR}"/patch-tar-1.14.90 || die "Failed to add tar support patch"
epatch "${FILESDIR}"/${P}-4tb-holding-disk.patch || die "Failed to patch for 4TB holding disks"
EPATCH_OPTS="-p1 -d ${S}" epatch "${FILESDIR}"/${P}-samba-printf.patch || die "Failed to patch samba printf bug"
EPATCH_OPTS="-p1 -d ${S}" epatch "${FILESDIR}"/${P}-amverify-loop-detect.patch || die "Failed to patch amverify loop bug"
# now the real fun
amanda_variable_setup
# places for us to work in
mkdir -p "${MYFILESDIR}" "${MYTMPDIR}"
# Now we store the settings we just created
set | egrep "^AMANDA_" > "${TMPENVFILE}"
}

src_compile() {
# fix bug #36316
addpredict /var/cache/samba/gencache.tdb

[ ! -f "${TMPENVFILE}" ] && die "Variable setting file (${TMPENVFILE}) should exist!"
source "${TMPENVFILE}"
local myconf
cd "${S}"

einfo "Using '${AMANDA_DBMODE}' style database"
myconf="${myconf} --with-db=${AMANDA_DBMODE}"
einfo "Using ${AMANDA_SERVER_TAPE} for tape server."
myconf="${myconf} --with-tape-server=${AMANDA_SERVER_TAPE}"
einfo "Using ${AMANDA_SERVER_INDEX} for index server."
myconf="${myconf} --with-index-server=${AMANDA_SERVER_TAPE}"
einfo "Using ${AMANDA_USER_NAME} for amanda user."
myconf="${myconf} --with-user=${AMANDA_USER_NAME}"
einfo "Using ${AMANDA_GROUP_NAME} for amanda group."
myconf="${myconf} --with-group=${AMANDA_GROUP_NAME}"
einfo "Using ${AMANDA_TAR_LISTDIR} as tar listdir."
myconf="${myconf} --with-gnutar-listdir=${AMANDA_TAR_LISTDIR}"
einfo "Using ${AMANDA_CONFIG_NAME} as default config name."
myconf="${myconf} --with-config=${AMANDA_CONFIG_NAME}"
einfo "Using ${AMANDA_TMPDIR} as Amanda temporary directory."
myconf="${myconf} --with-tmpdir=${AMANDA_TMPDIR}"

if [ -n "${AMANDA_PORTS_UDP}" ] && [ -n "${AMANDA_PORTS_TCP}" ] && [ -z "${AMANDA_PORTS_BOTH}" ] ; then
eerror "If you want _both_ UDP and TCP ports, please use only the"
eerror "AMANDA_PORTS environment variable for identical ports, or set"
eerror "AMANDA_PORTS_BOTH."
die "Bad port setup!"
fi
if [ -n "${AMANDA_PORTS_UDP}" ]; then
einfo "Using UDP ports ${AMANDA_PORTS_UDP/,/-}"
myconf="${myconf} --with-udpportrange=${AMANDA_PORTS_UDP}"
fi
if [ -n "${AMANDA_PORTS_TCP}" ]; then
einfo "Using TCP ports ${AMANDA_PORTS_TCP/,/-}"
myconf="${myconf} --with-tcpportrange=${AMANDA_PORTS_TCP}"
fi
if [ -n "${AMANDA_PORTS}" ]; then
einfo "Using ports ${AMANDA_PORTS/,/-}"
myconf="${myconf} --with-portrange=${AMANDA_PORTS}"
fi

# Extras
# Speed option
myconf="${myconf} --with-buffered-dump"
# Debug
myconf="${myconf} `use_with debug debugging`"
# Where to put our files
myconf="${myconf} --localstatedir=${AMANDA_USER_HOMEDIR}"

# Samba support
use samba && myconf="${myconf} --with-smbclient=/usr/bin/smbclient" || myconf="${myconf} --without-smbclient"

# Force the correct TAR
myconf="${myconf} --with-gnutar=/bin/tar"

econf ${myconf} || die "econf failed!"
emake -j1 || die "emake failed!"

# Compile the tapetype program too
# This is deprecated, use amtapetype instead!
# cd tape-src
# emake tapetype || die "emake tapetype failed!"

# Only needed if you we do versioning
#dosed "s,/usr/local/bin/perl,/usr/bin/perl," ${S}/contrib/set_prod_link.pl
#perl ${S}/contrib/set_prod_link.pl

}

src_install() {
[ ! -f "${TMPENVFILE}" ] && die "Variable setting file (${TMPENVFILE}) should exist!"
source ${TMPENVFILE}

einfo "Doing stock install"
emake -j1 DESTDIR="${D}" install || die

# Prepare our custom files
einfo "Building custom configuration files"
cp "${FILESDIR}"/amanda-* "${MYFILESDIR}"
local i # our iterator
local sedexpr # var for sed expr
sedexpr=''
for i in AMANDA_GROUP_GID AMANDA_GROUP_NAME AMANDA_USER_NAME AMANDA_USER_UID AMANDA_USER_SH AMANDA_USER_HOMEDIR AMANDA_USER_GROUPS AMANDA_SERVER AMANDA_SERVER_TAPE AMANDA_SERVER_INDEX AMANDA_TAR_LISTDIR AMANDA_CONFIG_NAME AMANDA_TMPDIR AMANDA_PORTS_UDP AMANDA_PORTS_TCP AMANDA_PORTS_BOTH AMANDA_PORTS; do
local val
eval "val=\"\${${i}}\""
sedexpr="${sedexpr}s|__${i}__|${val}|g;"
done
#einfo "Compiled SED expression: '${sedexpr}'"

# now apply the sed expr
for i in "${FILESDIR}"/amanda-* ; do
local filename
filename="`basename ${i}`"
#einfo "Applying compiled SED expression to ${filename}"
sed -re "${sedexpr}" <"${i}" >"${MYFILESDIR}"/${filename}
done

# Build the envdir file
# Don't forget this..
einfo "Building environment file"
local t
t="${MYFILESDIR}"/${ENVDFILE}
echo "# These settings are what was present in the environment when this" >>"${t}"
echo "# Amanda was compiled. Changing anything below this comment will" >>"${t}"
echo "# have no effect on your application, but it merely exists to" >>"${t}"
echo "# preserve them for your next emerge of Amanda" >>"${t}"
cat "${TMPENVFILE}" | sed "s,=\$,='',g" >>"${t}"

into /usr

# Depreacted, use amtapetype instead
#einfo "Installing tapetype utility"
#newsbin tape-src/tapetype tapetype

# docs
einfo "Installing documentation"
dodoc AUTHORS C* INSTALL NEWS README
# Clean up some bits
dodoc "${D}"/usr/share/amanda/*
rm -rf "${D}"/usr/share/amanda
# our inetd sample
einfo "Installing standard inetd sample"
dodoc "${MYFILESDIR}"/amanda-inetd.amanda.sample
# Stock extra docs
docinto docs
dodoc "${S}"/docs/*
# Labels
einfo "Installing labels"
docinto labels
dodoc "${S}"/example/3hole.ps
dodoc "${S}"/example/8.5x11.ps
dodoc "${S}"/example/DIN-A4.ps
dodoc "${S}"/example/DLT.ps
dodoc "${S}"/example/EXB-8500.ps
dodoc "${S}"/example/HP-DAT.ps
# Amanda example configs
einfo "Installing example configurations"
docinto example
dodoc "${S}"/example/*
docinto example1
newdoc "${FILESDIR}"/example_amanda.conf amanda.conf
newdoc "${FILESDIR}"/example_disklist disklist
newdoc "${FILESDIR}"/example_global.conf global.conf
docinto example2
newdoc "${S}"/example/amanda.conf amanda.conf
newdoc "${S}"/example/disklist disklist
# Compress it all
prepalldocs

# Just make sure it exists for XFS to work...
use !sparc && use xfs && keepdir /var/xfsdump/inventory

insinto /etc/amanda
einfo "Installing .amandahosts File for ${AMANDA_USER_NAME} user"
newins "${MYFILESDIR}"/amanda-amandahosts amandahosts
dosym /etc/amanda/amandahosts ${AMANDA_USER_HOMEDIR}/.amandahosts
insinto ${AMANDA_USER_HOMEDIR}
einfo "Installing .profile for ${AMANDA_USER_NAME} user"
newins "${MYFILESDIR}"/amanda-profile .profile

einfo "Installing Sample Daily Cron Job for Amanda"
CRONDIR=/etc/cron.daily/
exeinto ${CRONDIR}
newexe "${MYFILESDIR}"/amanda-cron amanda
# Not excetuable by default
fperms 644 ${CRONDIR}/amanda

insinto /etc/amanda/${AMANDA_CONFIG_NAME}
keepdir /etc/amanda
keepdir /etc/amanda/${AMANDA_CONFIG_NAME}

local i
for i in ${AMANDA_USER_HOMEDIR} ${AMANDA_TAR_LISTDIR} ${AMANDA_TMPDIR} ${AMANDA_TMPDIR}/dumps ${AMANDA_USER_HOMEDIR}/${AMANDA_CONFIG_NAME} /etc/amanda /etc/amanda/${AMANDA_CONFIG_NAME}; do
einfo "Securing directory (${i})"
dodir ${i}
keepdir ${i}
fowners ${AMANDA_USER_NAME}:${AMANDA_GROUP_NAME} ${i}
fperms 700 ${i}
done

# DevFS
einfo "Installing DevFS config file"
insinto /etc/devfs.d
newins "${MYFILESDIR}"/amanda-devfs amanda

# Env.d
einfo "Installing environment config file"
doenvd "${MYFILESDIR}"/${ENVDFILE}

# Installing Amanda Xinetd Services Definition
einfo "Installing xinetd service file"
insinto /etc/xinetd.d
newins "${MYFILESDIR}"/amanda-xinetd amanda

}

pkg_postinst() {
[ ! -f "${TMPENVFILE}" ] && die "Variable setting file (${TMPENVFILE}) should exist!"
source "${TMPENVFILE}"
local i
for i in amandates dumpdates; do
einfo "Creating inital Amanda file (${i})"
touch "${ROOT}"/etc/${i}
chown ${AMANDA_USER_NAME}:${AMANDA_GROUP_NAME} "${ROOT}"/etc/${i}
chmod 600 "${ROOT}"/etc/${i}
done

elog "You should configure Amanda in /etc/amanda now."
elog
elog "If you use xinetd, Don't forget to check /etc/xinetd.d/amanda"
elog "and restart xinetd afterwards!"
elog
elog "Otherwise, please look at /usr/share/doc/${P}/inetd.amanda.sample"
elog "as an example of how to configure your inetd."
elog
elog "NOTICE: If you need raw acces to partitions you need to add the"
elog "amanda user to the 'disk' group and uncomment following lines in"
elog "your /etc/devfs.d/amanda:"
elog "SCSI:"
elog "REGISTER ^scsi/host.*/bus.*/target.*/lun.*/part[0-9] PERMISSIONS root.disk 660"
elog "IDE:"
elog "REGISTER ^ide/host.*/bus.*/target.*/lun.*/part[0-9] PERMISSIONS root.disk 660"
elog
elog "NOTICE: If you have a tape changer, also uncomment the following"
elog "REGISTER ^scsi/host.*/bus.*/target.*/lun.*/generic PERMISSIONS root.disk 660"
}

amanda-2.4.5_p1.ebuild

# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-backup/amanda/amanda-2.4.5_p1.ebuild,v 1.9 2007/10/09 09:23:15 robbat2 Exp $

inherit eutils

DESCRIPTION="The Advanced Maryland Automatic Network Disk Archiver"
HOMEPAGE="http://www.amanda.org/"
SRC_URI="mirror://sourceforge/amanda/${P/_/}.tar.gz"
LICENSE="as-is"
SLOT="0"
KEYWORDS="~amd64 ~ppc ~ppc64 ~sparc ~x86"
RDEPEND="sys-libs/readline
virtual/inetd
app-arch/mt-st
sci-visualization/gnuplot
sys-apps/gawk
app-arch/tar
dev-lang/perl
sys-block/mtx
app-arch/dump
virtual/mailx
samba? ( net-fs/samba )
berkdb? ( sys-libs/db )
gdbm? ( sys-libs/gdbm )
!sparc? ( xfs? ( sys-fs/xfsdump ) )
>=sys-apps/portage-2.0.51-r3"

DEPEND="${RDEPEND}
sys-devel/autoconf
sys-devel/automake"

IUSE="berkdb debug gdbm samba xfs"

S="${WORKDIR}/${P/_/}"
MYFILESDIR="${WORKDIR}/files"
MYTMPDIR="${WORKDIR}/tmp"
MYINSTTMPDIR="/usr/share/amanda"
ENVDIR="/etc/env.d"
ENVDFILE="97amanda"
TMPENVFILE="${MYTMPDIR}/${ENVDFILE}"
TMPINSTENVFILE="${MYINSTTMPDIR}/tmpenv-${ENVDFILE}"

amanda_variable_setup() {

# Setting vars
local currentamanda

# Grab the current settings
currentamanda="$(set | egrep "^AMANDA_" | xargs)"
use debug && einfo "Current settings: ${currentamanda}"
#for i in ${currentamanda}; do
# eval `eval echo ${i}`
# echo "Setting: ${i}"
#done;

# First we set the defaults
[ -z "${AMANDA_GROUP_GID}" ] && AMANDA_GROUP_GID=87
[ -z "${AMANDA_GROUP_NAME}" ] && AMANDA_GROUP_NAME=amanda
[ -z "${AMANDA_USER_NAME}" ] && AMANDA_USER_NAME=amanda
[ -z "${AMANDA_USER_UID}" ] && AMANDA_USER_UID=87
[ -z "${AMANDA_USER_SH}" ] && AMANDA_USER_SH=-1
[ -z "${AMANDA_USER_HOMEDIR}" ] && AMANDA_USER_HOMEDIR=/var/spool/amanda
[ -z "${AMANDA_USER_GROUPS}" ] && AMANDA_USER_GROUPS="${AMANDA_GROUP_NAME}"
# This installs Amanda, with the server. However, it could be a client,
# just specify an alternate server name in AMANDA_SERVER.
[ -z "${AMANDA_SERVER}" ] && AMANDA_SERVER="${HOSTNAME}"
[ -z "${AMANDA_SERVER_TAPE}" ] && AMANDA_SERVER_TAPE="${AMANDA_SERVER}"
[ -z "${AMANDA_SERVER_INDEX}" ] && AMANDA_SERVER_INDEX="${AMANDA_SERVER}"
[ -z "${AMANDA_TAR_LISTDIR}" ] && AMANDA_TAR_LISTDIR=${AMANDA_USER_HOMEDIR}/tar-lists
[ -z "${AMANDA_CONFIG_NAME}" ] && AMANDA_CONFIG_NAME=DailySet1
[ -z "${AMANDA_TMPDIR}" ] && AMANDA_TMPDIR=${AMANDA_USER_HOMEDIR}/tmp
# These are left empty by default
[ -z "${AMANDA_PORTS_UDP}" ] && AMANDA_PORTS_UDP=
[ -z "${AMANDA_PORTS_TCP}" ] && AMANDA_PORTS_TCP=
[ -z "${AMANDA_PORTS_BOTH}" ] && AMANDA_PORTS_BOTH=
[ -z "${AMANDA_PORTS}" ] && AMANDA_PORTS=

# This one is a little more complicated
# The priority list is this:
# 1. 'Berkely DB style' (only if USE="berkdb")
# 2. 'GDBM style' (only if USE="gdbm")
# 3. 'Text style'
[ -z "${AMANDA_DBMODE}" ] && use berkdb && AMANDA_DBMODE=db
[ -z "${AMANDA_DBMODE}" ] && use gdbm && AMANDA_DBMODE=gdbm
[ -z "${AMANDA_DBMODE}" ] && AMANDA_DBMODE=text

# Now pull in the old stuff
if [ -f "${ENVDIR}/${ENVDFILE}" ]; then
# We don't just source it as we don't want everything in there.
eval $(egrep "^AMANDA_" ${ENVDIR}/${ENVDFILE})
fi

# Re-apply the new settings if any
[ -n "${currentamanda}" ] && eval `echo "${currentamanda}"`

}

pkg_setup() {
# Now add users if needed
amanda_variable_setup
enewgroup "${AMANDA_GROUP_NAME}" "${AMANDA_GROUP_GID}"
enewuser "${AMANDA_USER_NAME}" "${AMANDA_USER_UID}" "${AMANDA_USER_SH}" "${AMANDA_USER_HOMEDIR}" "${AMANDA_USER_GROUPS}"
}

src_unpack() {
unpack "${A}"
# Fix glitch with recognizing tar-1.14.90
EPATCH_OPTS="-p1 -d ${S}" epatch ${FILESDIR}/patch-tar-1.14.90 || die "Failed to add tar support patch"
EPATCH_OPTS="-p1 -d ${S}" epatch ${FILESDIR}/${PN}-2.4.5-4tb-holding-disk.patch || die "Failed to patch for 4TB holding disks"
# merged by upstream
#EPATCH_OPTS="-p1 -d ${S}" epatch ${FILESDIR}/${PN}-2.4.5-samba-printf.patch || die "Failed to patch samba printf bug"
EPATCH_OPTS="-p1 -d ${S}" epatch ${FILESDIR}/${PN}-2.4.5-amverify-loop-detect.patch || die "Failed to patch amverify loop bug"
# now the real fun
amanda_variable_setup
# places for us to work in
mkdir -p "${MYFILESDIR}" "${MYTMPDIR}"
# Now we store the settings we just created
set | egrep "^AMANDA_" > "${TMPENVFILE}"
}

src_compile() {
# fix bug #36316
addpredict /var/cache/samba/gencache.tdb

[ ! -f "${TMPENVFILE}" ] && die "Variable setting file (${TMPENVFILE}) should exist!"
source "${TMPENVFILE}"
local myconf
cd "${S}"

einfo "Using '${AMANDA_DBMODE}' style database"
myconf="${myconf} --with-db=${AMANDA_DBMODE}"
einfo "Using ${AMANDA_SERVER_TAPE} for tape server."
myconf="${myconf} --with-tape-server=${AMANDA_SERVER_TAPE}"
einfo "Using ${AMANDA_SERVER_INDEX} for index server."
myconf="${myconf} --with-index-server=${AMANDA_SERVER_TAPE}"
einfo "Using ${AMANDA_USER_NAME} for amanda user."
myconf="${myconf} --with-user=${AMANDA_USER_NAME}"
einfo "Using ${AMANDA_GROUP_NAME} for amanda group."
myconf="${myconf} --with-group=${AMANDA_GROUP_NAME}"
einfo "Using ${AMANDA_TAR_LISTDIR} as tar listdir."
myconf="${myconf} --with-gnutar-listdir=${AMANDA_TAR_LISTDIR}"
einfo "Using ${AMANDA_CONFIG_NAME} as default config name."
myconf="${myconf} --with-config=${AMANDA_CONFIG_NAME}"
einfo "Using ${AMANDA_TMPDIR} as Amanda temporary directory."
myconf="${myconf} --with-tmpdir=${AMANDA_TMPDIR}"

if [ -n "${AMANDA_PORTS_UDP}" ] && [ -n "${AMANDA_PORTS_TCP}" ] && [ -z "${AMANDA_PORTS_BOTH}" ] ; then
eerror "If you want _both_ UDP and TCP ports, please use only the"
eerror "AMANDA_PORTS environment variable for identical ports, or set"
eerror "AMANDA_PORTS_BOTH."
die "Bad port setup!"
fi
if [ -n "${AMANDA_PORTS_UDP}" ]; then
einfo "Using UDP ports ${AMANDA_PORTS_UDP/,/-}"
myconf="${myconf} --with-udpportrange=${AMANDA_PORTS_UDP}"
fi
if [ -n "${AMANDA_PORTS_TCP}" ]; then
einfo "Using TCP ports ${AMANDA_PORTS_TCP/,/-}"
myconf="${myconf} --with-tcpportrange=${AMANDA_PORTS_TCP}"
fi
if [ -n "${AMANDA_PORTS}" ]; then
einfo "Using ports ${AMANDA_PORTS/,/-}"
myconf="${myconf} --with-portrange=${AMANDA_PORTS}"
fi

# Extras
# Speed option
myconf="${myconf} --with-buffered-dump"
# Debug
myconf="${myconf} `use_with debug debugging`"
# Where to put our files
myconf="${myconf} --localstatedir=${AMANDA_USER_HOMEDIR}"

# Samba support
use samba && myconf="${myconf} --with-smbclient=/usr/bin/smbclient" || myconf="${myconf} --without-smbclient"

# Force the correct TAR
myconf="${myconf} --with-gnutar=/bin/tar"

econf ${myconf} || die "econf failed!"
emake -j1 || die "emake failed!"

# Compile the tapetype program too
# This is deprecated, use amtapetype instead!
# cd tape-src
# emake tapetype || die "emake tapetype failed!"

# Only needed if you we do versioning
#dosed "s,/usr/local/bin/perl,/usr/bin/perl," ${S}/contrib/set_prod_link.pl
#perl ${S}/contrib/set_prod_link.pl

}

src_install() {
[ ! -f "${TMPENVFILE}" ] && die "Variable setting file (${TMPENVFILE}) should exist!"
source ${TMPENVFILE}

einfo "Doing stock install"
emake -j1 DESTDIR="${D}" install || die

# Prepare our custom files
einfo "Building custom configuration files"
cp "${FILESDIR}"/amanda-* "${MYFILESDIR}"
local i # our iterator
local sedexpr # var for sed expr
sedexpr=''
for i in AMANDA_GROUP_GID AMANDA_GROUP_NAME AMANDA_USER_NAME AMANDA_USER_UID AMANDA_USER_SH AMANDA_USER_HOMEDIR AMANDA_USER_GROUPS AMANDA_SERVER AMANDA_SERVER_TAPE AMANDA_SERVER_INDEX AMANDA_TAR_LISTDIR AMANDA_CONFIG_NAME AMANDA_TMPDIR AMANDA_PORTS_UDP AMANDA_PORTS_TCP AMANDA_PORTS_BOTH AMANDA_PORTS; do
local val
eval "val=\"\${${i}}\""
sedexpr="${sedexpr}s|__${i}__|${val}|g;"
done
#einfo "Compiled SED expression: '${sedexpr}'"

# now apply the sed expr
for i in "${FILESDIR}"/amanda-* ; do
local filename
filename="`basename ${i}`"
#einfo "Applying compiled SED expression to ${filename}"
sed -re "${sedexpr}" <"${i}" >"${MYFILESDIR}"/${filename}
done

# Build the envdir file
# Don't forget this..
einfo "Building environment file"
local t
t="${MYFILESDIR}"/${ENVDFILE}
echo "# These settings are what was present in the environment when this" >>"${t}"
echo "# Amanda was compiled. Changing anything below this comment will" >>"${t}"
echo "# have no effect on your application, but it merely exists to" >>"${t}"
echo "# preserve them for your next emerge of Amanda" >>"${t}"
cat "${TMPENVFILE}" | sed "s,=\$,='',g" >>"${t}"

into /usr

# Depreacted, use amtapetype instead
#einfo "Installing tapetype utility"
#newsbin tape-src/tapetype tapetype

# docs
einfo "Installing documentation"
dodoc AUTHORS C* INSTALL NEWS README
# Clean up some bits
dodoc "${D}"/usr/share/amanda/*
rm -rf "${D}"/usr/share/amanda
mkdir -p "${D}"/${MYINSTTMPDIR} || die
cp ${TMPENVFILE} "${D}"/${TMPINSTENVFILE} || die
# our inetd sample
einfo "Installing standard inetd sample"
dodoc "${MYFILESDIR}"/amanda-inetd.amanda.sample
# Stock extra docs
docinto docs
dodoc "${S}"/docs/*
# Labels
einfo "Installing labels"
docinto labels
dodoc "${S}"/example/3hole.ps
dodoc "${S}"/example/8.5x11.ps
dodoc "${S}"/example/DIN-A4.ps
dodoc "${S}"/example/DLT.ps
dodoc "${S}"/example/EXB-8500.ps
dodoc "${S}"/example/HP-DAT.ps
# Amanda example configs
einfo "Installing example configurations"
docinto example
dodoc "${S}"/example/*
docinto example1
newdoc "${FILESDIR}"/example_amanda.conf amanda.conf
newdoc "${FILESDIR}"/example_disklist disklist
newdoc "${FILESDIR}"/example_global.conf global.conf
docinto example2
newdoc "${S}"/example/amanda.conf amanda.conf
newdoc "${S}"/example/disklist disklist
# Compress it all
prepalldocs

# Just make sure it exists for XFS to work...
use !sparc && use xfs && keepdir /var/xfsdump/inventory

insinto /etc/amanda
einfo "Installing .amandahosts File for ${AMANDA_USER_NAME} user"
newins "${MYFILESDIR}"/amanda-amandahosts amandahosts
dosym /etc/amanda/amandahosts ${AMANDA_USER_HOMEDIR}/.amandahosts
insinto ${AMANDA_USER_HOMEDIR}
einfo "Installing .profile for ${AMANDA_USER_NAME} user"
newins "${MYFILESDIR}"/amanda-profile .profile

einfo "Installing Sample Daily Cron Job for Amanda"
CRONDIR=/etc/cron.daily/
exeinto ${CRONDIR}
newexe "${MYFILESDIR}"/amanda-cron amanda
# Not excetuable by default
fperms 644 ${CRONDIR}/amanda

insinto /etc/amanda/${AMANDA_CONFIG_NAME}
keepdir /etc/amanda
keepdir /etc/amanda/${AMANDA_CONFIG_NAME}

local i
for i in ${AMANDA_USER_HOMEDIR} ${AMANDA_TAR_LISTDIR} ${AMANDA_TMPDIR} ${AMANDA_TMPDIR}/dumps ${AMANDA_USER_HOMEDIR}/${AMANDA_CONFIG_NAME} /etc/amanda /etc/amanda/${AMANDA_CONFIG_NAME}; do
einfo "Securing directory (${i})"
dodir ${i}
keepdir ${i}
fowners ${AMANDA_USER_NAME}:${AMANDA_GROUP_NAME} ${i}
fperms 700 ${i}
done

# DevFS
einfo "Installing DevFS config file"
insinto /etc/devfs.d
newins "${MYFILESDIR}"/amanda-devfs amanda

# Env.d
einfo "Installing environment config file"
doenvd "${MYFILESDIR}"/${ENVDFILE}

# Installing Amanda Xinetd Services Definition
einfo "Installing xinetd service file"
insinto /etc/xinetd.d
newins "${MYFILESDIR}"/amanda-xinetd amanda

}

pkg_postinst() {
local aux="${ROOT}"/${TMPINSTENVFILE}
[ ! -f "${aux}" ] && die "Variable setting file (${aux}) should exist!"
source "${aux}"
rm "${aux}"
rmdir "${ROOT}"/${MYINSTTMPDIR} 2>/dev/null # ignore error

local i
for i in amandates dumpdates; do
einfo "Creating inital Amanda file (${i})"
touch "${ROOT}"/etc/${i}
chown ${AMANDA_USER_NAME}:${AMANDA_GROUP_NAME} "${ROOT}"/etc/${i}
chmod 600 "${ROOT}"/etc/${i}
done

elog "You should configure Amanda in /etc/amanda now."
elog
elog "If you use xinetd, Don't forget to check /etc/xinetd.d/amanda"
elog "and restart xinetd afterwards!"
elog
elog "Otherwise, please look at /usr/share/doc/${P}/inetd.amanda.sample"
elog "as an example of how to configure your inetd."
elog
elog "NOTICE: If you need raw acces to partitions you need to add the"
elog "amanda user to the 'disk' group and uncomment following lines in"
elog "your /etc/devfs.d/amanda:"
elog "SCSI:"
elog "REGISTER ^scsi/host.*/bus.*/target.*/lun.*/part[0-9] PERMISSIONS root.disk 660"
elog "IDE:"
elog "REGISTER ^ide/host.*/bus.*/target.*/lun.*/part[0-9] PERMISSIONS root.disk 660"
elog
elog "NOTICE: If you have a tape changer, also uncomment the following"
elog "REGISTER ^scsi/host.*/bus.*/target.*/lun.*/generic PERMISSIONS root.disk 660"
}

amanda-2.5.1_p3-r1.ebuild

# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-backup/amanda/amanda-2.5.1_p3-r1.ebuild,v 1.5 2007/10/09 09:23:15 robbat2 Exp $

inherit eutils

DESCRIPTION="The Advanced Maryland Automatic Network Disk Archiver"
HOMEPAGE="http://www.amanda.org/"
SRC_URI="mirror://sourceforge/amanda/${P/_/}.tar.gz"
LICENSE="as-is"
SLOT="0"
KEYWORDS="~amd64 ~ppc ~ppc64 ~sparc ~x86"
RDEPEND="sys-libs/readline
virtual/inetd
sys-apps/gawk
app-arch/tar
dev-lang/perl
app-arch/dump
samba? ( net-fs/samba )
berkdb? ( sys-libs/db )
gdbm? ( sys-libs/gdbm )
!sparc? ( xfs? ( sys-fs/xfsdump ) )
!minimal? ( virtual/mailx
app-arch/mt-st
sys-block/mtx
sci-visualization/gnuplot
app-crypt/aespipe
app-crypt/gnupg )"

DEPEND="${RDEPEND}
sys-devel/autoconf
sys-devel/automake"

IUSE="berkdb debug gdbm minimal samba xfs"

S="${WORKDIR}/${P/_/}"
MYFILESDIR="${WORKDIR}/files"
MYTMPDIR="${WORKDIR}/tmp"
MYINSTTMPDIR="/usr/share/amanda"
ENVDIR="/etc/env.d"
ENVDFILE="97amanda"
TMPENVFILE="${MYTMPDIR}/${ENVDFILE}"
TMPINSTENVFILE="${MYINSTTMPDIR}/tmpenv-${ENVDFILE}"

amanda_variable_setup() {

# Setting vars
local currentamanda

# Grab the current settings
currentamanda="$(set | egrep "^AMANDA_" | xargs)"
use debug && einfo "Current settings: ${currentamanda}"
#for i in ${currentamanda}; do
# eval `eval echo ${i}`
# echo "Setting: ${i}"
#done;

# First we set the defaults
[ -z "${AMANDA_GROUP_GID}" ] && AMANDA_GROUP_GID=87
[ -z "${AMANDA_GROUP_NAME}" ] && AMANDA_GROUP_NAME=amanda
[ -z "${AMANDA_USER_NAME}" ] && AMANDA_USER_NAME=amanda
[ -z "${AMANDA_USER_UID}" ] && AMANDA_USER_UID=87
[ -z "${AMANDA_USER_SH}" ] && AMANDA_USER_SH=-1
[ -z "${AMANDA_USER_HOMEDIR}" ] && AMANDA_USER_HOMEDIR=/var/spool/amanda
[ -z "${AMANDA_USER_GROUPS}" ] && AMANDA_USER_GROUPS="${AMANDA_GROUP_NAME}"

# This installs Amanda, with the server. However, it could be a client,
# just specify an alternate server name in AMANDA_SERVER.
[ -z "${AMANDA_SERVER}" ] && AMANDA_SERVER="${HOSTNAME}"
[ -z "${AMANDA_SERVER_TAPE}" ] && AMANDA_SERVER_TAPE="${AMANDA_SERVER}"
[ -z "${AMANDA_SERVER_INDEX}" ] && AMANDA_SERVER_INDEX="${AMANDA_SERVER}"
[ -z "${AMANDA_TAR_LISTDIR}" ] && AMANDA_TAR_LISTDIR=${AMANDA_USER_HOMEDIR}/tar-lists
[ -z "${AMANDA_CONFIG_NAME}" ] && AMANDA_CONFIG_NAME=DailySet1
[ -z "${AMANDA_TMPDIR}" ] && AMANDA_TMPDIR=/var/tmp/amanda
[ -z "${AMANDA_DBGDIR}" ] && AMANDA_DBGDIR="$AMANDA_TMPDIR"
# These are left empty by default
[ -z "${AMANDA_PORTS_UDP}" ] && AMANDA_PORTS_UDP=
[ -z "${AMANDA_PORTS_TCP}" ] && AMANDA_PORTS_TCP=
[ -z "${AMANDA_PORTS_BOTH}" ] && AMANDA_PORTS_BOTH=
[ -z "${AMANDA_PORTS}" ] && AMANDA_PORTS=

# This one is a little more complicated
# The priority list is this:
# 1. 'Berkely DB style' (only if USE="berkdb")
# 2. 'GDBM style' (only if USE="gdbm")
# 3. 'Text style'
[ -z "${AMANDA_DBMODE}" ] && use berkdb && AMANDA_DBMODE=db
[ -z "${AMANDA_DBMODE}" ] && use gdbm && AMANDA_DBMODE=gdbm
[ -z "${AMANDA_DBMODE}" ] && AMANDA_DBMODE=text

# Now pull in the old stuff
if [ -f "${ENVDIR}/${ENVDFILE}" ]; then
# We don't just source it as we don't want everything in there.
eval $(egrep "^AMANDA_" ${ENVDIR}/${ENVDFILE})
fi

# Re-apply the new settings if any
[ -n "${currentamanda}" ] && eval `echo "${currentamanda}"`

}

pkg_setup() {
# Now add users if needed
amanda_variable_setup
enewgroup "${AMANDA_GROUP_NAME}" "${AMANDA_GROUP_GID}"
enewuser "${AMANDA_USER_NAME}" "${AMANDA_USER_UID}" "${AMANDA_USER_SH}" "${AMANDA_USER_HOMEDIR}" "${AMANDA_USER_GROUPS}"
}

src_unpack() {
unpack "${A}"
# Fix glitch with recognizing tar-1.14.90
EPATCH_OPTS="-p1 -d ${S}" epatch ${FILESDIR}/patch-tar-1.14.90 || die "Failed to add tar support patch"
# Fix tar 1.16 changes
# ( http://cvs.savannah.gnu.org/viewcvs/tar/NEWS?rev=1.125&root=tar )
# commented by sgw, but not yet removed:
# the patch is in the upstream source already
#EPATCH_OPTS="-p0 -d ${S}" epatch ${FILESDIR}/${P}-tar-1.16.patch || die "Failed to add tar 1.16 patch"

# Fix broken display of chunks with parameter displayunit.
EPATCH_OPTS="-p1 -d ${S}" epatch ${FILESDIR}/${P}-displayunit.patch || die "Failed to add amstatus-patch"

# now the real fun
amanda_variable_setup
# places for us to work in
mkdir -p "${MYFILESDIR}" "${MYTMPDIR}"
# Now we store the settings we just created
set | egrep "^AMANDA_" > "${TMPENVFILE}"
}

src_compile() {
# fix bug #36316
addpredict /var/cache/samba/gencache.tdb

[ ! -f "${TMPENVFILE}" ] && die "Variable setting file (${TMPENVFILE}) should exist!"
source "${TMPENVFILE}"
local myconf
cd "${S}"

einfo "Using '${AMANDA_DBMODE}' style database"
myconf="${myconf} --with-db=${AMANDA_DBMODE}"
einfo "Using ${AMANDA_SERVER_TAPE} for tape server."
myconf="${myconf} --with-tape-server=${AMANDA_SERVER_TAPE}"
einfo "Using ${AMANDA_SERVER_INDEX} for index server."
myconf="${myconf} --with-index-server=${AMANDA_SERVER_INDEX}"
einfo "Using ${AMANDA_USER_NAME} for amanda user."
myconf="${myconf} --with-user=${AMANDA_USER_NAME}"
einfo "Using ${AMANDA_GROUP_NAME} for amanda group."
myconf="${myconf} --with-group=${AMANDA_GROUP_NAME}"
einfo "Using ${AMANDA_TAR_LISTDIR} as tar listdir."
myconf="${myconf} --with-gnutar-listdir=${AMANDA_TAR_LISTDIR}"
einfo "Using ${AMANDA_CONFIG_NAME} as default config name."
myconf="${myconf} --with-config=${AMANDA_CONFIG_NAME}"
einfo "Using ${AMANDA_TMPDIR} as Amanda temporary directory."
myconf="${myconf} --with-tmpdir=${AMANDA_TMPDIR}"

if [ -n "${AMANDA_PORTS_UDP}" ] && [ -n "${AMANDA_PORTS_TCP}" ] && [ -z "${AMANDA_PORTS_BOTH}" ] ; then
eerror "If you want _both_ UDP and TCP ports, please use only the"
eerror "AMANDA_PORTS environment variable for identical ports, or set"
eerror "AMANDA_PORTS_BOTH."
die "Bad port setup!"
fi
if [ -n "${AMANDA_PORTS_UDP}" ]; then
einfo "Using UDP ports ${AMANDA_PORTS_UDP/,/-}"
myconf="${myconf} --with-udpportrange=${AMANDA_PORTS_UDP}"
fi
if [ -n "${AMANDA_PORTS_TCP}" ]; then
einfo "Using TCP ports ${AMANDA_PORTS_TCP/,/-}"
myconf="${myconf} --with-tcpportrange=${AMANDA_PORTS_TCP}"
fi
if [ -n "${AMANDA_PORTS}" ]; then
einfo "Using ports ${AMANDA_PORTS/,/-}"
myconf="${myconf} --with-portrange=${AMANDA_PORTS}"
fi

# Extras
# Speed option
myconf="${myconf} --with-buffered-dump"
# Debug
myconf="${myconf} `use_with debug debugging`"
# Where to put our files
myconf="${myconf} --localstatedir=${AMANDA_USER_HOMEDIR}"

# Samba support
use samba && myconf="${myconf} --with-smbclient=/usr/bin/smbclient" || myconf="${myconf} --without-smbclient"

# Force the correct TAR
myconf="${myconf} --with-gnutar=/bin/tar"

# Client only, as requested in bug #127725
use minimal && myconf="${myconf} --without-server"

econf ${myconf} || die "econf failed!"
emake -j1 || die "emake failed!"

# Compile the tapetype program too
# This is deprecated, use amtapetype instead!
# cd tape-src
# emake tapetype || die "emake tapetype failed!"

# Only needed if you we do versioning
#dosed "s,/usr/local/bin/perl,/usr/bin/perl," ${S}/contrib/set_prod_link.pl
#perl ${S}/contrib/set_prod_link.pl

}

src_install() {
[ ! -f "${TMPENVFILE}" ] && die "Variable setting file (${TMPENVFILE}) should exist!"
source ${TMPENVFILE}

einfo "Doing stock install"
emake -j1 DESTDIR="${D}" install || die

# Prepare our custom files
einfo "Building custom configuration files"
cp "${FILESDIR}"/amanda-* "${MYFILESDIR}"
local i # our iterator
local sedexpr # var for sed expr
sedexpr=''
for i in AMANDA_GROUP_GID AMANDA_GROUP_NAME AMANDA_USER_NAME AMANDA_USER_UID AMANDA_USER_SH AMANDA_USER_HOMEDIR AMANDA_USER_GROUPS AMANDA_SERVER AMANDA_SERVER_TAPE AMANDA_SERVER_INDEX AMANDA_TAR_LISTDIR AMANDA_CONFIG_NAME AMANDA_TMPDIR AMANDA_PORTS_UDP AMANDA_PORTS_TCP AMANDA_PORTS_BOTH AMANDA_PORTS; do
local val
eval "val=\"\${${i}}\""
sedexpr="${sedexpr}s|__${i}__|${val}|g;"
done
#einfo "Compiled SED expression: '${sedexpr}'"

# now apply the sed expr
for i in "${FILESDIR}"/amanda-* ; do
local filename
filename="`basename ${i}`"
#einfo "Applying compiled SED expression to ${filename}"
sed -re "${sedexpr}" <"${i}" >"${MYFILESDIR}"/${filename}
done

# Build the envdir file
# Don't forget this..
einfo "Building environment file"
local t
t="${MYFILESDIR}"/${ENVDFILE}
echo "# These settings are what was present in the environment when this" >>"${t}"
echo "# Amanda was compiled. Changing anything below this comment will" >>"${t}"
echo "# have no effect on your application, but it merely exists to" >>"${t}"
echo "# preserve them for your next emerge of Amanda" >>"${t}"
cat "${TMPENVFILE}" | sed "s,=\$,='',g" >>"${t}"

into /usr

# Deprecated, use amtapetype instead
#einfo "Installing tapetype utility"
#newsbin tape-src/tapetype tapetype

# docs
einfo "Installing documentation"
dodoc AUTHORS C* INSTALL NEWS README
# Clean up some bits
dodoc /usr/share/amanda/*
rm -rf "${D}"/usr/share/amanda
mkdir -p "${D}"/${MYINSTTMPDIR} || die
cp "${TMPENVFILE}" "${D}"/${TMPINSTENVFILE} || die
# our inetd sample
einfo "Installing standard inetd sample"
newdoc "${MYFILESDIR}"/amanda-inetd.amanda.sample-2.5.1_p3-r1 amanda-inetd.amanda.sample
# Stock extra docs
docinto docs
dodoc "${S}"/docs/*
# Labels
einfo "Installing labels"
docinto labels
dodoc "${S}"/example/3hole.ps
dodoc "${S}"/example/8.5x11.ps
dodoc "${S}"/example/DIN-A4.ps
dodoc "${S}"/example/DLT.ps
dodoc "${S}"/example/EXB-8500.ps
dodoc "${S}"/example/HP-DAT.ps
# Amanda example configs
einfo "Installing example configurations"
docinto example
dodoc "${S}"/example/*
docinto example1
newdoc "${FILESDIR}"/example_amanda.conf amanda.conf
newdoc "${FILESDIR}"/example_disklist-2.5.1_p3-r1 disklist
newdoc "${FILESDIR}"/example_global.conf global.conf
docinto example2
newdoc "${S}"/example/amanda.conf amanda.conf
newdoc "${S}"/example/disklist disklist
# Compress it all
prepalldocs

# Just make sure it exists for XFS to work...
use !sparc && use xfs && keepdir /var/xfsdump/inventory

insinto /etc/amanda
einfo "Installing .amandahosts File for ${AMANDA_USER_NAME} user"

cat "${FILESDIR}"/amanda-amandahosts-client-2.5.1_p3-r1 >>"${D}"/etc/amanda/amandahosts
use minimal \
|| cat "${FILESDIR}"/amanda-amandahosts-server2.5.1_p3-r1 >>"${D}"/etc/amanda/amandahosts

dosym /etc/amanda/amandahosts ${AMANDA_USER_HOMEDIR}/.amandahosts
insinto ${AMANDA_USER_HOMEDIR}
einfo "Installing .profile for ${AMANDA_USER_NAME} user"
newins "${MYFILESDIR}"/amanda-profile .profile

einfo "Installing Sample Daily Cron Job for Amanda"
CRONDIR=/etc/cron.daily/
exeinto ${CRONDIR}
newexe "${MYFILESDIR}"/amanda-cron amanda
# Not excetuable by default
fperms 644 ${CRONDIR}/amanda

insinto /etc/amanda/${AMANDA_CONFIG_NAME}
keepdir /etc/amanda
keepdir /etc/amanda/${AMANDA_CONFIG_NAME}

local i
for i in ${AMANDA_USER_HOMEDIR} ${AMANDA_TAR_LISTDIR} ${AMANDA_TMPDIR} ${AMANDA_TMPDIR}/dumps ${AMANDA_USER_HOMEDIR}/${AMANDA_CONFIG_NAME} /etc/amanda /etc/amanda/${AMANDA_CONFIG_NAME}; do
einfo "Securing directory (${i})"
dodir ${i}
keepdir ${i}
fowners ${AMANDA_USER_NAME}:${AMANDA_GROUP_NAME} ${i}
fperms 700 ${i}
done

# DevFS
einfo "Installing DevFS config file"
insinto /etc/devfs.d
newins "${MYFILESDIR}"/amanda-devfs amanda

# Env.d
einfo "Installing environment config file"
doenvd "${MYFILESDIR}"/${ENVDFILE}

# Installing Amanda Xinetd Services Definition
einfo "Installing xinetd service file"
insinto /etc/xinetd.d
newins "${MYFILESDIR}"/amanda-xinetd-2.5.1_p3-r1 amanda

}

pkg_postinst() {
local aux="${ROOT}"/${TMPINSTENVFILE}
[ ! -f "${aux}" ] && die "Variable setting file (${aux}) should exist!"
source "${aux}"
rm "${aux}"
rmdir "${ROOT}"/${MYINSTTMPDIR} 2>/dev/null # ignore error

local i
for i in amandates dumpdates; do
einfo "Creating inital Amanda file (${i})"
touch "${ROOT}"/etc/${i}
chown ${AMANDA_USER_NAME}:${AMANDA_GROUP_NAME} "${ROOT}"/etc/${i}
chmod 600 "${ROOT}"/etc/${i}
done

# If USE=minimal, give out a warning, if AMANDA_SERVER is not set to
# another host than HOSTNAME.
if use minimal; then
if [[ "${AMANDA_SERVER}" = "${HOSTNAME}" ]]; then
echo
ewarn "You are installing a client-only version of Amanda."
ewarn "You should set the variable $AMANDA_SERVER to point at your"
ewarn "Amanda-tape-server, otherwise you will have to specify its name"
ewarn "when using amrecover on the client."
ewarn "For example: Use something like"
ewarn "AMANDA_SERVER=\"myserver\" emerge amanda"
echo
fi
fi

elog "You should configure Amanda in /etc/amanda now."
elog
elog "If you use xinetd, Don't forget to check /etc/xinetd.d/amanda"
elog "and restart xinetd afterwards!"
elog
elog "Otherwise, please look at /usr/share/doc/${P}/inetd.amanda.sample"
elog "as an example of how to configure your inetd."
elog
elog "NOTICE: If you need raw access to partitions you need to add the"
elog "amanda user to the 'disk' group and uncomment following lines in"
elog "your /etc/devfs.d/amanda:"
elog "SCSI:"
elog "REGISTER ^scsi/host.*/bus.*/target.*/lun.*/part[0-9] PERMISSIONS root.disk 660"
elog "IDE:"
elog "REGISTER ^ide/host.*/bus.*/target.*/lun.*/part[0-9] PERMISSIONS root.disk 660"
elog
elog "NOTICE: If you have a tape changer, also uncomment the following"
elog "REGISTER ^scsi/host.*/bus.*/target.*/lun.*/generic PERMISSIONS root.disk 660"
elog
elog "If you use localhost in your disklist your restores may break."
elog "You should replace it with the actual hostname!"
elog "Please also see the syntax changes to amandahosts."
}

amanda-2.5.1_p3-r2.ebuild

# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-backup/amanda/amanda-2.5.1_p3-r2.ebuild,v 1.6 2007/10/09 09:23:15 robbat2 Exp $

inherit eutils

DESCRIPTION="The Advanced Maryland Automatic Network Disk Archiver"
HOMEPAGE="http://www.amanda.org/"
SRC_URI="mirror://sourceforge/amanda/${P/_/}.tar.gz"
LICENSE="as-is"
SLOT="0"
KEYWORDS="~amd64 ~ppc ~ppc64 ~sparc ~x86"
RDEPEND="sys-libs/readline
virtual/inetd
sys-apps/gawk
app-arch/tar
dev-lang/perl
app-arch/dump
samba? ( net-fs/samba )
berkdb? ( sys-libs/db )
gdbm? ( sys-libs/gdbm )
!sparc? ( xfs? ( sys-fs/xfsdump ) )
!minimal? ( virtual/mailx
app-arch/mt-st
sys-block/mtx
sci-visualization/gnuplot
app-crypt/aespipe
app-crypt/gnupg )"

DEPEND="${RDEPEND}
sys-devel/autoconf
sys-devel/automake"

IUSE="berkdb debug gdbm minimal samba xfs"

S="${WORKDIR}/${P/_/}"
MYFILESDIR="${WORKDIR}/files"
MYTMPDIR="${WORKDIR}/tmp"
MYINSTTMPDIR="/usr/share/amanda"
ENVDIR="/etc/env.d"
ENVDFILE="97amanda"
TMPENVFILE="${MYTMPDIR}/${ENVDFILE}"
TMPINSTENVFILE="${MYINSTTMPDIR}/tmpenv-${ENVDFILE}"

amanda_variable_setup() {

# Setting vars
local currentamanda

# Grab the current settings
currentamanda="$(set | egrep "^AMANDA_" | xargs)"
use debug && einfo "Current settings: ${currentamanda}"
#for i in ${currentamanda}; do
# eval `eval echo ${i}`
# echo "Setting: ${i}"
#done;

# First we set the defaults
[ -z "${AMANDA_GROUP_GID}" ] && AMANDA_GROUP_GID=87
[ -z "${AMANDA_GROUP_NAME}" ] && AMANDA_GROUP_NAME=amanda
[ -z "${AMANDA_USER_NAME}" ] && AMANDA_USER_NAME=amanda
[ -z "${AMANDA_USER_UID}" ] && AMANDA_USER_UID=87
[ -z "${AMANDA_USER_SH}" ] && AMANDA_USER_SH=-1
[ -z "${AMANDA_USER_HOMEDIR}" ] && AMANDA_USER_HOMEDIR=/var/spool/amanda
[ -z "${AMANDA_USER_GROUPS}" ] && AMANDA_USER_GROUPS="${AMANDA_GROUP_NAME}"

# This installs Amanda, with the server. However, it could be a client,
# just specify an alternate server name in AMANDA_SERVER.
[ -z "${AMANDA_SERVER}" ] && AMANDA_SERVER="${HOSTNAME}"
[ -z "${AMANDA_SERVER_TAPE}" ] && AMANDA_SERVER_TAPE="${AMANDA_SERVER}"
[ -z "${AMANDA_SERVER_INDEX}" ] && AMANDA_SERVER_INDEX="${AMANDA_SERVER}"
[ -z "${AMANDA_TAR_LISTDIR}" ] && AMANDA_TAR_LISTDIR=${AMANDA_USER_HOMEDIR}/tar-lists
[ -z "${AMANDA_CONFIG_NAME}" ] && AMANDA_CONFIG_NAME=DailySet1
[ -z "${AMANDA_TMPDIR}" ] && AMANDA_TMPDIR=/var/tmp/amanda
[ -z "${AMANDA_DBGDIR}" ] && AMANDA_DBGDIR="$AMANDA_TMPDIR"
# These are left empty by default
[ -z "${AMANDA_PORTS_UDP}" ] && AMANDA_PORTS_UDP=
[ -z "${AMANDA_PORTS_TCP}" ] && AMANDA_PORTS_TCP=
[ -z "${AMANDA_PORTS_BOTH}" ] && AMANDA_PORTS_BOTH=
[ -z "${AMANDA_PORTS}" ] && AMANDA_PORTS=

# This one is a little more complicated
# The priority list is this:
# 1. 'Berkely DB style' (only if USE="berkdb")
# 2. 'GDBM style' (only if USE="gdbm")
# 3. 'Text style'
[ -z "${AMANDA_DBMODE}" ] && use berkdb && AMANDA_DBMODE=db
[ -z "${AMANDA_DBMODE}" ] && use gdbm && AMANDA_DBMODE=gdbm
[ -z "${AMANDA_DBMODE}" ] && AMANDA_DBMODE=text

# Now pull in the old stuff
if [ -f "${ENVDIR}/${ENVDFILE}" ]; then
# We don't just source it as we don't want everything in there.
eval $(egrep "^AMANDA_" ${ENVDIR}/${ENVDFILE})
fi

# Re-apply the new settings if any
[ -n "${currentamanda}" ] && eval `echo "${currentamanda}"`

}

pkg_setup() {
# Now add users if needed
amanda_variable_setup
enewgroup "${AMANDA_GROUP_NAME}" "${AMANDA_GROUP_GID}"
enewuser "${AMANDA_USER_NAME}" "${AMANDA_USER_UID}" "${AMANDA_USER_SH}" "${AMANDA_USER_HOMEDIR}" "${AMANDA_USER_GROUPS}"
}

src_unpack() {
unpack "${A}"
# Fix glitch with recognizing tar-1.14.90
EPATCH_OPTS="-p1 -d ${S}" epatch ${FILESDIR}/patch-tar-1.14.90 || die "Failed to add tar support patch"
# Fix tar 1.16 changes
# ( http://cvs.savannah.gnu.org/viewcvs/tar/NEWS?rev=1.125&root=tar )
# commented by sgw, but not yet removed:
# the patch is in the upstream source already
#EPATCH_OPTS="-p0 -d ${S}" epatch ${FILESDIR}/${P}-tar-1.16.patch || die "Failed to add tar 1.16 patch"

# Fix broken display of chunks with parameter displayunit.
EPATCH_OPTS="-p1 -d ${S}" epatch ${FILESDIR}/${P}-displayunit.patch || die "Failed to add amstatus-patch"

# now the real fun
amanda_variable_setup
# places for us to work in
mkdir -p "${MYFILESDIR}" "${MYTMPDIR}"
# Now we store the settings we just created
set | egrep "^AMANDA_" > "${TMPENVFILE}"
}

src_compile() {
# fix bug #36316
addpredict /var/cache/samba/gencache.tdb

[ ! -f "${TMPENVFILE}" ] && die "Variable setting file (${TMPENVFILE}) should exist!"
source "${TMPENVFILE}"
local myconf
cd "${S}"

einfo "Using '${AMANDA_DBMODE}' style database"
myconf="${myconf} --with-db=${AMANDA_DBMODE}"
einfo "Using ${AMANDA_SERVER_TAPE} for tape server."
myconf="${myconf} --with-tape-server=${AMANDA_SERVER_TAPE}"
einfo "Using ${AMANDA_SERVER_INDEX} for index server."
myconf="${myconf} --with-index-server=${AMANDA_SERVER_INDEX}"
einfo "Using ${AMANDA_USER_NAME} for amanda user."
myconf="${myconf} --with-user=${AMANDA_USER_NAME}"
einfo "Using ${AMANDA_GROUP_NAME} for amanda group."
myconf="${myconf} --with-group=${AMANDA_GROUP_NAME}"
einfo "Using ${AMANDA_TAR_LISTDIR} as tar listdir."
myconf="${myconf} --with-gnutar-listdir=${AMANDA_TAR_LISTDIR}"
einfo "Using ${AMANDA_CONFIG_NAME} as default config name."
myconf="${myconf} --with-config=${AMANDA_CONFIG_NAME}"
einfo "Using ${AMANDA_TMPDIR} as Amanda temporary directory."
myconf="${myconf} --with-tmpdir=${AMANDA_TMPDIR}"

if [ -n "${AMANDA_PORTS_UDP}" ] && [ -n "${AMANDA_PORTS_TCP}" ] && [ -z "${AMANDA_PORTS_BOTH}" ] ; then
eerror "If you want _both_ UDP and TCP ports, please use only the"
eerror "AMANDA_PORTS environment variable for identical ports, or set"
eerror "AMANDA_PORTS_BOTH."
die "Bad port setup!"
fi
if [ -n "${AMANDA_PORTS_UDP}" ]; then
einfo "Using UDP ports ${AMANDA_PORTS_UDP/,/-}"
myconf="${myconf} --with-udpportrange=${AMANDA_PORTS_UDP}"
fi
if [ -n "${AMANDA_PORTS_TCP}" ]; then
einfo "Using TCP ports ${AMANDA_PORTS_TCP/,/-}"
myconf="${myconf} --with-tcpportrange=${AMANDA_PORTS_TCP}"
fi
if [ -n "${AMANDA_PORTS}" ]; then
einfo "Using ports ${AMANDA_PORTS/,/-}"
myconf="${myconf} --with-portrange=${AMANDA_PORTS}"
fi

# Extras
# Speed option
myconf="${myconf} --with-buffered-dump"
# "debugging" in the configuration is NOT debug in the conventional sense.
# It is actually just useful output in the application, and should remain
# enabled. There are some cases of breakage with MTX tape changers as of
# 2.5.1p2 that it exposes when turned off as well.
myconf="${myconf} --with-debugging"
# Where to put our files
myconf="${myconf} --localstatedir=${AMANDA_USER_HOMEDIR}"

# Samba support
use samba && myconf="${myconf} --with-smbclient=/usr/bin/smbclient" || myconf="${myconf} --without-smbclient"

# Force the correct TAR
myconf="${myconf} --with-gnutar=/bin/tar"

# Client only, as requested in bug #127725
use minimal && myconf="${myconf} --without-server"

econf ${myconf} || die "econf failed!"
emake -j1 || die "emake failed!"

# Compile the tapetype program too
# This is deprecated, use amtapetype instead!
# cd tape-src
# emake tapetype || die "emake tapetype failed!"

# Only needed if you we do versioning
#dosed "s,/usr/local/bin/perl,/usr/bin/perl," ${S}/contrib/set_prod_link.pl
#perl ${S}/contrib/set_prod_link.pl

}

src_install() {
[ ! -f "${TMPENVFILE}" ] && die "Variable setting file (${TMPENVFILE}) should exist!"
source ${TMPENVFILE}

einfo "Doing stock install"
emake -j1 DESTDIR="${D}" install || die

# Prepare our custom files
einfo "Building custom configuration files"
cp "${FILESDIR}"/amanda-* "${MYFILESDIR}"
local i # our iterator
local sedexpr # var for sed expr
sedexpr=''
for i in AMANDA_GROUP_GID AMANDA_GROUP_NAME AMANDA_USER_NAME AMANDA_USER_UID AMANDA_USER_SH AMANDA_USER_HOMEDIR AMANDA_USER_GROUPS AMANDA_SERVER AMANDA_SERVER_TAPE AMANDA_SERVER_INDEX AMANDA_TAR_LISTDIR AMANDA_CONFIG_NAME AMANDA_TMPDIR AMANDA_PORTS_UDP AMANDA_PORTS_TCP AMANDA_PORTS_BOTH AMANDA_PORTS; do
local val
eval "val=\"\${${i}}\""
sedexpr="${sedexpr}s|__${i}__|${val}|g;"
done
#einfo "Compiled SED expression: '${sedexpr}'"

# now apply the sed expr
for i in "${FILESDIR}"/amanda-* ; do
local filename
filename="`basename ${i}`"
#einfo "Applying compiled SED expression to ${filename}"
sed -re "${sedexpr}" <"${i}" >"${MYFILESDIR}"/${filename}
done

# Build the envdir file
# Don't forget this..
einfo "Building environment file"
local t
t="${MYFILESDIR}"/${ENVDFILE}
echo "# These settings are what was present in the environment when this" >>"${t}"
echo "# Amanda was compiled. Changing anything below this comment will" >>"${t}"
echo "# have no effect on your application, but it merely exists to" >>"${t}"
echo "# preserve them for your next emerge of Amanda" >>"${t}"
cat "${TMPENVFILE}" | sed "s,=\$,='',g" >>"${t}"

into /usr

# Deprecated, use amtapetype instead
#einfo "Installing tapetype utility"
#newsbin tape-src/tapetype tapetype

# docs
einfo "Installing documentation"
dodoc AUTHORS C* INSTALL NEWS README
# Clean up some bits
dodoc /usr/share/amanda/*
rm -rf "${D}"/usr/share/amanda
mkdir -p "${D}"/${MYINSTTMPDIR} || die
cp "${TMPENVFILE}" "${D}"/${TMPINSTENVFILE} || die
# our inetd sample
einfo "Installing standard inetd sample"
newdoc "${MYFILESDIR}"/amanda-inetd.amanda.sample-2.5.1_p3-r1 amanda-inetd.amanda.sample
# Stock extra docs
docinto docs
dodoc "${S}"/docs/*
# Labels
einfo "Installing labels"
docinto labels
dodoc "${S}"/example/3hole.ps
dodoc "${S}"/example/8.5x11.ps
dodoc "${S}"/example/DIN-A4.ps
dodoc "${S}"/example/DLT.ps
dodoc "${S}"/example/EXB-8500.ps
dodoc "${S}"/example/HP-DAT.ps
# Amanda example configs
einfo "Installing example configurations"
docinto example
dodoc "${S}"/example/*
docinto example1
newdoc "${FILESDIR}"/example_amanda.conf amanda.conf
newdoc "${FILESDIR}"/example_disklist-2.5.1_p3-r1 disklist
newdoc "${FILESDIR}"/example_global.conf global.conf
docinto example2
newdoc "${S}"/example/amanda.conf amanda.conf
newdoc "${S}"/example/disklist disklist
# Compress it all
prepalldocs

# Just make sure it exists for XFS to work...
use !sparc && use xfs && keepdir /var/xfsdump/inventory

insinto /etc/amanda
einfo "Installing .amandahosts File for ${AMANDA_USER_NAME} user"

cat "${FILESDIR}"/amanda-amandahosts-client-2.5.1_p3-r1 \
>>"${D}"/etc/amanda/amandahosts
use minimal \
|| cat "${FILESDIR}"/amanda-amandahosts-server2.5.1_p3-r1 \
>>"${D}"/etc/amanda/amandahosts

dosym /etc/amanda/amandahosts ${AMANDA_USER_HOMEDIR}/.amandahosts
insinto "${AMANDA_USER_HOMEDIR}"
einfo "Installing .profile for ${AMANDA_USER_NAME} user"
newins "${MYFILESDIR}"/amanda-profile .profile

einfo "Installing Sample Daily Cron Job for Amanda"
CRONDIR=/etc/cron.daily/
exeinto ${CRONDIR}
newexe "${MYFILESDIR}"/amanda-cron amanda
# Not excetuable by default
fperms 644 ${CRONDIR}/amanda

insinto /etc/amanda/${AMANDA_CONFIG_NAME}
keepdir /etc/amanda
keepdir /etc/amanda/${AMANDA_CONFIG_NAME}

local i
for i in ${AMANDA_USER_HOMEDIR} ${AMANDA_TAR_LISTDIR} ${AMANDA_TMPDIR} ${AMANDA_TMPDIR}/dumps ${AMANDA_USER_HOMEDIR}/${AMANDA_CONFIG_NAME} /etc/amanda /etc/amanda/${AMANDA_CONFIG_NAME}; do
einfo "Securing directory (${i})"
dodir ${i}
keepdir ${i}
fowners ${AMANDA_USER_NAME}:${AMANDA_GROUP_NAME} ${i}
fperms 700 ${i}
done

# DevFS
einfo "Installing DevFS config file"
insinto /etc/devfs.d
newins "${MYFILESDIR}"/amanda-devfs amanda

# Env.d
einfo "Installing environment config file"
doenvd "${MYFILESDIR}"/${ENVDFILE}

# Installing Amanda Xinetd Services Definition
einfo "Installing xinetd service file"
insinto /etc/xinetd.d
newins "${MYFILESDIR}"/amanda-xinetd-2.5.1_p3-r1 amanda

}

pkg_postinst() {
local aux="${ROOT}"/${TMPINSTENVFILE}
[ ! -f "${aux}" ] && die "Variable setting file (${aux}) should exist!"
source "${aux}"
rm "${aux}"
rmdir "${ROOT}"/${MYINSTTMPDIR} 2>/dev/null # ignore error

local i
for i in amandates dumpdates; do
einfo "Creating inital Amanda file (${i})"
touch "${ROOT}"/etc/${i}
chown ${AMANDA_USER_NAME}:${AMANDA_GROUP_NAME} "${ROOT}"/etc/${i}
chmod 600 "${ROOT}"/etc/${i}
done

# If USE=minimal, give out a warning, if AMANDA_SERVER is not set to
# another host than HOSTNAME.
if use minimal; then
if [[ "${AMANDA_SERVER}" = "${HOSTNAME}" ]]; then
echo
ewarn "You are installing a client-only version of Amanda."
ewarn "You should set the variable $AMANDA_SERVER to point at your"
ewarn "Amanda-tape-server, otherwise you will have to specify its name"
ewarn "when using amrecover on the client."
ewarn "For example: Use something like"
ewarn "AMANDA_SERVER=\"myserver\" emerge amanda"
echo
fi
fi

elog "You should configure Amanda in /etc/amanda now."
elog
elog "If you use xinetd, Don't forget to check /etc/xinetd.d/amanda"
elog "and restart xinetd afterwards!"
elog
elog "Otherwise, please look at /usr/share/doc/${P}/inetd.amanda.sample"
elog "as an example of how to configure your inetd."
elog
elog "NOTICE: If you need raw access to partitions you need to add the"
elog "amanda user to the 'disk' group and uncomment following lines in"
elog "your /etc/devfs.d/amanda:"
elog "SCSI:"
elog "REGISTER ^scsi/host.*/bus.*/target.*/lun.*/part[0-9] PERMISSIONS root.disk 660"
elog "IDE:"
elog "REGISTER ^ide/host.*/bus.*/target.*/lun.*/part[0-9] PERMISSIONS root.disk 660"
elog
elog "NOTICE: If you have a tape changer, also uncomment the following"
elog "REGISTER ^scsi/host.*/bus.*/target.*/lun.*/generic PERMISSIONS root.disk 660"
elog
elog "If you use localhost in your disklist your restores may break."
elog "You should replace it with the actual hostname!"
elog "Please also see the syntax changes to amandahosts."
}

amanda-2.5.1_p3-r4.ebuild

# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-backup/amanda/amanda-2.5.1_p3-r4.ebuild,v 1.4 2007/10/09 09:23:15 robbat2 Exp $

inherit eutils

DESCRIPTION="The Advanced Maryland Automatic Network Disk Archiver"
HOMEPAGE="http://www.amanda.org/"
SRC_URI="mirror://sourceforge/amanda/${P/_/}.tar.gz"
LICENSE="as-is"
SLOT="0"
KEYWORDS="~amd64 ~ppc ~ppc64 ~sparc ~x86"
RDEPEND="sys-libs/readline
virtual/inetd
sys-apps/gawk
app-arch/tar
dev-lang/perl
app-arch/dump
net-misc/openssh
samba? ( net-fs/samba )
berkdb? ( sys-libs/db )
kerberos? ( app-crypt/mit-krb5 )
gdbm? ( sys-libs/gdbm )
!sparc? ( xfs? ( sys-fs/xfsdump ) )
!minimal? ( virtual/mailx
app-arch/mt-st
sys-block/mtx
sci-visualization/gnuplot
app-crypt/aespipe
app-crypt/gnupg )"

DEPEND="${RDEPEND}
sys-devel/autoconf
sys-devel/automake"

IUSE="berkdb debug gdbm minimal samba xfs kerberos"

S="${WORKDIR}/${P/_/}"
MYFILESDIR="${WORKDIR}/files"
MYTMPDIR="${WORKDIR}/tmp"
MYINSTTMPDIR="/usr/share/amanda"
ENVDIR="/etc/env.d"
ENVDFILE="97amanda"
TMPENVFILE="${MYTMPDIR}/${ENVDFILE}"
TMPINSTENVFILE="${MYINSTTMPDIR}/tmpenv-${ENVDFILE}"

amanda_variable_setup() {

# Setting vars
local currentamanda

# Grab the current settings
currentamanda="$(set | egrep "^AMANDA_" | xargs)"
use debug && einfo "Current settings: ${currentamanda}"
#for i in ${currentamanda}; do
# eval `eval echo ${i}`
# echo "Setting: ${i}"
#done;

# First we set the defaults
[ -z "${AMANDA_GROUP_GID}" ] && AMANDA_GROUP_GID=87
[ -z "${AMANDA_GROUP_NAME}" ] && AMANDA_GROUP_NAME=amanda
[ -z "${AMANDA_USER_NAME}" ] && AMANDA_USER_NAME=amanda
[ -z "${AMANDA_USER_UID}" ] && AMANDA_USER_UID=87
[ -z "${AMANDA_USER_SH}" ] && AMANDA_USER_SH=-1
[ -z "${AMANDA_USER_HOMEDIR}" ] && AMANDA_USER_HOMEDIR=/var/spool/amanda
[ -z "${AMANDA_USER_GROUPS}" ] && AMANDA_USER_GROUPS="${AMANDA_GROUP_NAME}"

# This installs Amanda, with the server. However, it could be a client,
# just specify an alternate server name in AMANDA_SERVER.
[ -z "${AMANDA_SERVER}" ] && AMANDA_SERVER="${HOSTNAME}"
[ -z "${AMANDA_SERVER_TAPE}" ] && AMANDA_SERVER_TAPE="${AMANDA_SERVER}"
[ -z "${AMANDA_SERVER_INDEX}" ] && AMANDA_SERVER_INDEX="${AMANDA_SERVER}"
[ -z "${AMANDA_TAR_LISTDIR}" ] && AMANDA_TAR_LISTDIR=${AMANDA_USER_HOMEDIR}/tar-lists
[ -z "${AMANDA_CONFIG_NAME}" ] && AMANDA_CONFIG_NAME=DailySet1
[ -z "${AMANDA_TMPDIR}" ] && AMANDA_TMPDIR=/var/tmp/amanda
[ -z "${AMANDA_DBGDIR}" ] && AMANDA_DBGDIR="$AMANDA_TMPDIR"
# These are left empty by default
[ -z "${AMANDA_PORTS_UDP}" ] && AMANDA_PORTS_UDP=
[ -z "${AMANDA_PORTS_TCP}" ] && AMANDA_PORTS_TCP=
[ -z "${AMANDA_PORTS_BOTH}" ] && AMANDA_PORTS_BOTH=
[ -z "${AMANDA_PORTS}" ] && AMANDA_PORTS=

# This one is a little more complicated
# The priority list is this:
# 1. 'Berkely DB style' (only if USE="berkdb")
# 2. 'GDBM style' (only if USE="gdbm")
# 3. 'Text style'
[ -z "${AMANDA_DBMODE}" ] && use berkdb && AMANDA_DBMODE=db
[ -z "${AMANDA_DBMODE}" ] && use gdbm && AMANDA_DBMODE=gdbm
[ -z "${AMANDA_DBMODE}" ] && AMANDA_DBMODE=text

# Now pull in the old stuff
if [ -f "${ENVDIR}/${ENVDFILE}" ]; then
# We don't just source it as we don't want everything in there.
eval $(egrep "^AMANDA_" ${ENVDIR}/${ENVDFILE})
fi

# Re-apply the new settings if any
[ -n "${currentamanda}" ] && eval `echo "${currentamanda}"`

}

pkg_setup() {
# Now add users if needed
amanda_variable_setup
enewgroup "${AMANDA_GROUP_NAME}" "${AMANDA_GROUP_GID}"
enewuser "${AMANDA_USER_NAME}" "${AMANDA_USER_UID}" "${AMANDA_USER_SH}" "${AMANDA_USER_HOMEDIR}" "${AMANDA_USER_GROUPS}"
}

src_unpack() {
unpack "${A}"
# Fix glitch with recognizing tar-1.14.90
EPATCH_OPTS="-p1 -d ${S}" epatch ${FILESDIR}/patch-tar-1.14.90 || die "Failed to add tar support patch"
# Fix tar 1.16 changes
# ( http://cvs.savannah.gnu.org/viewcvs/tar/NEWS?rev=1.125&root=tar )
# commented by sgw, but not yet removed:
# the patch is in the upstream source already
#EPATCH_OPTS="-p0 -d ${S}" epatch ${FILESDIR}/${P}-tar-1.16.patch || die "Failed to add tar 1.16 patch"

# Fix broken display of chunks with parameter displayunit.
EPATCH_OPTS="-p1 -d ${S}" epatch ${FILESDIR}/${P}-displayunit.patch || die "Failed to add amstatus-patch"

# now the real fun
amanda_variable_setup
# places for us to work in
mkdir -p "${MYFILESDIR}" "${MYTMPDIR}"
# Now we store the settings we just created
set | egrep "^AMANDA_" > "${TMPENVFILE}"
}

src_compile() {
# fix bug #36316
addpredict /var/cache/samba/gencache.tdb

[ ! -f "${TMPENVFILE}" ] && die "Variable setting file (${TMPENVFILE}) should exist!"
source "${TMPENVFILE}"
local myconf
cd "${S}"

einfo "Using '${AMANDA_DBMODE}' style database"
myconf="${myconf} --with-db=${AMANDA_DBMODE}"
einfo "Using ${AMANDA_SERVER_TAPE} for tape server."
myconf="${myconf} --with-tape-server=${AMANDA_SERVER_TAPE}"
einfo "Using ${AMANDA_SERVER_INDEX} for index server."
myconf="${myconf} --with-index-server=${AMANDA_SERVER_INDEX}"
einfo "Using ${AMANDA_USER_NAME} for amanda user."
myconf="${myconf} --with-user=${AMANDA_USER_NAME}"
einfo "Using ${AMANDA_GROUP_NAME} for amanda group."
myconf="${myconf} --with-group=${AMANDA_GROUP_NAME}"
einfo "Using ${AMANDA_TAR_LISTDIR} as tar listdir."
myconf="${myconf} --with-gnutar-listdir=${AMANDA_TAR_LISTDIR}"
einfo "Using ${AMANDA_CONFIG_NAME} as default config name."
myconf="${myconf} --with-config=${AMANDA_CONFIG_NAME}"
einfo "Using ${AMANDA_TMPDIR} as Amanda temporary directory."
myconf="${myconf} --with-tmpdir=${AMANDA_TMPDIR}"

if [ -n "${AMANDA_PORTS_UDP}" ] && [ -n "${AMANDA_PORTS_TCP}" ] && [ -z "${AMANDA_PORTS_BOTH}" ] ; then
eerror "If you want _both_ UDP and TCP ports, please use only the"
eerror "AMANDA_PORTS environment variable for identical ports, or set"
eerror "AMANDA_PORTS_BOTH."
die "Bad port setup!"
fi
if [ -n "${AMANDA_PORTS_UDP}" ]; then
einfo "Using UDP ports ${AMANDA_PORTS_UDP/,/-}"
myconf="${myconf} --with-udpportrange=${AMANDA_PORTS_UDP}"
fi
if [ -n "${AMANDA_PORTS_TCP}" ]; then
einfo "Using TCP ports ${AMANDA_PORTS_TCP/,/-}"
myconf="${myconf} --with-tcpportrange=${AMANDA_PORTS_TCP}"
fi
if [ -n "${AMANDA_PORTS}" ]; then
einfo "Using ports ${AMANDA_PORTS/,/-}"
myconf="${myconf} --with-portrange=${AMANDA_PORTS}"
fi

# Extras
# Speed option
myconf="${myconf} --with-buffered-dump"
# "debugging" in the configuration is NOT debug in the conventional sense.
# It is actually just useful output in the application, and should remain
# enabled. There are some cases of breakage with MTX tape changers as of
# 2.5.1p2 that it exposes when turned off as well.
myconf="${myconf} --with-debugging"
# Where to put our files
myconf="${myconf} --localstatedir=${AMANDA_USER_HOMEDIR}"

# Samba support
myconf="${myconf} `use_with samba smbclient /usr/bin/smbclient`"

# Support for BSD, SSH, BSDUDP, BSDTCP security methods all compiled in by
# default
myconf="${myconf} --with-bsd-security"
myconf="${myconf} --with-ssh-security"
myconf="${myconf} --with-bsdudp-security"
myconf="${myconf} --with-bsdtcp-security"

# kerberos-security mechanism version 4
# always disable, per bug #173354
myconf="${myconf} --without-krb4-security"

# kerberos-security mechanism version 5
myconf="${myconf} `use_with kerberos krb5-security`"

# Force the correct TAR
myconf="${myconf} --with-gnutar=/bin/tar"

# Client only, as requested in bug #127725
use minimal && myconf="${myconf} --without-server"

econf ${myconf} || die "econf failed!"
emake -j1 || die "emake failed!"

# Compile the tapetype program too
# This is deprecated, use amtapetype instead!
# cd tape-src
# emake tapetype || die "emake tapetype failed!"

# Only needed if you we do versioning
#dosed "s,/usr/local/bin/perl,/usr/bin/perl," ${S}/contrib/set_prod_link.pl
#perl ${S}/contrib/set_prod_link.pl

}

src_install() {
[ ! -f "${TMPENVFILE}" ] && die "Variable setting file (${TMPENVFILE}) should exist!"
source ${TMPENVFILE}

einfo "Doing stock install"
emake -j1 DESTDIR="${D}" install || die

# Prepare our custom files
einfo "Building custom configuration files"
cp "${FILESDIR}"/amanda-* "${MYFILESDIR}"
local i # our iterator
local sedexpr # var for sed expr
sedexpr=''
for i in AMANDA_GROUP_GID AMANDA_GROUP_NAME AMANDA_USER_NAME \
AMANDA_USER_UID AMANDA_USER_SH AMANDA_USER_HOMEDIR \
AMANDA_USER_GROUPS AMANDA_SERVER AMANDA_SERVER_TAPE \
AMANDA_SERVER_INDEX AMANDA_TAR_LISTDIR AMANDA_CONFIG_NAME \
AMANDA_TMPDIR AMANDA_PORTS_UDP AMANDA_PORTS_TCP \
AMANDA_PORTS_BOTH AMANDA_PORTS; do
local val
eval "val=\"\${${i}}\""
sedexpr="${sedexpr}s|__${i}__|${val}|g;"
done
#einfo "Compiled SED expression: '${sedexpr}'"

# now apply the sed expr
for i in "${FILESDIR}"/amanda-* ; do
local filename
filename="`basename ${i}`"
#einfo "Applying compiled SED expression to ${filename}"
sed -re "${sedexpr}" <"${i}" >"${MYFILESDIR}"/${filename}
done

# Build the envdir file
# Don't forget this..
einfo "Building environment file"
local t
t="${MYFILESDIR}"/${ENVDFILE}
echo "# These settings are what was present in the environment when this" >>"${t}"
echo "# Amanda was compiled. Changing anything below this comment will" >>"${t}"
echo "# have no effect on your application, but it merely exists to" >>"${t}"
echo "# preserve them for your next emerge of Amanda" >>"${t}"
cat "${TMPENVFILE}" | sed "s,=\$,='',g" >>"${t}"

into /usr

# Deprecated, use amtapetype instead
#einfo "Installing tapetype utility"
#newsbin tape-src/tapetype tapetype

# docs
einfo "Installing documentation"
dodoc AUTHORS C* INSTALL NEWS README
# Clean up some bits
dodoc /usr/share/amanda/*
rm -rf "${D}"/usr/share/amanda
mkdir -p "${D}"/${MYINSTTMPDIR} || die
cp "${TMPENVFILE}" "${D}"/${TMPINSTENVFILE} || die
# our inetd sample
einfo "Installing standard inetd sample"
newdoc "${MYFILESDIR}"/amanda-inetd.amanda.sample-2.5.1_p3-r1 amanda-inetd.amanda.sample
# Stock extra docs
docinto docs
dodoc "${S}"/docs/*
# Labels
einfo "Installing labels"
docinto labels
dodoc "${S}"/example/3hole.ps
dodoc "${S}"/example/8.5x11.ps
dodoc "${S}"/example/DIN-A4.ps
dodoc "${S}"/example/DLT.ps
dodoc "${S}"/example/EXB-8500.ps
dodoc "${S}"/example/HP-DAT.ps
# Amanda example configs
einfo "Installing example configurations"
docinto example
dodoc "${S}"/example/*
docinto example1
newdoc "${FILESDIR}"/example_amanda.conf amanda.conf
newdoc "${FILESDIR}"/example_disklist-2.5.1_p3-r1 disklist
newdoc "${FILESDIR}"/example_global.conf global.conf
docinto example2
newdoc "${S}"/example/amanda.conf amanda.conf
newdoc "${S}"/example/disklist disklist
# Compress it all
prepalldocs

# Just make sure it exists for XFS to work...
use !sparc && use xfs && keepdir /var/xfsdump/inventory

insinto /etc/amanda
einfo "Installing .amandahosts File for ${AMANDA_USER_NAME} user"

cat "${FILESDIR}"/amanda-amandahosts-client-2.5.1_p3-r1 \
>>"${D}"/etc/amanda/amandahosts
use minimal \
|| cat "${FILESDIR}"/amanda-amandahosts-server2.5.1_p3-r1 \
>>"${D}"/etc/amanda/amandahosts

dosym /etc/amanda/amandahosts ${AMANDA_USER_HOMEDIR}/.amandahosts
insinto ${AMANDA_USER_HOMEDIR}
einfo "Installing .profile for ${AMANDA_USER_NAME} user"
newins "${MYFILESDIR}"/amanda-profile .profile

einfo "Installing Sample Daily Cron Job for Amanda"
CRONDIR=/etc/cron.daily/
exeinto ${CRONDIR}
newexe "${MYFILESDIR}"/amanda-cron amanda
# Not executable by default
fperms 644 ${CRONDIR}/amanda

insinto /etc/amanda/${AMANDA_CONFIG_NAME}
keepdir /etc/amanda
keepdir /etc/amanda/${AMANDA_CONFIG_NAME}

local i
for i in ${AMANDA_USER_HOMEDIR} ${AMANDA_TAR_LISTDIR} \
${AMANDA_TMPDIR} ${AMANDA_TMPDIR}/dumps \
${AMANDA_USER_HOMEDIR}/${AMANDA_CONFIG_NAME} \
/etc/amanda /etc/amanda/${AMANDA_CONFIG_NAME}; do
einfo "Securing directory (${i})"
dodir ${i}
keepdir ${i}
fowners ${AMANDA_USER_NAME}:${AMANDA_GROUP_NAME} ${i}
fperms 700 ${i}
done

einfo "Setting setuid permissions"
amanda_permissions_fix "${D}"

# DevFS
einfo "Installing DevFS config file"
insinto /etc/devfs.d
newins "${MYFILESDIR}"/amanda-devfs amanda

# Env.d
einfo "Installing environment config file"
doenvd "${MYFILESDIR}"/${ENVDFILE}

# Installing Amanda Xinetd Services Definition
einfo "Installing xinetd service file"
insinto /etc/xinetd.d
newins "${MYFILESDIR}"/amanda-xinetd-2.5.1_p3-r1 amanda

}

pkg_postinst() {
local aux="${ROOT}"/${TMPINSTENVFILE}
[ ! -f "${aux}" ] && die "Variable setting file (${aux}) should exist!"
source "${aux}"
rm "${aux}"
rmdir "${ROOT}"/${MYINSTTMPDIR} 2>/dev/null # ignore error

local i
for i in amandates dumpdates; do
einfo "Creating inital Amanda file (${i})"
touch "${ROOT}"/etc/${i}
chown ${AMANDA_USER_NAME}:${AMANDA_GROUP_NAME} "${ROOT}"/etc/${i}
chmod 600 "${ROOT}"/etc/${i}
done

# If USE=minimal, give out a warning, if AMANDA_SERVER is not set to
# another host than HOSTNAME.
if use minimal; then
if [[ "${AMANDA_SERVER}" = "${HOSTNAME}" ]]; then
echo
ewarn "You are installing a client-only version of Amanda."
ewarn "You should set the variable $AMANDA_SERVER to point at your"
ewarn "Amanda-tape-server, otherwise you will have to specify its name"
ewarn "when using amrecover on the client."
ewarn "For example: Use something like"
ewarn "AMANDA_SERVER=\"myserver\" emerge amanda"
echo
fi
fi

einfo "Checking setuid permissions"
amanda_permissions_fix "${ROOT}"

elog "You should configure Amanda in /etc/amanda now."
elog
elog "If you use xinetd, Don't forget to check /etc/xinetd.d/amanda"
elog "and restart xinetd afterwards!"
elog
elog "Otherwise, please look at /usr/share/doc/${P}/inetd.amanda.sample"
elog "as an example of how to configure your inetd."
elog
elog "NOTICE: If you need raw access to partitions you need to add the"
elog "amanda user to the 'disk' group and uncomment following lines in"
elog "your /etc/devfs.d/amanda:"
elog "SCSI:"
elog "REGISTER ^scsi/host.*/bus.*/target.*/lun.*/part[0-9] PERMISSIONS root.disk 660"
elog "IDE:"
elog "REGISTER ^ide/host.*/bus.*/target.*/lun.*/part[0-9] PERMISSIONS root.disk 660"
elog
elog "NOTICE: If you have a tape changer, also uncomment the following"
elog "REGISTER ^scsi/host.*/bus.*/target.*/lun.*/generic PERMISSIONS root.disk 660"
elog
elog "If you use localhost in your disklist your restores may break."
elog "You should replace it with the actual hostname!"
elog "Please also see the syntax changes to amandahosts."
}

# We have had reports of amanda file permissions getting screwed up.
# Losing setuid, becoming too lax etc.
# ONLY root and users in the amanda group should be able to run these binaries!
amanda_permissions_fix() {
local root="$1"
[ -z "${root}" ] && die "Failed to pass root argument to amanda_permissions_fix!"
for i in /usr/sbin/amcheck /usr/libexec/calcsize /usr/libexec/killpgrp \
/usr/libexec/rundump /usr/libexec/runtar /usr/libexec/dumper \
/usr/libexec/planner ; do
chown root:${AMANDA_GROUP_NAME} "${root}"/${i}
chmod u=srwx,g=rx,o= "${root}"/${i}
done
}

amanda-2.5.2_p1-r1.ebuild

# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-backup/amanda/amanda-2.5.2_p1-r1.ebuild,v 1.2 2007/10/09 09:23:15 robbat2 Exp $

inherit eutils

DESCRIPTION="The Advanced Maryland Automatic Network Disk Archiver"
HOMEPAGE="http://www.amanda.org/"
SRC_URI="mirror://sourceforge/amanda/${P/_/}.tar.gz"
LICENSE="as-is"
SLOT="0"
KEYWORDS="~amd64 ~ppc ~ppc64 ~sparc ~x86"
RDEPEND="sys-libs/readline
virtual/inetd
sys-apps/gawk
app-arch/tar
dev-lang/perl
app-arch/dump
net-misc/openssh
samba? ( net-fs/samba )
berkdb? ( sys-libs/db )
kerberos? ( app-crypt/mit-krb5 )
gdbm? ( sys-libs/gdbm )
!sparc? ( xfs? ( sys-fs/xfsdump ) )
!minimal? ( virtual/mailx
app-arch/mt-st
sys-block/mtx
sci-visualization/gnuplot
app-crypt/aespipe
app-crypt/gnupg )"

DEPEND="${RDEPEND}
sys-devel/autoconf
sys-devel/automake"

IUSE="berkdb debug gdbm minimal samba xfs kerberos"

S="${WORKDIR}/${P/_/}"
MYFILESDIR="${WORKDIR}/files"
MYTMPDIR="${WORKDIR}/tmp"
MYINSTTMPDIR="/usr/share/amanda"
ENVDIR="/etc/env.d"
ENVDFILE="97amanda"
TMPENVFILE="${MYTMPDIR}/${ENVDFILE}"
TMPINSTENVFILE="${MYINSTTMPDIR}/tmpenv-${ENVDFILE}"

amanda_variable_setup() {

# Setting vars
local currentamanda

# Grab the current settings
currentamanda="$(set | egrep "^AMANDA_" | xargs)"
use debug && einfo "Current settings: ${currentamanda}"
#for i in ${currentamanda}; do
# eval `eval echo ${i}`
# echo "Setting: ${i}"
#done;

# First we set the defaults
[ -z "${AMANDA_GROUP_GID}" ] && AMANDA_GROUP_GID=87
[ -z "${AMANDA_GROUP_NAME}" ] && AMANDA_GROUP_NAME=amanda
[ -z "${AMANDA_USER_NAME}" ] && AMANDA_USER_NAME=amanda
[ -z "${AMANDA_USER_UID}" ] && AMANDA_USER_UID=87
[ -z "${AMANDA_USER_SH}" ] && AMANDA_USER_SH=-1
[ -z "${AMANDA_USER_HOMEDIR}" ] && AMANDA_USER_HOMEDIR=/var/spool/amanda
[ -z "${AMANDA_USER_GROUPS}" ] && AMANDA_USER_GROUPS="${AMANDA_GROUP_NAME}"

# This installs Amanda, with the server. However, it could be a client,
# just specify an alternate server name in AMANDA_SERVER.
[ -z "${AMANDA_SERVER}" ] && AMANDA_SERVER="${HOSTNAME}"
[ -z "${AMANDA_SERVER_TAPE}" ] && AMANDA_SERVER_TAPE="${AMANDA_SERVER}"
[ -z "${AMANDA_SERVER_INDEX}" ] && AMANDA_SERVER_INDEX="${AMANDA_SERVER}"
[ -z "${AMANDA_TAR_LISTDIR}" ] && AMANDA_TAR_LISTDIR=${AMANDA_USER_HOMEDIR}/tar-lists
[ -z "${AMANDA_CONFIG_NAME}" ] && AMANDA_CONFIG_NAME=DailySet1
[ -z "${AMANDA_TMPDIR}" ] && AMANDA_TMPDIR=/var/tmp/amanda
[ -z "${AMANDA_DBGDIR}" ] && AMANDA_DBGDIR="$AMANDA_TMPDIR"
# These are left empty by default
[ -z "${AMANDA_PORTS_UDP}" ] && AMANDA_PORTS_UDP=
[ -z "${AMANDA_PORTS_TCP}" ] && AMANDA_PORTS_TCP=
[ -z "${AMANDA_PORTS_BOTH}" ] && AMANDA_PORTS_BOTH=
[ -z "${AMANDA_PORTS}" ] && AMANDA_PORTS=

# This one is a little more complicated
# The priority list is this:
# 1. 'Berkely DB style' (only if USE="berkdb")
# 2. 'GDBM style' (only if USE="gdbm")
# 3. 'Text style'
[ -z "${AMANDA_DBMODE}" ] && use berkdb && AMANDA_DBMODE=db
[ -z "${AMANDA_DBMODE}" ] && use gdbm && AMANDA_DBMODE=gdbm
[ -z "${AMANDA_DBMODE}" ] && AMANDA_DBMODE=text

# Now pull in the old stuff
if [ -f "${ENVDIR}/${ENVDFILE}" ]; then
# We don't just source it as we don't want everything in there.
eval $(egrep "^AMANDA_" ${ENVDIR}/${ENVDFILE})
fi

# Re-apply the new settings if any
[ -n "${currentamanda}" ] && eval `echo "${currentamanda}"`

}

pkg_setup() {
# Now add users if needed
amanda_variable_setup
enewgroup "${AMANDA_GROUP_NAME}" "${AMANDA_GROUP_GID}"
enewuser "${AMANDA_USER_NAME}" "${AMANDA_USER_UID}" "${AMANDA_USER_SH}" "${AMANDA_USER_HOMEDIR}" "${AMANDA_USER_GROUPS}"
}

src_unpack() {
unpack "${A}"

# now the real fun
amanda_variable_setup
# places for us to work in
mkdir -p "${MYFILESDIR}" "${MYTMPDIR}"
# Now we store the settings we just created
set | egrep "^AMANDA_" > "${TMPENVFILE}"
}

src_compile() {
# fix bug #36316
addpredict /var/cache/samba/gencache.tdb

[ ! -f "${TMPENVFILE}" ] && die "Variable setting file (${TMPENVFILE}) should exist!"
source "${TMPENVFILE}"
local myconf
cd "${S}"

einfo "Using '${AMANDA_DBMODE}' style database"
myconf="${myconf} --with-db=${AMANDA_DBMODE}"
einfo "Using ${AMANDA_SERVER_TAPE} for tape server."
myconf="${myconf} --with-tape-server=${AMANDA_SERVER_TAPE}"
einfo "Using ${AMANDA_SERVER_INDEX} for index server."
myconf="${myconf} --with-index-server=${AMANDA_SERVER_INDEX}"
einfo "Using ${AMANDA_USER_NAME} for amanda user."
myconf="${myconf} --with-user=${AMANDA_USER_NAME}"
einfo "Using ${AMANDA_GROUP_NAME} for amanda group."
myconf="${myconf} --with-group=${AMANDA_GROUP_NAME}"
einfo "Using ${AMANDA_TAR_LISTDIR} as tar listdir."
myconf="${myconf} --with-gnutar-listdir=${AMANDA_TAR_LISTDIR}"
einfo "Using ${AMANDA_CONFIG_NAME} as default config name."
myconf="${myconf} --with-config=${AMANDA_CONFIG_NAME}"
einfo "Using ${AMANDA_TMPDIR} as Amanda temporary directory."
myconf="${myconf} --with-tmpdir=${AMANDA_TMPDIR}"

if [ -n "${AMANDA_PORTS_UDP}" ] && [ -n "${AMANDA_PORTS_TCP}" ] && [ -z "${AMANDA_PORTS_BOTH}" ] ; then
eerror "If you want _both_ UDP and TCP ports, please use only the"
eerror "AMANDA_PORTS environment variable for identical ports, or set"
eerror "AMANDA_PORTS_BOTH."
die "Bad port setup!"
fi
if [ -n "${AMANDA_PORTS_UDP}" ]; then
einfo "Using UDP ports ${AMANDA_PORTS_UDP/,/-}"
myconf="${myconf} --with-udpportrange=${AMANDA_PORTS_UDP}"
fi
if [ -n "${AMANDA_PORTS_TCP}" ]; then
einfo "Using TCP ports ${AMANDA_PORTS_TCP/,/-}"
myconf="${myconf} --with-tcpportrange=${AMANDA_PORTS_TCP}"
fi
if [ -n "${AMANDA_PORTS}" ]; then
einfo "Using ports ${AMANDA_PORTS/,/-}"
myconf="${myconf} --with-portrange=${AMANDA_PORTS}"
fi

# Extras
# Speed option
myconf="${myconf} --with-buffered-dump"
# "debugging" in the configuration is NOT debug in the conventional sense.
# It is actually just useful output in the application, and should remain
# enabled. There are some cases of breakage with MTX tape changers as of
# 2.5.1p2 that it exposes when turned off as well.
myconf="${myconf} --with-debugging"
# Where to put our files
myconf="${myconf} --localstatedir=${AMANDA_USER_HOMEDIR}"

# Samba support
myconf="${myconf} `use_with samba smbclient /usr/bin/smbclient`"

# Support for BSD, SSH, BSDUDP, BSDTCP security methods all compiled in by
# default
myconf="${myconf} --with-bsd-security"
myconf="${myconf} --with-ssh-security"
myconf="${myconf} --with-bsdudp-security"
myconf="${myconf} --with-bsdtcp-security"

# kerberos-security mechanism version 4
# always disable, per bug #173354
myconf="${myconf} --without-krb4-security"

# kerberos-security mechanism version 5
myconf="${myconf} `use_with kerberos krb5-security`"

# Force the correct TAR
myconf="${myconf} --with-gnutar=/bin/tar"

# Client only, as requested in bug #127725
use minimal && myconf="${myconf} --without-server"

econf ${myconf} || die "econf failed!"
emake -j1 || die "emake failed!"

# Compile the tapetype program too
# This is deprecated, use amtapetype instead!
# cd tape-src
# emake tapetype || die "emake tapetype failed!"

# Only needed if you we do versioning
#dosed "s,/usr/local/bin/perl,/usr/bin/perl," ${S}/contrib/set_prod_link.pl
#perl ${S}/contrib/set_prod_link.pl

}

src_install() {
[ ! -f "${TMPENVFILE}" ] && die "Variable setting file (${TMPENVFILE}) should exist!"
source ${TMPENVFILE}

einfo "Doing stock install"
emake -j1 DESTDIR="${D}" install || die

# Prepare our custom files
einfo "Building custom configuration files"
cp "${FILESDIR}"/amanda-* "${MYFILESDIR}"
local i # our iterator
local sedexpr # var for sed expr
sedexpr=''
for i in AMANDA_GROUP_GID AMANDA_GROUP_NAME AMANDA_USER_NAME \
AMANDA_USER_UID AMANDA_USER_SH AMANDA_USER_HOMEDIR \
AMANDA_USER_GROUPS AMANDA_SERVER AMANDA_SERVER_TAPE \
AMANDA_SERVER_INDEX AMANDA_TAR_LISTDIR AMANDA_CONFIG_NAME \
AMANDA_TMPDIR AMANDA_PORTS_UDP AMANDA_PORTS_TCP \
AMANDA_PORTS_BOTH AMANDA_PORTS; do
local val
eval "val=\"\${${i}}\""
sedexpr="${sedexpr}s|__${i}__|${val}|g;"
done
#einfo "Compiled SED expression: '${sedexpr}'"

# now apply the sed expr
for i in "${FILESDIR}"/amanda-* ; do
local filename
filename="`basename ${i}`"
#einfo "Applying compiled SED expression to ${filename}"
sed -re "${sedexpr}" <"${i}" >"${MYFILESDIR}"/${filename}
done

# Build the envdir file
# Don't forget this..
einfo "Building environment file"
local t
t="${MYFILESDIR}"/${ENVDFILE}
echo "# These settings are what was present in the environment when this" >>"${t}"
echo "# Amanda was compiled. Changing anything below this comment will" >>"${t}"
echo "# have no effect on your application, but it merely exists to" >>"${t}"
echo "# preserve them for your next emerge of Amanda" >>"${t}"
cat "${TMPENVFILE}" | sed "s,=\$,='',g" >>"${t}"

into /usr

# Deprecated, use amtapetype instead
#einfo "Installing tapetype utility"
#newsbin tape-src/tapetype tapetype

# docs
einfo "Installing documentation"
dodoc AUTHORS C* INSTALL NEWS README
# Clean up some bits
dodoc /usr/share/amanda/*
rm -rf "${D}"/usr/share/amanda
mkdir -p "${D}"/${MYINSTTMPDIR} || die
cp "${TMPENVFILE}" "${D}"/${TMPINSTENVFILE} || die
# our inetd sample
einfo "Installing standard inetd sample"
newdoc "${MYFILESDIR}"/amanda-inetd.amanda.sample-2.5.1_p3-r1 amanda-inetd.amanda.sample
# Stock extra docs
docinto docs
dodoc "${S}"/docs/*
# Labels
einfo "Installing labels"
docinto labels
dodoc "${S}"/example/3hole.ps
dodoc "${S}"/example/8.5x11.ps
dodoc "${S}"/example/DIN-A4.ps
dodoc "${S}"/example/DLT.ps
dodoc "${S}"/example/EXB-8500.ps
dodoc "${S}"/example/HP-DAT.ps
# Amanda example configs
einfo "Installing example configurations"
docinto example
dodoc "${S}"/example/*
docinto example1
newdoc "${FILESDIR}"/example_amanda.conf amanda.conf
newdoc "${FILESDIR}"/example_disklist-2.5.1_p3-r1 disklist
newdoc "${FILESDIR}"/example_global.conf global.conf
docinto example2
newdoc "${S}"/example/amanda.conf amanda.conf
newdoc "${S}"/example/disklist disklist
# Compress it all
prepalldocs

# Just make sure it exists for XFS to work...
use !sparc && use xfs && keepdir /var/xfsdump/inventory

insinto /etc/amanda
einfo "Installing .amandahosts File for ${AMANDA_USER_NAME} user"

cat "${MYFILESDIR}"/amanda-amandahosts-client-2.5.1_p3-r1 \
>>"${D}"/etc/amanda/amandahosts
use minimal \
|| cat "${MYFILESDIR}"/amanda-amandahosts-server-2.5.1_p3-r1 \
>>"${D}"/etc/amanda/amandahosts

dosym /etc/amanda/amandahosts "${AMANDA_USER_HOMEDIR}"/.amandahosts
insinto "${AMANDA_USER_HOMEDIR}"
einfo "Installing .profile for ${AMANDA_USER_NAME} user"
newins "${MYFILESDIR}"/amanda-profile .profile

einfo "Installing Sample Daily Cron Job for Amanda"
CRONDIR=/etc/cron.daily/
exeinto ${CRONDIR}
newexe "${MYFILESDIR}"/amanda-cron amanda
# Not executable by default
fperms 644 ${CRONDIR}/amanda

insinto /etc/amanda/${AMANDA_CONFIG_NAME}
keepdir /etc/amanda
keepdir /etc/amanda/${AMANDA_CONFIG_NAME}

local i
for i in ${AMANDA_USER_HOMEDIR} ${AMANDA_TAR_LISTDIR} \
${AMANDA_TMPDIR} ${AMANDA_TMPDIR}/dumps \
${AMANDA_USER_HOMEDIR}/${AMANDA_CONFIG_NAME} \
/etc/amanda /etc/amanda/${AMANDA_CONFIG_NAME}; do
einfo "Securing directory (${i})"
dodir ${i}
keepdir ${i}
fowners ${AMANDA_USER_NAME}:${AMANDA_GROUP_NAME} ${i}
fperms 700 ${i}
done

einfo "Setting setuid permissions"
amanda_permissions_fix "${D}"

# DevFS
einfo "Installing DevFS config file"
insinto /etc/devfs.d
newins "${MYFILESDIR}"/amanda-devfs amanda

# Env.d
einfo "Installing environment config file"
doenvd "${MYFILESDIR}"/${ENVDFILE}

# Installing Amanda Xinetd Services Definition
einfo "Installing xinetd service file"
insinto /etc/xinetd.d
newins "${MYFILESDIR}"/amanda-xinetd-2.5.1_p3-r1 amanda

}

pkg_postinst() {
local aux="${ROOT}"/${TMPINSTENVFILE}
[ ! -f "${aux}" ] && die "Variable setting file (${aux}) should exist!"
source "${aux}"
rm "${aux}"
rmdir "${ROOT}"/${MYINSTTMPDIR} 2>/dev/null # ignore error

local i
for i in amandates dumpdates; do
einfo "Creating inital Amanda file (${i})"
touch "${ROOT}"/etc/${i}
chown ${AMANDA_USER_NAME}:${AMANDA_GROUP_NAME} "${ROOT}"/etc/${i}
chmod 600 "${ROOT}"/etc/${i}
done

# If USE=minimal, give out a warning, if AMANDA_SERVER is not set to
# another host than HOSTNAME.
if use minimal; then
if [[ "${AMANDA_SERVER}" = "${HOSTNAME}" ]]; then
echo
ewarn "You are installing a client-only version of Amanda."
ewarn "You should set the variable $AMANDA_SERVER to point at your"
ewarn "Amanda-tape-server, otherwise you will have to specify its name"
ewarn "when using amrecover on the client."
ewarn "For example: Use something like"
ewarn "AMANDA_SERVER=\"myserver\" emerge amanda"
echo
fi
fi

einfo "Checking setuid permissions"
amanda_permissions_fix "${ROOT}"

elog "You should configure Amanda in /etc/amanda now."
elog
elog "If you use xinetd, Don't forget to check /etc/xinetd.d/amanda"
elog "and restart xinetd afterwards!"
elog
elog "Otherwise, please look at /usr/share/doc/${P}/inetd.amanda.sample"
elog "as an example of how to configure your inetd."
elog
elog "NOTICE: If you need raw access to partitions you need to add the"
elog "amanda user to the 'disk' group and uncomment following lines in"
elog "your /etc/devfs.d/amanda:"
elog "SCSI:"
elog "REGISTER ^scsi/host.*/bus.*/target.*/lun.*/part[0-9] PERMISSIONS root.disk 660"
elog "IDE:"
elog "REGISTER ^ide/host.*/bus.*/target.*/lun.*/part[0-9] PERMISSIONS root.disk 660"
elog
elog "NOTICE: If you have a tape changer, also uncomment the following"
elog "REGISTER ^scsi/host.*/bus.*/target.*/lun.*/generic PERMISSIONS root.disk 660"
elog
elog "If you use localhost in your disklist your restores may break."
elog "You should replace it with the actual hostname!"
elog "Please also see the syntax changes to amandahosts."
}

# We have had reports of amanda file permissions getting screwed up.
# Losing setuid, becoming too lax etc.
# ONLY root and users in the amanda group should be able to run these binaries!
amanda_permissions_fix() {
local root="$1"
[ -z "${root}" ] && die "Failed to pass root argument to amanda_permissions_fix!"
for i in /usr/sbin/amcheck /usr/libexec/calcsize /usr/libexec/killpgrp \
/usr/libexec/rundump /usr/libexec/runtar /usr/libexec/dumper \
/usr/libexec/planner ; do
chown root:${AMANDA_GROUP_NAME} "${root}"/${i}
chmod u=srwx,g=rx,o= "${root}"/${i}
done
}

amanda-2.5.2_p1-r2.ebuild

# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-backup/amanda/amanda-2.5.2_p1-r2.ebuild,v 1.3 2007/10/09 09:23:15 robbat2 Exp $

inherit eutils

DESCRIPTION="The Advanced Maryland Automatic Network Disk Archiver"
HOMEPAGE="http://www.amanda.org/"
SRC_URI="mirror://sourceforge/amanda/${P/_/}.tar.gz"
LICENSE="as-is"
SLOT="0"
KEYWORDS="~amd64 ~ppc ~ppc64 ~sparc ~x86"
RDEPEND="sys-libs/readline
virtual/inetd
sys-apps/gawk
app-arch/tar
dev-lang/perl
app-arch/dump
net-misc/openssh
samba? ( net-fs/samba )
berkdb? ( sys-libs/db )
kerberos? ( app-crypt/mit-krb5 )
gdbm? ( sys-libs/gdbm )
!sparc? ( xfs? ( sys-fs/xfsdump ) )
!minimal? ( virtual/mailx
app-arch/mt-st
sys-block/mtx
sci-visualization/gnuplot
app-crypt/aespipe
app-crypt/gnupg )"

DEPEND="${RDEPEND}
sys-devel/autoconf
sys-devel/automake"

IUSE="berkdb debug gdbm minimal samba xfs kerberos"

S="${WORKDIR}/${P/_/}"
MYFILESDIR="${WORKDIR}/files"
MYTMPDIR="${WORKDIR}/tmp"
MYINSTTMPDIR="/usr/share/amanda"
ENVDIR="/etc/env.d"
ENVDFILE="97amanda"
TMPENVFILE="${MYTMPDIR}/${ENVDFILE}"
TMPINSTENVFILE="${MYINSTTMPDIR}/tmpenv-${ENVDFILE}"

# This is a complete list of Amanda settings that the ebuild takes from the
# build environment. This allows users to alter the behavior of the package as
# upstream intended, but keeping with Gentoo style. We store a copy of them in
# /etc/env.d/97amanda during the install, so that they are preserved for future
# installed.
AMANDA_ENV_SETTINGS="
AMANDA_GROUP_GID AMANDA_GROUP_NAME
AMANDA_USER_NAME AMANDA_USER_UID AMANDA_USER_SH AMANDA_USER_HOMEDIR AMANDA_USER_GROUPS
AMANDA_SERVER AMANDA_SERVER_TAPE AMANDA_SERVER_INDEX
AMANDA_TAR_LISTDIR AMANDA_TAR
AMANDA_PORTS_UDP AMANDA_PORTS_TCP AMANDA_PORTS_BOTH AMANDA_PORTS
AMANDA_CONFIG_NAME AMANDA_TMPDIR AMANDA_DBMODE"

amanda_variable_setup() {

# Setting vars
local currentamanda

# Grab the current settings
currentamanda="$(set | egrep "^AMANDA_" | xargs)"
use debug && einfo "Current settings: ${currentamanda}"
#for i in ${currentamanda}; do
# eval `eval echo ${i}`
# echo "Setting: ${i}"
#done;

# First we set the defaults
[ -z "${AMANDA_GROUP_GID}" ] && AMANDA_GROUP_GID=87
[ -z "${AMANDA_GROUP_NAME}" ] && AMANDA_GROUP_NAME=amanda
[ -z "${AMANDA_USER_NAME}" ] && AMANDA_USER_NAME=amanda
[ -z "${AMANDA_USER_UID}" ] && AMANDA_USER_UID=87
[ -z "${AMANDA_USER_SH}" ] && AMANDA_USER_SH=-1
[ -z "${AMANDA_USER_HOMEDIR}" ] && AMANDA_USER_HOMEDIR=/var/spool/amanda
[ -z "${AMANDA_USER_GROUPS}" ] && AMANDA_USER_GROUPS="${AMANDA_GROUP_NAME}"

# This installs Amanda, with the server. However, it could be a client,
# just specify an alternate server name in AMANDA_SERVER.
[ -z "${AMANDA_SERVER}" ] && AMANDA_SERVER="${HOSTNAME}"
[ -z "${AMANDA_SERVER_TAPE}" ] && AMANDA_SERVER_TAPE="${AMANDA_SERVER}"
[ -z "${AMANDA_SERVER_INDEX}" ] && AMANDA_SERVER_INDEX="${AMANDA_SERVER}"
[ -z "${AMANDA_TAR_LISTDIR}" ] && AMANDA_TAR_LISTDIR=${AMANDA_USER_HOMEDIR}/tar-lists
[ -z "${AMANDA_CONFIG_NAME}" ] && AMANDA_CONFIG_NAME=DailySet1
[ -z "${AMANDA_TMPDIR}" ] && AMANDA_TMPDIR=/var/tmp/amanda
[ -z "${AMANDA_DBGDIR}" ] && AMANDA_DBGDIR="$AMANDA_TMPDIR"
# These are left empty by default
[ -z "${AMANDA_PORTS_UDP}" ] && AMANDA_PORTS_UDP=
[ -z "${AMANDA_PORTS_TCP}" ] && AMANDA_PORTS_TCP=
[ -z "${AMANDA_PORTS_BOTH}" ] && AMANDA_PORTS_BOTH=
[ -z "${AMANDA_PORTS}" ] && AMANDA_PORTS=

# This one is a little more complicated
# The priority list is this:
# 1. 'Berkely DB style' (only if USE="berkdb")
# 2. 'GDBM style' (only if USE="gdbm")
# 3. 'Text style'
[ -z "${AMANDA_DBMODE}" ] && use berkdb && AMANDA_DBMODE=db
[ -z "${AMANDA_DBMODE}" ] && use gdbm && AMANDA_DBMODE=gdbm
[ -z "${AMANDA_DBMODE}" ] && AMANDA_DBMODE=text

# What tar to use
[ -z "${AMANDA_TAR}" ] && AMANDA_TAR=/bin/tar

# Now pull in the old stuff
if [ -f "${ENVDIR}/${ENVDFILE}" ]; then
# We don't just source it as we don't want everything in there.
eval $(egrep "^AMANDA_" ${ENVDIR}/${ENVDFILE})
fi

# Re-apply the new settings if any
[ -n "${currentamanda}" ] && eval `echo "${currentamanda}"`

}

pkg_setup() {
# Now add users if needed
amanda_variable_setup
enewgroup "${AMANDA_GROUP_NAME}" "${AMANDA_GROUP_GID}"
enewuser "${AMANDA_USER_NAME}" "${AMANDA_USER_UID}" "${AMANDA_USER_SH}" "${AMANDA_USER_HOMEDIR}" "${AMANDA_USER_GROUPS}"
}

src_unpack() {
unpack "${A}"

# now the real fun
amanda_variable_setup
# places for us to work in
mkdir -p "${MYFILESDIR}" "${MYTMPDIR}"
# Now we store the settings we just created
set | egrep "^AMANDA_" > "${TMPENVFILE}"
}

src_compile() {
# fix bug #36316
addpredict /var/cache/samba/gencache.tdb

[ ! -f "${TMPENVFILE}" ] && die "Variable setting file (${TMPENVFILE}) should exist!"
source "${TMPENVFILE}"
local myconf
cd "${S}"

einfo "Using '${AMANDA_DBMODE}' style database"
myconf="${myconf} --with-db=${AMANDA_DBMODE}"
einfo "Using ${AMANDA_SERVER_TAPE} for tape server."
myconf="${myconf} --with-tape-server=${AMANDA_SERVER_TAPE}"
einfo "Using ${AMANDA_SERVER_INDEX} for index server."
myconf="${myconf} --with-index-server=${AMANDA_SERVER_INDEX}"
einfo "Using ${AMANDA_USER_NAME} for amanda user."
myconf="${myconf} --with-user=${AMANDA_USER_NAME}"
einfo "Using ${AMANDA_GROUP_NAME} for amanda group."
myconf="${myconf} --with-group=${AMANDA_GROUP_NAME}"
einfo "Using ${AMANDA_TAR} as Tar implementation."
myconf="${myconf} --with-gnutar=${AMANDA_TAR}"
einfo "Using ${AMANDA_TAR_LISTDIR} as tar listdir."
myconf="${myconf} --with-gnutar-listdir=${AMANDA_TAR_LISTDIR}"
einfo "Using ${AMANDA_CONFIG_NAME} as default config name."
myconf="${myconf} --with-config=${AMANDA_CONFIG_NAME}"
einfo "Using ${AMANDA_TMPDIR} as Amanda temporary directory."
myconf="${myconf} --with-tmpdir=${AMANDA_TMPDIR}"

if [ -n "${AMANDA_PORTS_UDP}" ] && [ -n "${AMANDA_PORTS_TCP}" ] && [ -z "${AMANDA_PORTS_BOTH}" ] ; then
eerror "If you want _both_ UDP and TCP ports, please use only the"
eerror "AMANDA_PORTS environment variable for identical ports, or set"
eerror "AMANDA_PORTS_BOTH."
die "Bad port setup!"
fi
if [ -n "${AMANDA_PORTS_UDP}" ]; then
einfo "Using UDP ports ${AMANDA_PORTS_UDP/,/-}"
myconf="${myconf} --with-udpportrange=${AMANDA_PORTS_UDP}"
fi
if [ -n "${AMANDA_PORTS_TCP}" ]; then
einfo "Using TCP ports ${AMANDA_PORTS_TCP/,/-}"
myconf="${myconf} --with-tcpportrange=${AMANDA_PORTS_TC