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
75ed8ae7
Kaydet (Commit)
75ed8ae7
authored
May 23, 2013
tarafından
Michael Meeks
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
combine and layer links.txt files into the images*.zip archives.
Change-Id: I0dd6730ac3bef95843de25d6813678273cf09832
üst
2ac4beab
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
1 deletion
+67
-1
packimages.pl
solenv/bin/packimages.pl
+67
-1
No files found.
solenv/bin/packimages.pl
Dosyayı görüntüle @
75ed8ae7
...
...
@@ -27,6 +27,8 @@ use strict;
use
Getopt::
Long
;
use
File::
Find
;
use
File::
Basename
;
require
File::
Temp
;
use
File::
Temp
();
use
Archive::
Zip
qw(:ERROR_CODES :CONSTANTS)
;
#### globals ####
...
...
@@ -64,10 +66,18 @@ $do_rebuild = is_file_newer(\%image_lists_hash) if $do_rebuild == 0;
my
(
$global_hash_ref
,
$module_hash_ref
,
$custom_hash_ref
)
=
iterate_image_lists
(
$image_lists_ref
);
# custom_hash filled from filesystem lookup
find_custom
(
$custom_hash_ref
);
# build a consolidated set of links
my
%
links
;
read_links
(
\%
links
,
$global_path
);
for
my
$path
(
@custom_path
)
{
read_links
(
\%
links
,
$path
);
}
my
$zip_hash_ref
=
create_zip_list
(
$global_hash_ref
,
$module_hash_ref
,
$custom_hash_ref
);
$do_rebuild
=
is_file_newer
(
$zip_hash_ref
)
if
$do_rebuild
==
0
;
if
(
$do_rebuild
==
1
)
{
create_zip_archive
(
$zip_hash_ref
);
create_zip_archive
(
$zip_hash_ref
,
\%
links
);
replace_file
(
$tmp_out_file
,
$out_file
);
print_message
(
"packing $out_file finished."
)
if
$verbose
;
}
else
{
...
...
@@ -333,10 +343,19 @@ sub optimize_zip_layout($)
sub
create_zip_archive
{
my
$zip_hash_ref
=
shift
;
my
$links_hash_ref
=
shift
;
print_message
(
"creating image archive ..."
)
if
$verbose
;
my
$zip
=
Archive::
Zip
->
new
();
if
(
keys
%
{
$links_hash_ref
})
{
my
$linktmp
=
write_links
(
$links_hash_ref
);
my
$member
=
$zip
->
addFile
(
$linktmp
->
filename
,
"links.txt"
,
COMPRESSION_DEFLATED
);
if
(
!
$member
)
{
print_error
(
"failed to add links file: $!"
,
5
);
}
}
# FIXME: test - $member = addfile ... $member->desiredCompressionMethod( COMPRESSION_STORED );
# any measurable performance win/loss ?
foreach
(
optimize_zip_layout
(
$zip_hash_ref
)
)
{
...
...
@@ -425,3 +444,50 @@ sub print_error
}
return
;
}
sub
read_links
($$)
{
my
$links
=
shift
;
my
$path
=
shift
;
my
$fname
=
"$path/links.txt"
;
if
(
!-
f
"$fname"
)
{
print
STDERR
"no links in $fname\n"
;
return
;
}
my
$fh
;
open
(
$fh
,
$fname
)
||
die
"Can't open: $fname: $!"
;
# Syntax of links file:
# # comment
# missing-image image-to-load-instead
while
(
<
$fh
>
)
{
my
$line
=
$_
;
$line
=~
s/\r//g
;
# DOS line-feeds
$line
=~
s/\#.*$//
;
# kill comments
$line
=~
m/^\s*$/
&&
next
;
# blank lines
if
(
$line
=~
m/^([^\s]+)\s+(.*)$/
)
{
my
(
$missing
,
$replace
)
=
(
$1
,
$2
);
# enter into hash, and overwrite previous layer if necessary
$links
->
{
$1
}
=
$2
;
}
else
{
die
"Malformed links line: '$line'\n"
;
}
}
close
(
$fh
);
}
# write out the links to a tmp file
sub
write_links
($)
{
my
$links
=
shift
;
my
$tmp
=
File::
Temp
->
new
(
TEMPLATE
=>
"linksXXXXXXX"
,
UNLINK
=>
0
);
$tmp
||
die
"can't create tmp: $!"
;
for
my
$missing
(
sort
keys
%
{
$links
})
{
my
$line
=
$missing
.
" "
.
$links
->
{
$missing
}
.
"\n"
;
print
$tmp
$line
;
}
binmode
$tmp
;
# force flush
return
$tmp
;
}
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