/[smeserver]/rpms/e-smith-devtools/sme10/e-smith-devtools-2.6.0-bz11993-backup.patch
ViewVC logotype

Annotation of /rpms/e-smith-devtools/sme10/e-smith-devtools-2.6.0-bz11993-backup.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Tue Jun 14 04:12:44 2022 UTC (2 years, 5 months ago) by jpp
Branch: MAIN
CVS Tags: e-smith-devtools-2_6_0-12_el7_sme, e-smith-devtools-2_6_0-11_el7_sme
* Tue Jun 14 2022 Jean-Philippe Pialasse <tests@pialasse.com> 2.6.0-11.sme
- ease backup include and exclude of contribs [SME: 11993]

1 jpp 1.1 diff -Nur --no-dereference e-smith-devtools-2.6.0.old/Backup.pm e-smith-devtools-2.6.0/Backup.pm
2     --- e-smith-devtools-2.6.0.old/Backup.pm 1969-12-31 19:00:00.000000000 -0500
3     +++ e-smith-devtools-2.6.0/Backup.pm 2022-06-14 00:05:43.785000000 -0400
4     @@ -0,0 +1,136 @@
5     +#----------------------------------------------------------------------
6     +# copyright (C) 2013-2022 Koozali Foundation
7     +#
8     +# This program is free software; you can redistribute it and/or modify
9     +# it under the terms of the GNU General Public License as published by
10     +# the Free Software Foundation; either version 2 of the License, or
11     +# (at your option) any later version.
12     +#
13     +# This program is distributed in the hope that it will be useful,
14     +# but WITHOUT ANY WARRANTY; without even the implied warranty of
15     +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16     +# GNU General Public License for more details.
17     +#
18     +# You should have received a copy of the GNU General Public License
19     +# along with this program; if not, write to the Free Software
20     +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21     +#
22     +#----------------------------------------------------------------------
23     +package esmith::Build::Backup;
24     +
25     +use strict;
26     +use warnings;
27     +use Exporter;
28     +use File::Basename;
29     +use File::Path;
30     +
31     +our @ISA = qw(Exporter);
32     +our @EXPORT = qw();
33     +our @EXPORT_OK = qw(
34     + backup_excludes
35     + backup_includes
36     + );
37     +our %EXPORT_TAGS = (
38     + all => [ qw!backup_excludes backup_includes! ]
39     + );
40     +
41     +our $VERSION = sprintf '%d.%03d', q$Revision: 1.0 $ =~ /: (\d+).(\d+)/;
42     +
43     +=head1 NAME
44     +
45     +esmith::Build::Backup - A library for creating backup include and exclude during rpm construction.
46     +
47     +=head1 SYNOPSIS
48     +
49     + use esmith::Build::Backup qw(:all);
50     +
51     + backup_includes("smeserver-ContribName", qw(/list/of/path /you/need/to /include/to /backup));
52     +
53     +=head1 DESCRIPTION
54     +
55     +=cut
56     +
57     +=head2 backup_includes
58     +
59     +This function populates both /etc/backup-data.d/ for core console backup and template for
60     +/etc/dar/DailyBackup.dcf which is dar workstation backup file, if the directories do
61     +not exist, it will create them.
62     +
63     + ie. backup_includes("smeserver-ContribName", qw(/list/of/path /you/need/to /include/to /backup))
64     +
65     +=cut
66     +sub backup_includes
67     +{
68     + my ($name, @paths) = @_;
69     + my $dir = "root/etc/e-smith/templates/etc/dar/DailyBackup.dcf";
70     + my $core = "root/etc/backup-data.d";
71     + my $filename = "$dir/41go-into-$name";
72     + my $corefilename = "$core/${name}.include";
73     +
74     + unless (-d $dir)
75     + {
76     + mkpath $dir or die "Could not create dir $dir: $!";
77     + }
78     + unless (-d $core)
79     + {
80     + mkpath $core or die "Could not create dir $core: $!";
81     + }
82     +
83     + open(FH, '>', $filename) or die $!;
84     + open(CFH, '>', $corefilename) or die $!;
85     + foreach my $str (@paths)
86     + {
87     + $str =~ s|/$||;
88     + print CFH "$str\n";
89     + $str =~ s|^/||;
90     + print FH "--go-into $str\n";
91     + }
92     + close(FH);
93     + close(CFH);
94     + # add template expand to smeserver-ContribName-update
95     + use esmith::Build::CreateLinks qw(templates2events);
96     + templates2events("/etc/dar/DailyBackup.dcf","${name}-update");
97     +}
98     +
99     +=head2 backup_excludes
100     +
101     +This function populates both /etc/backup-data.d/ for core console backup and template for
102     +/etc/dar/DailyBackup.dcf which is dar workstation backup file, if the directories do
103     +not exist, it will create them.
104     +
105     + ie. backup_excludes("smeserver-ContribName", qw(/list/of/path /you/need/to /exclude/from /backup))
106     +
107     +=cut
108     +sub backup_excludes
109     +{
110     + my ($name, @paths) = @_;
111     + my $dir = "root/etc/e-smith/templates/etc/dar/DailyBackup.dcf";
112     + my $core = "root/etc/backup-data.d";
113     + my $filename = "$dir/46prune-$name";
114     + my $corefilename = "$core/${name}.exclude";
115     +
116     + unless (-d $dir)
117     + {
118     + mkpath $dir or die "Could not create dir $dir: $!";
119     + }
120     + unless (-d $core)
121     + {
122     + mkpath $core or die "Could not create dir $core: $!";
123     + }
124     +
125     + open(FH, '>', $filename) or die $!;
126     + open(CFH, '>', $corefilename) or die $!;
127     + foreach my $str (@paths)
128     + {
129     + $str =~ s|/$||;
130     + print CFH "$str\n";
131     + $str =~ s|^/||;
132     + print FH "--prune $str\n";
133     + }
134     + close(FH);
135     + close(CFH);
136     + # add template expand to smeserver-ContribName-update
137     + use esmith::Build::CreateLinks qw(templates2events);
138     + templates2events("/etc/dar/DailyBackup.dcf","${name}-update");
139     +}
140     +

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed