Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-udev-rules
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-udev-rules
Commits
acbd78df
Commit
acbd78df
authored
Dec 13, 2017
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make static nodes using udev rules
parent
9a148fa2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
1 deletion
+27
-1
generate_mknods.py
generate_mknods.py
+27
-1
No files found.
generate_mknods.py
View file @
acbd78df
...
...
@@ -19,7 +19,7 @@
@author: Andrey Filippov
@copyright: 2016 Elphel, Inc.
@license: GPLv3.0+
@contact: andrey@elphel.com
l
@contact: andrey@elphel.com
@deffield updated: Updated
'''
from
__future__
import
division
...
...
@@ -34,7 +34,26 @@ __version__ = "3.0+"
__maintainer__
=
"Andrey Filippov"
__email__
=
"andrey@elphel.com"
__status__
=
"Development"
def
create_udev_rules_file
(
contents
):
c
=
"# --- This is an auto-generated file, see "
+
sys
.
argv
[
0
]
+
"
\n
"
c
+=
"ACTION!=
\"
add
\"
, GOTO=
\"
static_nodes_end
\"\n\n
"
c
+=
contents
c
+=
"
\n
LABEL=
\"
static_nodes_end
\"
"
f
=
open
(
'50-elphel-static-nodes.rules'
,
'w'
)
f
.
write
(
c
)
f
.
close
()
def
get_udev_rule
(
mode
,
name
,
devtype
,
major
,
minor
,
comment
):
tmpstr
=
comment
.
strip
()
+
"
\n
"
tmpstr
+=
"ACTION==
\"
add
\"
, RUN+=
\"
/bin/mknod -m "
+
mode
+
" /dev/"
+
name
+
" "
+
devtype
+
" "
+
major
+
" "
+
minor
+
"
\"\n
"
return
tmpstr
def
process_header
():
rulestr
=
""
print
(
"# --- This is an auto-generated file, see
%
s ---"
%
(
sys
.
argv
[
0
]))
print
(
"define mknodes ="
)
pat
=
re
.
compile
(
r'#define\s+(\w+)\s+\(\s*"([^"]+)"\s*,\s*"([^"]+)"\s*,\s*(\w*)\s*,\s*(\w*)\s*,\s*"([^"]+)"\s*,\s*"([^"]+)"\s*\)(.*)'
)
...
...
@@ -52,7 +71,14 @@ def process_header():
comment
=
" # "
+
comment
print
(
"mknod -m
%
s $(TARGETDIR)/
%-20
s
%
s
%3
s
%3
s
%
s"
%
(
fs
.
group
(
6
),
fs
.
group
(
2
),
fs
.
group
(
7
),
fs
.
group
(
4
),
fs
.
group
(
5
),
comment
))
rulestr
+=
get_udev_rule
(
fs
.
group
(
6
),
fs
.
group
(
2
),
fs
.
group
(
7
),
fs
.
group
(
4
),
fs
.
group
(
5
),
comment
)
line
=
f
.
readline
()
if
rulestr
!=
""
:
create_udev_rules_file
(
rulestr
)
print
(
"endef"
)
if
__name__
==
"__main__"
:
process_header
()
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