Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Calamares
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
osak
Calamares
Commits
0f8ef422
Commit
0f8ef422
authored
9 years ago
by
Teo Mrnjavac
Browse files
Options
Downloads
Patches
Plain Diff
Lint.
parent
e6806048
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/modules/fstab/main.py
+23
-19
23 additions, 19 deletions
src/modules/fstab/main.py
with
23 additions
and
19 deletions
src/modules/fstab/main.py
+
23
−
19
View file @
0f8ef422
...
@@ -76,8 +76,8 @@ def is_ssd_disk(disk_name):
...
@@ -76,8 +76,8 @@ def is_ssd_disk(disk_name):
# Should not happen unless sysfs changes, but better safe than sorry
# Should not happen unless sysfs changes, but better safe than sorry
return
False
return
False
with
open
(
filename
)
as
f
:
with
open
(
filename
)
as
sysfile
:
return
f
.
read
()
==
"
0
\n
"
return
sysfile
.
read
()
==
"
0
\n
"
def
disk_name_for_partition
(
partition
):
def
disk_name_for_partition
(
partition
):
...
@@ -132,14 +132,14 @@ class FstabGenerator(object):
...
@@ -132,14 +132,14 @@ class FstabGenerator(object):
mkdir_p
(
os
.
path
.
join
(
self
.
root_mount_point
,
"
etc
"
))
mkdir_p
(
os
.
path
.
join
(
self
.
root_mount_point
,
"
etc
"
))
crypttab_path
=
os
.
path
.
join
(
self
.
root_mount_point
,
"
etc
"
,
"
crypttab
"
)
crypttab_path
=
os
.
path
.
join
(
self
.
root_mount_point
,
"
etc
"
,
"
crypttab
"
)
with
open
(
crypttab_path
,
"
w
"
)
as
fl
:
with
open
(
crypttab_path
,
"
w
"
)
as
crypttab_file
:
print
(
CRYPTTAB_HEADER
,
file
=
fl
)
print
(
CRYPTTAB_HEADER
,
file
=
crypttab_file
)
for
partition
in
self
.
partitions
:
for
partition
in
self
.
partitions
:
dct
=
self
.
generate_crypttab_line_info
(
partition
)
dct
=
self
.
generate_crypttab_line_info
(
partition
)
if
dct
:
if
dct
:
self
.
print_crypttab_line
(
dct
,
file
=
fl
)
self
.
print_crypttab_line
(
dct
,
file
=
crypttab_file
)
def
generate_crypttab_line_info
(
self
,
partition
):
def
generate_crypttab_line_info
(
self
,
partition
):
"""
Generates information for each crypttab entry.
"""
"""
Generates information for each crypttab entry.
"""
...
@@ -172,14 +172,14 @@ class FstabGenerator(object):
...
@@ -172,14 +172,14 @@ class FstabGenerator(object):
mkdir_p
(
os
.
path
.
join
(
self
.
root_mount_point
,
"
etc
"
))
mkdir_p
(
os
.
path
.
join
(
self
.
root_mount_point
,
"
etc
"
))
fstab_path
=
os
.
path
.
join
(
self
.
root_mount_point
,
"
etc
"
,
"
fstab
"
)
fstab_path
=
os
.
path
.
join
(
self
.
root_mount_point
,
"
etc
"
,
"
fstab
"
)
with
open
(
fstab_path
,
"
w
"
)
as
f
l
:
with
open
(
fstab_path
,
"
w
"
)
as
f
stab_file
:
print
(
FSTAB_HEADER
,
file
=
f
l
)
print
(
FSTAB_HEADER
,
file
=
f
stab_file
)
for
partition
in
self
.
partitions
:
for
partition
in
self
.
partitions
:
dct
=
self
.
generate_fstab_line_info
(
partition
)
dct
=
self
.
generate_fstab_line_info
(
partition
)
if
dct
:
if
dct
:
self
.
print_fstab_line
(
dct
,
file
=
f
l
)
self
.
print_fstab_line
(
dct
,
file
=
f
stab_file
)
if
self
.
root_is_ssd
:
if
self
.
root_is_ssd
:
# Mount /tmp on a tmpfs
# Mount /tmp on a tmpfs
...
@@ -189,22 +189,23 @@ class FstabGenerator(object):
...
@@ -189,22 +189,23 @@ class FstabGenerator(object):
options
=
"
defaults,noatime,mode=1777
"
,
options
=
"
defaults,noatime,mode=1777
"
,
check
=
0
,
check
=
0
,
)
)
self
.
print_fstab_line
(
dct
,
file
=
f
l
)
self
.
print_fstab_line
(
dct
,
file
=
f
stab_file
)
def
generate_fstab_line_info
(
self
,
partition
):
def
generate_fstab_line_info
(
self
,
partition
):
"""
Generates information for each fstab entry.
"""
"""
Generates information for each fstab entry.
"""
f
s
=
partition
[
"
fs
"
]
f
ilesystem
=
partition
[
"
fs
"
]
mount_point
=
partition
[
"
mountPoint
"
]
mount_point
=
partition
[
"
mountPoint
"
]
disk_name
=
disk_name_for_partition
(
partition
)
disk_name
=
disk_name_for_partition
(
partition
)
is_ssd
=
disk_name
in
self
.
ssd_disks
is_ssd
=
disk_name
in
self
.
ssd_disks
f
s
=
FS_MAP
.
get
(
f
s
,
fs
)
f
ilesystem
=
FS_MAP
.
get
(
f
ilesystem
,
filesystem
)
if
not
mount_point
and
not
f
s
==
"
swap
"
:
if
not
mount_point
and
not
f
ilesystem
==
"
swap
"
:
return
None
return
None
options
=
self
.
mount_options
.
get
(
fs
,
self
.
mount_options
[
"
default
"
])
options
=
self
.
mount_options
.
get
(
filesystem
,
self
.
mount_options
[
"
default
"
])
if
is_ssd
:
if
is_ssd
:
extra
=
self
.
ssd_extra_mount_options
.
get
(
f
s
)
extra
=
self
.
ssd_extra_mount_options
.
get
(
f
ilesystem
)
if
extra
:
if
extra
:
options
+=
"
,
"
+
extra
options
+=
"
,
"
+
extra
...
@@ -221,7 +222,7 @@ class FstabGenerator(object):
...
@@ -221,7 +222,7 @@ class FstabGenerator(object):
return
dict
(
device
=
"
UUID=
"
+
partition
[
"
uuid
"
],
return
dict
(
device
=
"
UUID=
"
+
partition
[
"
uuid
"
],
mount_point
=
mount_point
or
"
swap
"
,
mount_point
=
mount_point
or
"
swap
"
,
fs
=
f
s
,
fs
=
f
ilesystem
,
options
=
options
,
options
=
options
,
check
=
check
,
check
=
check
,
)
)
...
@@ -248,12 +249,15 @@ def run():
...
@@ -248,12 +249,15 @@ def run():
:return:
:return:
"""
"""
g
s
=
libcalamares
.
globalstorage
g
lobal_storage
=
libcalamares
.
globalstorage
conf
=
libcalamares
.
job
.
configuration
conf
=
libcalamares
.
job
.
configuration
partitions
=
g
s
.
value
(
"
partitions
"
)
partitions
=
g
lobal_storage
.
value
(
"
partitions
"
)
root_mount_point
=
g
s
.
value
(
"
rootMountPoint
"
)
root_mount_point
=
g
lobal_storage
.
value
(
"
rootMountPoint
"
)
mount_options
=
conf
[
"
mountOptions
"
]
mount_options
=
conf
[
"
mountOptions
"
]
ssd_extra_mount_options
=
conf
.
get
(
"
ssdExtraMountOptions
"
,
{})
ssd_extra_mount_options
=
conf
.
get
(
"
ssdExtraMountOptions
"
,
{})
generator
=
FstabGenerator
(
partitions
,
root_mount_point
,
mount_options
,
ssd_extra_mount_options
)
generator
=
FstabGenerator
(
partitions
,
root_mount_point
,
mount_options
,
ssd_extra_mount_options
)
return
generator
.
run
()
return
generator
.
run
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment