mirror of
https://github.com/vlang/v.git
synced 2025-09-16 16:02:29 +03:00
tools.vpm: fix installing of modules with conflicting names, extend tests (#19961)
This commit is contained in:
parent
fb9382833c
commit
29eda896a1
5 changed files with 159 additions and 142 deletions
|
@ -92,7 +92,6 @@ fn vpm_install_from_vpm(modules []Module) {
|
|||
mut errors := 0
|
||||
for m in modules {
|
||||
vpm_log(@FILE_LINE, @FN, 'module: ${m}')
|
||||
last_errors := errors
|
||||
match m.install() {
|
||||
.installed {}
|
||||
.failed {
|
||||
|
@ -107,9 +106,7 @@ fn vpm_install_from_vpm(modules []Module) {
|
|||
vpm_error('failed to increment the download count for `${m.name}`', details: err.msg())
|
||||
errors++
|
||||
}
|
||||
if last_errors == errors {
|
||||
println('Installed `${m.name}`.')
|
||||
}
|
||||
println('Installed `${m.name}`.')
|
||||
resolve_dependencies(get_manifest(m.install_path), idents)
|
||||
}
|
||||
if errors > 0 {
|
||||
|
@ -123,7 +120,6 @@ fn vpm_install_from_vcs(modules []Module) {
|
|||
mut errors := 0
|
||||
for m in modules {
|
||||
vpm_log(@FILE_LINE, @FN, 'module: ${m}')
|
||||
last_errors := errors
|
||||
match m.install() {
|
||||
.installed {}
|
||||
.failed {
|
||||
|
@ -134,56 +130,8 @@ fn vpm_install_from_vcs(modules []Module) {
|
|||
continue
|
||||
}
|
||||
}
|
||||
manifest := get_manifest(m.install_path) or { continue }
|
||||
final_path := os.join_path(m.install_path.all_before_last(os.path_separator),
|
||||
normalize_mod_path(manifest.name))
|
||||
if m.install_path != final_path {
|
||||
verbose_println('Relocating `${m.name} (${m.install_path_fmted})` to `${manifest.name} (${final_path})`...')
|
||||
if os.exists(final_path) {
|
||||
println('Target directory for `${m.name} (${final_path})` already exists.')
|
||||
input := os.input('Replace it with the module directory? [Y/n]: ')
|
||||
match input.to_lower() {
|
||||
'', 'y' {
|
||||
m.remove() or {
|
||||
vpm_error('failed to remove `${final_path}`.', details: err.msg())
|
||||
errors++
|
||||
continue
|
||||
}
|
||||
}
|
||||
else {
|
||||
verbose_println('Skipping `${m.name}`.')
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
// When the module should be relocated into a subdirectory we need to make sure
|
||||
// it exists to not run into permission errors.
|
||||
if m.install_path.count(os.path_separator) < final_path.count(os.path_separator)
|
||||
&& !os.exists(final_path) {
|
||||
os.mkdir_all(final_path) or {
|
||||
vpm_error('failed to create directory for `${manifest.name}`.',
|
||||
details: err.msg()
|
||||
)
|
||||
errors++
|
||||
continue
|
||||
}
|
||||
}
|
||||
os.mv(m.install_path, final_path) or {
|
||||
errors++
|
||||
vpm_error('failed to relocate module `${m.name}`.', details: err.msg())
|
||||
os.rmdir_all(m.install_path) or {
|
||||
vpm_error('failed to remove `${m.install_path}`.', details: err.msg())
|
||||
errors++
|
||||
continue
|
||||
}
|
||||
continue
|
||||
}
|
||||
verbose_println('Relocated `${m.name}` to `${manifest.name}`.')
|
||||
}
|
||||
if last_errors == errors {
|
||||
println('Installed `${m.name}`.')
|
||||
}
|
||||
resolve_dependencies(manifest, urls)
|
||||
println('Installed `${m.name}`.')
|
||||
resolve_dependencies(m.manifest, urls)
|
||||
}
|
||||
if errors > 0 {
|
||||
exit(1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue