Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
144fbefb
Kaydet (Commit)
144fbefb
authored
Kas 07, 2012
tarafından
Caolán McNamara
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
refactor packconfig to hopefully be unchanged, but extendable
Change-Id: I25fe2f7e3277bd9a9509b0bec81f8d76b2bf8c8f
üst
0ab64210
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
36 deletions
+43
-36
packconfig.pl
postprocess/packconfig/packconfig.pl
+43
-36
No files found.
postprocess/packconfig/packconfig.pl
Dosyayı görüntüle @
144fbefb
...
...
@@ -31,12 +31,10 @@ use Archive::Zip qw(:ERROR_CODES :CONSTANTS);
#### globals ####
my
$out_file
;
# path to output archive
my
$tmp_out_file
;
# path to temporary output file
my
$out_path
;
# path to output archives in
my
$files_path
;
# path to look for desired files
my
$verbose
;
# be verbose
my
$extra_verbose
;
# be extra verbose
my
$do_rebuild
=
0
;
# is rebuilding zipfile required?
#### script id #####
...
...
@@ -46,21 +44,37 @@ my $do_rebuild = 0; # is rebuilding zipfile required?
parse_options
();
my
%
files_hash
;
my
$file_ref
=
get_files
();
my
$file_ref
=
get_core_files
(
\%
files_hash
);
my
$out_file
=
"$out_path"
.
"uiconfig.zip"
;
packzip
(
\%
files_hash
,
$out_file
);
exit
(
0
);
$do_rebuild
=
is_file_newer
(
\%
files_hash
)
if
$do_rebuild
==
0
;
#### subroutines ####
if
(
$do_rebuild
==
1
)
{
create_zip_archive
(
\%
files_hash
);
replace_file
(
$tmp_out_file
,
$out_file
);
print_message
(
"packing $out_file finished."
);
}
else
{
print_message
(
"$out_file up to date. nothing to do."
);
}
sub
packzip
{
my
$file_hash_ref
=
shift
;
my
$output_file
=
shift
;
exit
(
0
);
# Check if output_file can be written.
my
$out_dir
=
dirname
(
$output_file
);
print_error
(
"no such directory: '$out_dir'"
,
2
)
if
!
-
d
$out_dir
;
print_error
(
"can't search directory: '$out_dir'"
,
2
)
if
!
-
x
$out_dir
;
print_error
(
"directory is not writable: '$out_dir'"
,
2
)
if
!
-
w
$out_dir
;
#### subroutines ####
# is rebuilding zipfile required?
my
$do_rebuild
=
is_file_newer
(
$file_hash_ref
,
$output_file
);
if
(
$do_rebuild
==
1
)
{
#temporary intermediate output file
my
$tmp_out_file
=
"$output_file"
.
"$$"
.
$ENV
{
INPATH
};
create_zip_archive
(
$file_hash_ref
,
$tmp_out_file
);
replace_file
(
$tmp_out_file
,
$output_file
);
print_message
(
"packing $output_file finished."
);
}
else
{
print_message
(
"$output_file up to date. nothing to do."
);
}
}
sub
parse_options
{
...
...
@@ -68,28 +82,18 @@ sub parse_options
my
$p
=
Getopt::Long::
Parser
->
new
();
my
$success
=
$p
->
getoptions
(
'-h'
=>
\
$opt_help
,
'-o=s'
=>
\
$out_
file
,
'-o=s'
=>
\
$out_
path
,
'-i=s'
=>
\
$files_path
,
'-v'
=>
\
$verbose
,
'-vv'
=>
\
$extra_verbose
);
if
(
$opt_help
||
!
$success
||
!
$out_
file
||
!
$files_path
)
if
(
$opt_help
||
!
$success
||
!
$out_
path
||
!
$files_path
)
{
usage
();
exit
(
1
);
}
#define intermediate output file
$tmp_out_file
=
"$out_file"
.
"$$"
.
$ENV
{
INPATH
};
# Sanity checks.
# Check if out_file can be written.
my
$out_dir
=
dirname
(
$out_file
);
print_error
(
"no such directory: '$out_dir'"
,
2
)
if
!
-
d
$out_dir
;
print_error
(
"can't search directory: '$out_dir'"
,
2
)
if
!
-
x
$out_dir
;
print_error
(
"directory is not writable: '$out_dir'"
,
2
)
if
!
-
w
$out_dir
;
# Check paths.
foreach
(
$files_path
)
{
print_error
(
"no such directory: '$_'"
,
2
)
if
!
-
d
$_
;
...
...
@@ -97,11 +101,12 @@ sub parse_options
}
}
sub
get_files
sub
get_
core_
files
{
local
@
main::
file_list
;
find_files
(
\%
files_hash
);
my
$files_hash_ref
=
shift
;
find_core_files
(
$files_hash_ref
);
if
(
!
keys
%
files_hash
)
{
print_error
(
"can't find any image lists in '$files_path'"
,
3
);
...
...
@@ -110,7 +115,7 @@ sub get_files
return
wantarray
?
@
main::
file_list
:
\
@
main::
file_list
;
}
sub
find_files
sub
find_
core_
files
{
my
$files_hash_ref
=
shift
;
find
({
wanted
=>
\&
wanted
,
no_chdir
=>
0
},
"$files_path"
);
...
...
@@ -132,12 +137,13 @@ sub wanted
sub
is_file_newer
{
my
$test_hash_ref
=
shift
;
my
$zip_file
=
shift
;
my
$reference_stamp
=
0
;
print_message
(
"checking timestamps ..."
)
if
$verbose
;
if
(
-
e
$
out
_file
)
{
$reference_stamp
=
(
stat
(
$
out
_file
))[
9
];
print_message
(
"found $
out
_file with $reference_stamp ..."
)
if
$verbose
;
print_message
(
"checking timestamps
for $zip_file
..."
)
if
$verbose
;
if
(
-
e
$
zip
_file
)
{
$reference_stamp
=
(
stat
(
$
zip
_file
))[
9
];
print_message
(
"found $
zip
_file with $reference_stamp ..."
)
if
$verbose
;
}
return
1
if
$reference_stamp
==
0
;
...
...
@@ -155,6 +161,7 @@ sub is_file_newer
sub
create_zip_archive
{
my
$zip_hash_ref
=
shift
;
my
$zip_output_file
=
shift
;
print_message
(
"creating config archive ..."
)
if
$verbose
;
my
$zip
=
Archive::
Zip
->
new
();
...
...
@@ -173,9 +180,9 @@ sub create_zip_archive
print_error
(
"can't add file '$path' to config zip archive: $!"
,
5
);
}
}
my
$status
=
$zip
->
writeToFileNamed
(
$
tmp_o
ut_file
);
my
$status
=
$zip
->
writeToFileNamed
(
$
zip_outp
ut_file
);
if
(
$status
!=
AZ_OK
)
{
print_error
(
"write image zip archive '$
tmp_o
ut_file' failed. Reason: $status"
,
6
);
print_error
(
"write image zip archive '$
zip_outp
ut_file' failed. Reason: $status"
,
6
);
}
return
;
}
...
...
@@ -235,7 +242,7 @@ sub usage
print
STDERR
"Creates archive of userinterface config files\n"
;
print
STDERR
"Options:\n"
;
print
STDERR
" -h print this help\n"
;
print
STDERR
" -o out_
file
path to output archive\n"
;
print
STDERR
" -o out_
path
path to output archive\n"
;
print
STDERR
" -i file_path path to directory containing the config files\n"
;
print
STDERR
" -v verbose\n"
;
print
STDERR
" -vv very verbose\n"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment