Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Librem5
Librem 5 Package Information Tool
Commits
9e525f70
Commit
9e525f70
authored
Feb 18, 2020
by
David Boddie
💬
Browse files
Add tools to extract license information from system images
parent
19512f55
Pipeline
#52557
failed with stage
in 15 seconds
Changes
2
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
tools/dpkg-status-summary.py
0 → 100755
View file @
9e525f70
This diff is collapsed.
Click to expand it.
tools/librem5-mount-rootfs.py
0 → 100755
View file @
9e525f70
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2020 Purism SPC
# SPDX-License-Identifier: GPL-3.0+
# Author: David Boddie <david.boddie@puri.sm>
import
locale
import
os
import
shlex
import
subprocess
import
sys
if
__name__
==
'__main__'
:
if
len
(
sys
.
argv
)
!=
3
:
sys
.
stderr
.
write
(
'Usage: %s <librem5.img disk image> '
'<mount point>
\n
'
%
sys
.
argv
[
0
])
sys
.
exit
(
1
)
image
=
sys
.
argv
[
1
]
mount_point
=
sys
.
argv
[
2
]
s
=
subprocess
.
Popen
([
'fdisk'
,
'--units=sectors'
,
'-l'
,
shlex
.
quote
(
image
)],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
if
s
.
wait
()
!=
0
:
sys
.
stderr
.
write
(
'Error: %s
\n
'
%
str
(
s
.
stderr
.
read
().
rstrip
(),
locale
.
getpreferredencoding
()))
sys
.
exit
(
1
)
for
line
in
s
.
stdout
.
readlines
():
line
=
line
.
strip
()
if
line
.
startswith
(
b
'librem5.img2'
):
start
=
int
(
line
.
split
()[
1
])
offset
=
start
*
512
if
not
os
.
path
.
isdir
(
mount_point
):
os
.
mkdir
(
mount_point
)
result
=
os
.
system
(
'mount -o offset=%i %s %s'
%
(
offset
,
shlex
.
quote
(
image
),
shlex
.
quote
(
mount_point
)))
if
result
!=
0
:
sys
.
exit
(
1
)
# Add sources to the /etc/apt/sources.list file.
file_name
=
os
.
path
.
join
(
mount_point
,
'etc'
,
'apt'
,
'sources.list'
)
lines
=
[]
sources
=
set
()
for
line
in
open
(
file_name
).
readlines
():
lines
.
append
(
line
)
if
line
.
startswith
(
'deb-src '
):
sources
.
add
(
line
[
8
:])
f
=
open
(
file_name
,
'w'
)
for
line
in
lines
:
f
.
write
(
line
)
if
line
.
startswith
(
'deb '
):
if
line
[
4
:]
not
in
sources
:
f
.
write
(
'deb-src '
+
line
[
4
:])
f
.
close
()
# Enter the chroot and update apt.
if
os
.
system
(
'chroot %s apt update'
%
shlex
.
quote
(
mount_point
))
!=
0
:
sys
.
exit
(
1
)
print
(
'Now run:'
)
print
(
'dpkg-status-summary.py [-d] <release name> %s '
'<output directory>'
%
shlex
.
quote
(
mount_point
))
sys
.
exit
()
Write
Preview
Supports
Markdown
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