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
1564ebf8
Verified
Commit
1564ebf8
authored
Feb 19, 2016
by
Michal 'vorner' Vaner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pkg: Fix for getting lists of files
parent
d3e03897
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
7 deletions
+35
-7
src/lib/autoload/a_05_backend.lua
src/lib/autoload/a_05_backend.lua
+4
-5
tests/backend.lua
tests/backend.lua
+31
-2
No files found.
src/lib/autoload/a_05_backend.lua
View file @
1564ebf8
...
...
@@ -31,11 +31,10 @@ local run_command = run_command
local
events_wait
=
events_wait
local
DBG
=
DBG
local
WARN
=
WARN
local
utils
=
require
"utils"
module
"backend"
require
"utils"
--[[
Configuration of the module. It is supported (yet unlikely to be
needed) to modify these variables.
...
...
@@ -348,13 +347,13 @@ function pkg_examine(dir)
Split into „lines“ separated by 0-char. Then eat leading dots and, in case
there was only a dot, replace it by /.
]]
return
utils
.
map
(
utils
.
lines2set
(
text
,
"%z"
),
function
(
f
)
return
f
:
gsub
(
"^%."
,
""
):
gsub
(
"^$"
,
"/"
)
end
)
return
utils
.
map
(
utils
.
lines2set
(
text
,
"%z"
),
function
(
f
)
return
f
:
gsub
(
"^%."
,
""
):
gsub
(
"^$"
,
"/"
)
,
true
end
)
end
local
files
,
dirs
-- One for non-directories
launch
(
data_dir
,
function
(
text
)
files
=
find_result
(
text
)
end
,
"find"
,
"!"
,
"-type"
,
"d"
,
"-print0"
)
launch
(
data_dir
,
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
,
"find"
,
"-type"
,
"d"
,
"-print0"
)
launch
(
data_dir
,
function
(
text
)
dirs
=
find_result
(
text
)
end
,
"
/usr/bin/
find"
,
"-type"
,
"d"
,
"-print0"
)
-- Wait for all asynchronous processes to finish
events_wait
(
unpack
(
events
))
-- How well did it go?
...
...
tests/backend.lua
View file @
1564ebf8
...
...
@@ -25,6 +25,8 @@ local lines2set = utils.lines2set
module
(
"backend-tests"
,
package
.
seeall
,
lunit
.
testcase
)
local
datadir
=
(
os.getenv
(
"S"
)
or
"."
)
..
"/tests/data/"
-- Tests for the block_parse function
function
test_block_parse
()
-- Simple case
...
...
@@ -236,8 +238,11 @@ local orig_status_file = B.status_file
local
orig_info_dir
=
B
.
info_dir
local
tmp_dirs
=
{}
--[[
Test the chain of functions ‒ unpack, examine
]]
function
test_pkg_unpack
()
local
fname
=
(
os.getenv
(
"S"
)
or
"."
)
..
"/tests/data/
updater.ipk"
local
fname
=
datadir
..
"
updater.ipk"
local
f
=
io.open
(
fname
)
local
input
=
f
:
read
(
"*a"
)
f
:
close
()
...
...
@@ -277,7 +282,31 @@ function test_pkg_unpack()
./data/usr/share/updater/keys/release.pem
./data/usr/share/updater/keys/standby.pem
]]
),
lines2set
(
stdout
))
end
,
nil
,
nil
,
-
1
,
-
1
,
'/bin/sh'
,
'-c'
,
"cd '"
..
path
..
"' && find"
))
end
,
function
()
chdir
(
path
)
end
,
nil
,
-
1
,
-
1
,
"/usr/bin/find"
))
local
files
,
dirs
=
B
.
pkg_examine
(
path
)
assert_table_equal
(
lines2set
(
[[/etc/init.d/updater
/etc/config/updater
/etc/ssl/updater.pem
/usr/share/updater/keys/standby.pem
/usr/share/updater/keys/release.pem
/usr/bin/updater-resume.sh
/usr/bin/updater.sh
/usr/bin/updater-unstuck.sh
/usr/bin/updater-utils.sh
/usr/bin/updater-worker.sh
/usr/bin/updater-wipe.sh]]
),
files
)
assert_table_equal
(
lines2set
(
[[/
/etc
/etc/init.d
/etc/cron.d
/etc/config
/etc/ssl
/usr
/usr/share
/usr/share/updater
/usr/share/updater/hashes
/usr/share/updater/keys
/usr/bin]]
),
dirs
)
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