Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
updater
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Michal Čihař
updater
Commits
266bc228
Verified
Commit
266bc228
authored
Feb 19, 2016
by
Michal 'vorner' Vaner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pkg: Load list of config files
parent
1564ebf8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
6 deletions
+22
-6
src/lib/autoload/a_05_backend.lua
src/lib/autoload/a_05_backend.lua
+20
-5
tests/backend.lua
tests/backend.lua
+2
-1
No files found.
src/lib/autoload/a_05_backend.lua
View file @
266bc228
...
...
@@ -331,7 +331,7 @@ function pkg_examine(dir)
local
events
=
{}
local
err
=
nil
-- Launch scans of the data directory
local
function
launch
(
dir
,
postprocess
,
...
)
local
function
launch
(
postprocess
,
...
)
local
function
cback
(
ecode
,
killed
,
stdout
,
stderr
)
if
ecode
==
0
then
postprocess
(
stdout
)
...
...
@@ -339,7 +339,7 @@ function pkg_examine(dir)
err
=
stderr
end
end
local
event
=
run_command
(
cback
,
function
()
chdir
(
dir
)
end
,
nil
,
cmd_timeout
,
cmd_kill_timeout
,
...
)
local
event
=
run_command
(
cback
,
function
()
chdir
(
d
ata_d
ir
)
end
,
nil
,
cmd_timeout
,
cmd_kill_timeout
,
...
)
table.insert
(
events
,
event
)
end
local
function
find_result
(
text
)
...
...
@@ -351,16 +351,31 @@ function pkg_examine(dir)
end
local
files
,
dirs
-- One for non-directories
launch
(
data_dir
,
function
(
text
)
files
=
find_result
(
text
)
end
,
"/usr/bin/find"
,
"!"
,
"-type"
,
"d"
,
"-print0"
)
launch
(
function
(
text
)
files
=
find_result
(
text
)
end
,
"/usr/bin/find"
,
"!"
,
"-type"
,
"d"
,
"-print0"
)
-- One for directories
launch
(
data_dir
,
function
(
text
)
dirs
=
find_result
(
text
)
end
,
"/usr/bin/find"
,
"-type"
,
"d"
,
"-print0"
)
launch
(
function
(
text
)
dirs
=
find_result
(
text
)
end
,
"/usr/bin/find"
,
"-type"
,
"d"
,
"-print0"
)
-- Get list of config files, if there are any
local
control_dir
=
dir
..
"/control"
local
cidx
=
io.open
(
control_dir
..
"/conffiles"
)
local
conffiles
=
{}
if
cidx
then
for
l
in
cidx
:
lines
()
do
local
fname
=
l
:
match
(
"^%s*/(.*%S)%s*"
)
local
function
get_hash
(
text
)
local
hash
=
text
:
match
(
"[0-9a-fA-F]+"
)
conffiles
[
fname
]
=
hash
end
launch
(
get_hash
,
"/usr/bin/md5sum"
,
fname
)
end
cidx
:
close
()
end
-- Wait for all asynchronous processes to finish
events_wait
(
unpack
(
events
))
-- How well did it go?
if
err
then
error
(
err
)
end
return
files
,
dirs
return
files
,
dirs
,
conffiles
end
return
_M
tests/backend.lua
View file @
266bc228
...
...
@@ -283,7 +283,7 @@ function test_pkg_unpack()
./data/usr/share/updater/keys/standby.pem
]]
),
lines2set
(
stdout
))
end
,
function
()
chdir
(
path
)
end
,
nil
,
-
1
,
-
1
,
"/usr/bin/find"
))
local
files
,
dirs
=
B
.
pkg_examine
(
path
)
local
files
,
dirs
,
conffiles
=
B
.
pkg_examine
(
path
)
assert_table_equal
(
lines2set
(
[[/etc/init.d/updater
/etc/config/updater
/etc/ssl/updater.pem
...
...
@@ -307,6 +307,7 @@ function test_pkg_unpack()
/usr/share/updater/hashes
/usr/share/updater/keys
/usr/bin]]
),
dirs
)
-- TODO: How about the conffiles
end
function
setup
()
...
...
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