Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Arch Linux
repod
Commits
3e7edd6c
Unverified
Commit
3e7edd6c
authored
Oct 09, 2019
by
Maxim Baz
Browse files
Port nicer repo load code to all scripts
parent
405ebc91
Changes
2
Hide whitespace changes
Inline
Side-by-side
dbscripts/db-move
View file @
3e7edd6c
...
...
@@ -13,6 +13,7 @@ from lib.dbwrite import generate_dbs
async
def
main
(
repo_from
,
repo_to
,
pkgbases
)
->
int
:
metadir
=
(
Path
(
argv
[
0
]).
parent
/
"meta"
).
resolve
(
strict
=
True
)
# FIXME: Put this into metadir/.git/
lockfile
=
(
metadir
/
"dbscripts.lock"
).
open
(
mode
=
"w"
)
flock
(
lockfile
,
LOCK_EX
)
...
...
@@ -27,13 +28,15 @@ async def main(repo_from, repo_to, pkgbases) -> int:
raise
RuntimeError
(
"repo_from and repo_to cannot be the same"
)
# load existing repo metadata
meta
=
{
repo
:
{
p
.
stem
:
json
.
load
((
metadir
/
repo
/
p
).
open
())
for
p
in
(
metadir
/
repo
).
glob
(
"*.json"
)
}
for
repo
in
[
repo_from
,
repo_to
]
}
def
json_load
(
path
):
with
path
.
open
()
as
f
:
return
json
.
load
(
f
)
def
repo_load
(
repo
):
repodir
=
metadir
/
repo
return
{
p
.
stem
:
json_load
(
repodir
/
p
)
for
p
in
repodir
.
glob
(
"*.json"
)}
meta
=
{
repo
:
repo_load
(
repo
)
for
repo
in
[
repo_from
,
repo_to
]}
# validate that the move is possible
for
pkgbase
in
pkgbases
:
...
...
dbscripts/db-remove
View file @
3e7edd6c
...
...
@@ -13,6 +13,7 @@ from lib.dbwrite import generate_dbs
async
def
main
(
repo
,
pkgbases
)
->
int
:
metadir
=
(
Path
(
argv
[
0
]).
parent
/
"meta"
).
resolve
(
strict
=
True
)
# FIXME: Put this into metadir/.git/
lockfile
=
(
metadir
/
"dbscripts.lock"
).
open
(
mode
=
"w"
)
flock
(
lockfile
,
LOCK_EX
)
...
...
@@ -21,12 +22,15 @@ async def main(repo, pkgbases) -> int:
raise
RuntimeError
(
f
"repo '
{
repo
}
' is not allowed"
)
# load existing repo metadata
meta
=
{
repo
:
{
p
.
stem
:
json
.
load
((
metadir
/
repo
/
p
).
open
())
for
p
in
(
metadir
/
repo
).
glob
(
"*.json"
)
}
}
def
json_load
(
path
):
with
path
.
open
()
as
f
:
return
json
.
load
(
f
)
def
repo_load
(
repo
):
repodir
=
metadir
/
repo
return
{
p
.
stem
:
json_load
(
repodir
/
p
)
for
p
in
repodir
.
glob
(
"*.json"
)}
meta
=
{
repo
:
repo_load
(
repo
)}
# remove packages from meta and corresponding json files
for
pkgbase
in
pkgbases
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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