Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
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
MyCard
magicseteditor
Commits
cf13517f
Commit
cf13517f
authored
May 16, 2008
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some more unfinished installer stuff
parent
c10078d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
113 additions
and
0 deletions
+113
-0
src/data/installer.cpp
src/data/installer.cpp
+112
-0
src/util/io/package_manager.hpp
src/util/io/package_manager.hpp
+1
-0
No files found.
src/data/installer.cpp
View file @
cf13517f
...
@@ -355,6 +355,118 @@ void merge(InstallablePackages& installed, const DownloadableInstallerP& install
...
@@ -355,6 +355,118 @@ void merge(InstallablePackages& installed, const DownloadableInstallerP& install
}
}
// ----------------------------------------------------------------------------- : Installable package : dependency stuff
InstallablePackage
*
find_package
(
InstallablePackages
&
packages
,
const
String
&
name
)
{
// TODO: The packages are sorted, so we could use a binary search.
FOR_EACH
(
p
,
packages
)
{
if
(
p
->
description
->
name
==
name
)
return
p
.
get
();
}
return
nullptr
;
}
/// A dependency on the new or installed version of an installable package
/// Used only inside these algorithms
struct
Dep
{
InstallablePackage
*
package
;
bool
new_version
;
};
typedef
void
(
*
DependencyFun
)(
InstallablePackages
&
packages
,
Dep
dep
,
PackageAction
where
);
/// All dependencies of a package(version)
void
for_each_dependency
(
DependencyFun
fun
,
InstallablePackages
&
packages
,
Dep
pdep
,
PackageAction
where
)
{
vector
<
PackageDependencyP
>&
deps
=
pdep
.
new_version
?
pdep
.
package
->
installed
->
dependencies
:
pdep
.
package
->
description
->
dependencies
;
FOR_EACH
(
dep_
,
deps
)
{
// NOTE: an old version will never depend on a new version
Dep
d
=
{
find_package
(
packages
,
dep_
->
package
),
pdep
.
new_version
};
if
(
d
.
package
&&
d
.
package
->
installed
&&
d
.
package
->
installed
->
version
>=
dep_
->
version
)
{
d
.
new_version
=
false
;
}
fun
(
packages
,
d
,
where
);
}
}
/// All packages that depend on a package(version)
void
for_each_backwards_dependency
(
DependencyFun
fun
,
InstallablePackages
&
packages
,
Dep
pdep
,
PackageAction
where
)
{
FOR_EACH
(
p
,
packages
)
{
if
(
p
->
installed
)
FOR_EACH
(
dep_
,
p
->
installed
->
dependencies
)
{
if
(
pdep
.
package
->
description
->
name
!=
dep_
->
package
)
{
continue
;
// no dependency on p
}
if
(
pdep
.
new_version
&&
pdep
.
package
->
installed
&&
pdep
.
package
->
installed
->
version
>=
dep_
->
version
)
{
continue
;
// no need for new version of pdep
}
Dep
d
=
{
p
.
get
(),
false
};
fun
(
packages
,
d
,
where
);
}
if
(
p
->
installer
)
FOR_EACH
(
dep_
,
p
->
description
->
dependencies
)
{
if
(
pdep
.
package
->
description
->
name
!=
dep_
->
package
)
{
continue
;
// no dependency on p
}
if
(
pdep
.
new_version
&&
pdep
.
package
->
installed
&&
pdep
.
package
->
installed
->
version
>=
dep_
->
version
)
{
continue
;
// no need for new version of pdep
}
Dep
d
=
{
p
.
get
(),
true
};
fun
(
packages
,
d
,
where
);
}
}
}
void
inc_if_nonzero
(
int
&
x
)
{
if
(
x
)
x
++
;
}
void
add_package_dependency
(
InstallablePackages
&
packages
,
Dep
dep
,
PackageAction
where
)
{
if
(
!
dep
.
package
)
return
;
bool
change
=
false
;
if
(
dep
.
new_version
)
{
change
=
!
(
dep
.
package
->
action
&
PACKAGE_INSTALL
);
dep
.
package
->
action
=
where
|
PACKAGE_INSTALL
;
inc_if_nonzero
(
dep
.
package
->
automatic
);
}
else
if
(
dep
.
package
->
action
&
PACKAGE_REMOVE
)
{
dep
.
package
->
action
=
where
|
PACKAGE_NOTHING
;
dep
.
package
->
automatic
=
0
;
}
if
(
change
)
{
for_each_dependency
(
add_package_dependency
,
packages
,
dep
,
where
);
}
}
void
remove_package_dependency_need_not_install
(
InstallablePackages
&
packages
,
Dep
dep
,
PackageAction
where
)
{
if
(
!
dep
.
package
)
return
;
if
(
dep
.
new_version
&&
(
dep
.
package
->
action
&
PACKAGE_INSTALL
)
&&
dep
.
package
->
automatic
)
{
// we no longer need to install this package
if
(
--
dep
.
package
->
automatic
==
0
)
{
dep
.
package
->
action
=
where
|
PACKAGE_NOTHING
;
for_each_dependency
(
remove_package_dependency_need_not_install
,
packages
,
dep
,
where
);
}
}
// TODO: also uninstall packages that are already installed, and which are 'hidden'?
}
void
remove_package_dependency
(
InstallablePackages
&
packages
,
Dep
dep
,
PackageAction
where
)
{
if
(
!
dep
.
package
)
return
;
bool
change
=
false
;
if
(
dep
.
new_version
)
{
change
=
!
(
dep
.
package
->
action
&
PACKAGE_NOTHING
);
dep
.
package
->
action
=
where
|
PACKAGE_NOTHING
;
dep
.
package
->
automatic
=
0
;
}
else
if
(
dep
.
package
->
status
&
PACKAGE_REMOVABLE
)
{
change
=
!
(
dep
.
package
->
action
&
PACKAGE_REMOVE
);
dep
.
package
->
action
=
where
|
PACKAGE_REMOVE
;
inc_if_nonzero
(
dep
.
package
->
automatic
);
}
if
(
change
)
{
// things that depend on us
for_each_backwards_dependency
(
remove_package_dependency
,
packages
,
dep
,
where
);
// things we depend on
for_each_dependency
(
remove_package_dependency_need_not_install
,
packages
,
dep
,
where
);
}
}
// ----------------------------------------------------------------------------- : Installable package : dependency stuff (OLD)
bool
add_package_dependency
(
InstallablePackages
&
packages
,
const
PackageDependency
&
dep
,
PackageAction
where
,
bool
set
)
{
bool
add_package_dependency
(
InstallablePackages
&
packages
,
const
PackageDependency
&
dep
,
PackageAction
where
,
bool
set
)
{
FOR_EACH
(
p
,
packages
)
{
FOR_EACH
(
p
,
packages
)
{
if
(
p
->
description
->
name
==
dep
.
package
)
{
if
(
p
->
description
->
name
==
dep
.
package
)
{
...
...
src/util/io/package_manager.hpp
View file @
cf13517f
...
@@ -174,6 +174,7 @@ class PackageVersion : public IntrusivePtrBase<PackageVersion> {
...
@@ -174,6 +174,7 @@ class PackageVersion : public IntrusivePtrBase<PackageVersion> {
String
name
;
String
name
;
Version
version
;
Version
version
;
vector
<
PackageDependencyP
>
dependencies
;
enum
Status
enum
Status
{
STATUS_LOCAL
=
0x01
///< Package is installed in the local package dir
{
STATUS_LOCAL
=
0x01
///< Package is installed in the local package dir
,
STATUS_GLOBAL
=
0x02
///< Package is installed in the global package dir
,
STATUS_GLOBAL
=
0x02
///< Package is installed in the global package dir
...
...
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