Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meta-elphel393
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
meta-elphel393
Commits
333d1c50
Commit
333d1c50
authored
Jul 28, 2025
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented Kostya's correction, added warning
parent
5056d9f8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
13 deletions
+23
-13
elphel-misc-functions.bbclass
classes/elphel-misc-functions.bbclass
+23
-13
No files found.
classes/elphel-misc-functions.bbclass
View file @
333d1c50
...
...
@@ -4,7 +4,7 @@
def version_update(path,file,evr):
import os.path
if not os.path.exists(path+'/'+file):
return
0
return
"0"
f=open(path+'/'+file)
for line in f:
...
...
@@ -24,25 +24,35 @@ def version_update(path,file,evr):
def revision_update(path,file):
import subprocess, os# , pwd for some reasons pwd.getpwall() show some 3-user default, so read and parse etc/passwd
import getpass
#
import getpass
pef = None # , preexec_fn=pefuid
if (os.getuid() == 0):
bb.warn("Tried to access '"+path+"' as root, demoting to a normal user")
"""
python __anonymous() {
if d.getVar('MY_VARIABLE', True) == "":
bb.warn("MY_VARIABLE is not set. This may lead to unexpected behavior.")
}
"""
#uname = os.getlogin()
uname = getpass.getuser()
with open("/etc/passwd") as f:
for line in f:
line = line.strip()
a = line.split(':')
if a[0] == uname:
#
uname = getpass.getuser()
#
with open("/etc/passwd") as f:
#
for line in f:
#
line = line.strip()
#
a = line.split(':')
#
if a[0] == uname:
# pef = preexec_fn=demote(int(a[3]),int(a[2]));
pef = preexec_fn=demote(int(a[2]),int(a[3]));
break
# pef = preexec_fn=demote(int(a[2]),int(a[3]));
# break
# Kostya's solution:
st = os.stat(path)
pef = demote(st.st_uid, st.st_gid)
cmd = "cd "+path+"; git rev-list --count $(git log -1 --pretty=format:\"%H\" "+file+")..HEAD"
try:
res =
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True, preexec_fn=pef
)
res =
str(subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True, preexec_fn=pef)
)
except subprocess.CalledProcessError as e:
res = "error_"+
e.returncode
res = str(int(res))
res = "error_"+
str(e.returncode)
#
res = str(int(res))
res = res.strip(' \t\n\r')
return res
...
...
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