Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
chromebrew
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
chromebrew
Commits
31b2f7a4
Commit
31b2f7a4
authored
Jun 08, 2017
by
lyxell
Committed by
GitHub
Jun 08, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #717 from jam7/refactor/dependency
Refactor dependency expansion
parents
adee0e73
864d2b33
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
22 deletions
+34
-22
crew
crew
+31
-20
lib/package.rb
lib/package.rb
+3
-2
No files found.
crew
View file @
31b2f7a4
...
...
@@ -312,7 +312,7 @@ def resolve_dependencies_and_install
begin
origin
=
@pkg
.
name
resolve
D
ependencies
resolve
_d
ependencies
search
origin
,
true
install
...
...
@@ -329,51 +329,62 @@ def resolve_dependencies_and_install
end
end
def
resolveD
ependencies
def
expand_d
ependencies
@dependencies
=
[]
# check source packages existance
@source_package
=
0
def
push_dependencies
if
@pkg
.
is_binary?
(
@device
[
:architecture
])
if
@pkg
.
is_binary?
(
@device
[
:architecture
])
||
(
!
@pkg
.
in_upgrade
&&
@device
[
:installed_packages
].
any?
{
|
pkg
|
pkg
[
:name
]
==
@pkg
.
name
})
# retrieve name of dependencies that doesn't contain :build tag
@
check_deps
=
@pkg
.
dependencies
.
select
{
|
k
,
v
|
!
v
.
include?
(
:build
)}.
map
{
|
k
,
v
|
k
}
check_deps
=
@pkg
.
dependencies
.
select
{
|
k
,
v
|
!
v
.
include?
(
:build
)}.
map
{
|
k
,
v
|
k
}
elsif
@pkg
.
is_fake?
# retrieve name of all dependencies
@
check_deps
=
@pkg
.
dependencies
.
map
{
|
k
,
v
|
k
}
check_deps
=
@pkg
.
dependencies
.
map
{
|
k
,
v
|
k
}
else
# retrieve name of all dependencies
@
check_deps
=
@pkg
.
dependencies
.
map
{
|
k
,
v
|
k
}
check_deps
=
@pkg
.
dependencies
.
map
{
|
k
,
v
|
k
}
# count the number of source packages to add buildessential into dependencies later
@source_package
+=
1
end
if
@check_deps
&&
!
@check_deps
.
empty?
@dependencies
.
unshift
@check_deps
@check_deps
.
each
do
|
dep
|
search
dep
,
true
push_dependencies
end
# remove a dependent package which is equal to the target
check_deps
.
select!
{
|
name
|
@pkgName
!=
name
}
# add new dependencies at the beginning of array
@dependencies
=
check_deps
.
clone
.
concat
(
@dependencies
)
# check all dependencies recursively
check_deps
.
each
do
|
dep
|
search
dep
,
true
push_dependencies
end
end
push_dependencies
# Add buildessential
and solve it
s dependencies if any of dependent
# Add buildessential
'
s dependencies if any of dependent
# packages are made from source
if
@source_package
>
0
@dependencies
.
unshift
'buildessential'
search
'buildessential'
,
true
push_dependencies
end
push_dependencies
@dependencies
.
uniq
end
def
resolve_dependencies
dependencies
=
expand_dependencies
# leave only not installed packages in dependencies
dependencies
.
select!
{
|
name
|
@device
[
:installed_packages
].
none?
{
|
pkg
|
pkg
[
:name
]
==
name
}}
return
if
@
dependencies
.
empty?
return
if
dependencies
.
empty?
puts
"Following packages also need to be installed: "
@dependencies
.
flatten!
.
uniq!
@dependencies
.
each
do
|
dep
|
dependencies
.
each
do
|
dep
|
print
dep
+
" "
end
...
...
@@ -392,7 +403,7 @@ def resolveDependencies
end
if
proceed
@
dependencies
.
each
do
|
dep
|
dependencies
.
each
do
|
dep
|
search
dep
install
end
...
...
@@ -451,7 +462,7 @@ def resolve_dependencies_and_build
# mark current package as which is required to compile from source
@pkg
.
build_from_source
=
true
resolve
D
ependencies
resolve
_d
ependencies
search
origin
,
true
build_package
Dir
.
pwd
...
...
lib/package.rb
View file @
31b2f7a4
...
...
@@ -12,8 +12,9 @@ class Package
@@debug_symbol
=
ENV
[
'CREW_DEBUG_SYMBOL'
]
||
false
def
self
.
dependencies
# Not sure how to initialize instance variable of not constructed class.
# Therefore, initialize it in reader function.
# We need instance variable in derived class, so not define it here,
# base class. Instead of define it, we initialize it in a function
# called from derived classees.
@dependencies
=
Hash
.
new
unless
@dependencies
@dependencies
end
...
...
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