mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-27 10:16:14 +01:00
commit
4dae53fbe7
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -1,4 +1,5 @@
|
|||||||
.gitattributes export-ignore
|
.gitattributes export-ignore
|
||||||
.github export-ignore
|
.github export-ignore
|
||||||
contrib export-ignore
|
contrib/build_rpm.py export-ignore
|
||||||
|
contrib/osc.spec export-ignore
|
||||||
osc/util/git_version.py export-subst
|
osc/util/git_version.py export-subst
|
||||||
|
47
.gitignore
vendored
47
.gitignore
vendored
@ -1,7 +1,42 @@
|
|||||||
*.pyc
|
# Byte-compiled / optimized / DLL files
|
||||||
*.swp
|
__pycache__/
|
||||||
tags
|
*.py[cod]
|
||||||
build
|
*$py.class
|
||||||
*junit-xml-results
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
*.egg
|
*.egg
|
||||||
osc.egg-info/*
|
MANIFEST
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Temporary/backup files of text editors
|
||||||
|
*.swp
|
||||||
|
*~
|
||||||
|
.#*
|
||||||
|
|
||||||
|
# Packages, archives
|
||||||
|
*.rpm
|
||||||
|
*.tar*
|
||||||
|
27
.travis.yml
27
.travis.yml
@ -1,27 +0,0 @@
|
|||||||
language: python
|
|
||||||
python:
|
|
||||||
- '2.7'
|
|
||||||
- '3.6'
|
|
||||||
- '3.7'
|
|
||||||
- '3.8'
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- diffstat
|
|
||||||
sudo: false
|
|
||||||
before_script: cd $TRAVIS_BUILD_DIR/tests
|
|
||||||
script: python suite.py
|
|
||||||
before_deploy:
|
|
||||||
- cd $TRAVIS_BUILD_DIR/
|
|
||||||
- rm -rf $TRAVIS_BUILD_DIR/dist/*
|
|
||||||
deploy:
|
|
||||||
provider: pypi
|
|
||||||
skip_existing: true
|
|
||||||
skip_cleanup: true
|
|
||||||
user: suse
|
|
||||||
password:
|
|
||||||
secure: R4+YNPW2tsiY06hibGvONYn0//1z1QdcY8VmNbYpIRly4eTAbPE9uejKpyuflUkznpEkoqCdFzi5FNFhgat9N+AkIKyX9NTkf0oxaKKbdqBM7H1V8bqLYlAO479262spRyO0ee5fV5v6g81AFjncIV+pGjtQ0Vg/sjVcvGa61bs=
|
|
||||||
on:
|
|
||||||
tags: true
|
|
||||||
distributions: sdist
|
|
||||||
repo: openSUSE/osc
|
|
12
AUTHORS
12
AUTHORS
@ -1,23 +1,33 @@
|
|||||||
Adrian Schroeter
|
Adrian Schroeter
|
||||||
|
Anatoli Babenia
|
||||||
Andreas Bauer
|
Andreas Bauer
|
||||||
|
Andreas Schwab
|
||||||
|
Bernhard M. Wiedemann
|
||||||
Christoph Thiel
|
Christoph Thiel
|
||||||
|
Daniel Mach
|
||||||
|
Danny Al-Gaaf
|
||||||
|
Danny Kukawka
|
||||||
David Mayr
|
David Mayr
|
||||||
Dirk Mueller
|
Dirk Mueller
|
||||||
|
Jan-Simon Möller
|
||||||
Juergen Weigert
|
Juergen Weigert
|
||||||
Lars Rupp
|
Lars Rupp
|
||||||
Lenz Grimmer
|
Lenz Grimmer
|
||||||
Ludwig Nussel
|
Ludwig Nussel
|
||||||
|
Marco Strigl
|
||||||
Marcus Huewe
|
Marcus Huewe
|
||||||
Marcus Rueckert
|
Marcus Rueckert
|
||||||
Martin Mohring
|
Martin Mohring
|
||||||
Michael Schroeder
|
Michael Schroeder
|
||||||
Michael Wolf
|
Michael Wolf
|
||||||
|
Michal Čihař
|
||||||
Michal Marek
|
Michal Marek
|
||||||
|
Michal Vyskocil
|
||||||
Pavol Rusnak
|
Pavol Rusnak
|
||||||
Peter Poeml
|
Peter Poeml
|
||||||
Sascha Peilicke
|
Sascha Peilicke
|
||||||
|
Stephan Kulow
|
||||||
Susanne Oberhauser
|
Susanne Oberhauser
|
||||||
Tom Patzig
|
Tom Patzig
|
||||||
Werner Fink
|
Werner Fink
|
||||||
Will Stephenson
|
Will Stephenson
|
||||||
Jan-Simon Möller
|
|
||||||
|
@ -1,92 +0,0 @@
|
|||||||
jw, Tue Oct 20 22:09:16 CEST 2009
|
|
||||||
|
|
||||||
This is a feature suggestion for easier osc commandline handling.
|
|
||||||
Many commands require specifying Project and/or Package names.
|
|
||||||
|
|
||||||
The current situation is not satisfying for the following reasons:
|
|
||||||
- inconsistent defaults. Some osc subcommands can take project
|
|
||||||
and/or package names from the current directory, if run inside a checkout
|
|
||||||
tree. If both project and package can use this default or only one, and if
|
|
||||||
one, which, depends on the command. Users have a hard time memorizing
|
|
||||||
which is which.
|
|
||||||
Examples as of osc version 0.123:
|
|
||||||
osc maintainer PRJ [PKG]
|
|
||||||
- does not look in the current directory.
|
|
||||||
- need at least PRJ.
|
|
||||||
osc list [PRJ [PKG]]
|
|
||||||
- Never looks at the current directory.
|
|
||||||
- lists all projects, if run without parameters.
|
|
||||||
osc checkout [PRJ] PKG
|
|
||||||
osc checkout PRJ
|
|
||||||
- takes project from current directory, if inside a checkout tree
|
|
||||||
- else operates on an entire project.
|
|
||||||
osc checkin [ARG]
|
|
||||||
- defaults to current project and package,
|
|
||||||
- if arg is a subdirectory, project is taken from current directory
|
|
||||||
- if arg is a file, both project and package are taken from current
|
|
||||||
directory.
|
|
||||||
osc results [PRJ PKG]
|
|
||||||
- takes either both or none from current directory.
|
|
||||||
- many commands do not look into the current directory,
|
|
||||||
they are cumbersome to use.
|
|
||||||
- sometimes PRJ/PKG can be used instead of PRJ PKG
|
|
||||||
|
|
||||||
|
|
||||||
Suggested solution
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Instead of tuning (maybe optional) positional parameters.
|
|
||||||
We suggest to deprecate this syntax over time and instead favour an alternate
|
|
||||||
syntax:
|
|
||||||
osc CMD ... [--prj PRJ] [--pkg PKG] ...
|
|
||||||
osc CMD ... [--proj PRJ] [--pack PKG] ...
|
|
||||||
osc CMD ... [--project PRJ] [--package PKG] ...
|
|
||||||
|
|
||||||
These six options are new to osc, currently no existing command uses
|
|
||||||
them. Thus the new syntax is conflict free wit the old syntax, both can be
|
|
||||||
used in parallel.
|
|
||||||
|
|
||||||
--prj, --proj, --project are synonyms.
|
|
||||||
--pkg, --pack, --package are synonyms.
|
|
||||||
|
|
||||||
osc shall support aliases, to save typing. Some implicit aliases exist,
|
|
||||||
with well defined magic effects. Aliases substitution is literal.
|
|
||||||
They can replace options including their parameters, or just the option, or
|
|
||||||
just the parameters.
|
|
||||||
- (a dash) expands to --prj openSUSE:Factory
|
|
||||||
(or --prj followed by any other project as defined in
|
|
||||||
~/.oscrc:default_project )
|
|
||||||
--prj - is synonymous to just -, for consistency.
|
|
||||||
|
|
||||||
. (a dot) evaluates the current working directory, searching for
|
|
||||||
.osc/_apiurl, .osc/_project, and .osc/_package
|
|
||||||
Implicit --apiurl, --prj, or --pkg options are constructed as far
|
|
||||||
as available from the current directory and as far as not already
|
|
||||||
present in the command line.
|
|
||||||
If a dot is used as parameter to an option, it has a more
|
|
||||||
deterministic meaning.
|
|
||||||
--apiurl . Substitute only the current apiurl,
|
|
||||||
--prj . Substitute the current project name, and provides
|
|
||||||
a default for --apiurl unless given.
|
|
||||||
--pkg . Substitures current package name likewise.
|
|
||||||
|
|
||||||
./. expands to --prj . --pkg .
|
|
||||||
./PKG expands to --prj . --pkg PKG
|
|
||||||
|
|
||||||
Unless otherwise noted in the online help, magic aliases are only attempted onceper commandline, and will only apply to their respective options.
|
|
||||||
E.g. osc ci -m - will use a simple '-' as check in messages, and the absence of any project or package will default to the current project or package, just as
|
|
||||||
osc ci . -m - would do.
|
|
||||||
|
|
||||||
Additionally, user defined aliases can be added to ~/.oscrc
|
|
||||||
If an alias expansion has effect on the command line, the expanded line is
|
|
||||||
printed as debug output.
|
|
||||||
|
|
||||||
online help of osc commands shall refer to the above syntax like this:
|
|
||||||
|
|
||||||
osc CMD ... PROJ/PACK
|
|
||||||
|
|
||||||
An additional help entry
|
|
||||||
|
|
||||||
osc help 'PROJ/PACK'
|
|
||||||
|
|
||||||
shall explain the relevant details as presented herein.
|
|
87
TODO
87
TODO
@ -1,87 +0,0 @@
|
|||||||
FIXME:
|
|
||||||
- more command inconsistencies:
|
|
||||||
osc request show
|
|
||||||
-B, --bugowner also show requests about packages where I am bugowner
|
|
||||||
osc my
|
|
||||||
-b, --bugowner restrict listing to items where the user is bugowner
|
|
||||||
osc list
|
|
||||||
-b, --binaries list built binaries instead of sources
|
|
||||||
osc search
|
|
||||||
-B PROJECT, --baseproject=PROJECT
|
|
||||||
--binary search binary packages
|
|
||||||
-b, --bugowner as -i, but only bugowner
|
|
||||||
|
|
||||||
osc checkout
|
|
||||||
-c, --current-dir place PACKAGE folder in the current directory instead
|
|
||||||
of a PROJECT/PACKAGE directory
|
|
||||||
osc branch
|
|
||||||
-c, --checkout Checkout branched package afterwards ('osc bco' is a
|
|
||||||
shorthand for this option)
|
|
||||||
# that means the branch checkout to cwd is not possible
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CRITICAL:
|
|
||||||
- webpage can create a _link in a fully populated package.
|
|
||||||
Need to prevent his somehow.
|
|
||||||
|
|
||||||
- canonical option parser.
|
|
||||||
-A, -e, -u, -E <n>, should be univeral to all subconmmands that work on prj/pkg objects.
|
|
||||||
With all subcommands that work on prj/pkg, the following should all be synonyms:
|
|
||||||
-A apiurl prj pkg
|
|
||||||
-A apiurl --project prj --package=pkg
|
|
||||||
-A apiurl prj/pkg
|
|
||||||
-A apiurl prj:pkg
|
|
||||||
apiurl/source/prj/pkg
|
|
||||||
The current working directory or its descendants should provide defaults
|
|
||||||
for apiurl, prj and/or pkg.
|
|
||||||
See also http://en.opensuse.org/openSUSE:Build_Service_Concept_OscProjPack
|
|
||||||
|
|
||||||
MAJOR:
|
|
||||||
|
|
||||||
NORMAL:
|
|
||||||
|
|
||||||
- split functionality that needs prj/pac as commandline arguments into a seperate tool (oscremote? osc -r?)
|
|
||||||
(update: we have some commands meanwhile which exist in an alternate form,
|
|
||||||
prefixed with r, which works remotely. E.g. rbuildlog, rprjresults, rresults)
|
|
||||||
- status: implement -u option as in svn [3]
|
|
||||||
- implement (svn-like) switch command
|
|
||||||
- implement 'mv' command
|
|
||||||
- commit: check if errors during PUT are handled sensibly, so the change is
|
|
||||||
not committed to localmeta
|
|
||||||
- add switch to commit to change repository options, like to e.g. disable publishing?
|
|
||||||
- implement optional logging to .osc/log, which could be useful for debugging bugs like
|
|
||||||
the one where api.opensuse.org sends empty replies (a hard-to-catch one)
|
|
||||||
|
|
||||||
|
|
||||||
MINOR:
|
|
||||||
|
|
||||||
- osc checkout should display file download progress (bnc#442115)
|
|
||||||
- adjust zsh completion to work with cmdln.py implementation
|
|
||||||
- add support for adding tags to packages?
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JW:
|
|
||||||
FIXME: osc bco ignores --nodevelproject ??
|
|
||||||
FIXME: osc co overwrites local changes without warning.
|
|
||||||
FIXME: when branching, the user should be added to bugowner, for the branch project.
|
|
||||||
FIXME: 'osc rq' shall default to 'osc rq list -M -B -s all',
|
|
||||||
where -B shows requests related to packages where I am the bugowner.
|
|
||||||
FIXME: 'osc log openSUSE:Factory PKG' should also point to the bsdevelproject
|
|
||||||
|
|
||||||
osc addrepo - obsolete zypper ar
|
|
||||||
=> hm, addrepo could be used also to add a repo to a project. These functionalities
|
|
||||||
should not conflict
|
|
||||||
osc install - obsolete zypper in
|
|
||||||
-
|
|
||||||
|
|
||||||
- german umlaut characters äöü do not work in the message for osc submitpac.
|
|
||||||
404 not found, and no request sent.
|
|
||||||
- implement fedora style 'osc mock' - this requires anonymous read-only access to the build server.
|
|
||||||
this could use http://tmp.vuntz.net/opensuse-packages/browse.py?project=openSUSE:Factory
|
|
||||||
as a hacky solution, while we are waiting on fate#306192
|
|
||||||
=> we will not make rpm downloads anonymous possible, this would create too high load on the server.
|
|
||||||
Please improve build script instead.
|
|
||||||
|
|
@ -130,10 +130,10 @@ install -d %{buildroot}%{osc_plugin_dir}
|
|||||||
install -d %{buildroot}%{_sharedstatedir}/osc-plugins
|
install -d %{buildroot}%{_sharedstatedir}/osc-plugins
|
||||||
|
|
||||||
# install completions
|
# install completions
|
||||||
install -Dm0755 dist/osc.complete %{buildroot}%{_datadir}/osc/complete
|
install -Dm0755 contrib/osc.complete %{buildroot}%{_datadir}/osc/complete
|
||||||
install -Dm0644 dist/complete.csh %{buildroot}%{completion_dir_csh}/osc.csh
|
install -Dm0644 contrib/complete.csh %{buildroot}%{completion_dir_csh}/osc.csh
|
||||||
install -Dm0644 dist/complete.sh %{buildroot}%{completion_dir_bash}/osc.sh
|
install -Dm0644 contrib/complete.sh %{buildroot}%{completion_dir_bash}/osc.sh
|
||||||
install -Dm0644 osc.fish %{buildroot}%{completion_dir_fish}/osc.fish
|
install -Dm0644 contrib/osc.fish %{buildroot}%{completion_dir_fish}/osc.fish
|
||||||
|
|
||||||
# install rpm macros
|
# install rpm macros
|
||||||
install -Dm0644 macros.osc %{buildroot}%{_rpmmacrodir}/macros.osc
|
install -Dm0644 macros.osc %{buildroot}%{_rpmmacrodir}/macros.osc
|
||||||
@ -151,7 +151,7 @@ install -Dm0644 osc.1 %{buildroot}%{_mandir}/man1/osc.1
|
|||||||
|
|
||||||
# docs
|
# docs
|
||||||
%license COPYING
|
%license COPYING
|
||||||
%doc AUTHORS README.md TODO NEWS
|
%doc AUTHORS README.md NEWS
|
||||||
%if %{with man}
|
%if %{with man}
|
||||||
%{_mandir}/man1/osc.*
|
%{_mandir}/man1/osc.*
|
||||||
%endif
|
%endif
|
||||||
|
234
fuse/fuseosc
234
fuse/fuseosc
@ -1,234 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
# Copyright (c) 2008-2009 Pavol Rusnak <prusnak@suse.cz>
|
|
||||||
#
|
|
||||||
# Permission is hereby granted, free of charge, to any person
|
|
||||||
# obtaining a copy of this software and associated documentation
|
|
||||||
# files (the "Software"), to deal in the Software without
|
|
||||||
# restriction, including without limitation the rights to use,
|
|
||||||
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the
|
|
||||||
# Software is furnished to do so, subject to the following
|
|
||||||
# conditions:
|
|
||||||
|
|
||||||
# The above copyright notice and this permission notice shall be
|
|
||||||
# included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
||||||
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
||||||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
||||||
# OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
try:
|
|
||||||
import osc
|
|
||||||
import osc.conf
|
|
||||||
import osc.core
|
|
||||||
except:
|
|
||||||
# allow loading module from working copy if osc is not installed
|
|
||||||
sys.path.append(os.path.abspath(os.path.dirname(sys.argv[0]) + '/../osc'))
|
|
||||||
import osc
|
|
||||||
import osc.conf
|
|
||||||
import osc.core
|
|
||||||
import fuse
|
|
||||||
import stat
|
|
||||||
import errno
|
|
||||||
import tempfile
|
|
||||||
|
|
||||||
fuse.fuse_python_api = (0, 2)
|
|
||||||
|
|
||||||
projects = []
|
|
||||||
cache = {}
|
|
||||||
|
|
||||||
class EmptyStat(fuse.Stat):
|
|
||||||
def __init__(self):
|
|
||||||
self.st_mode = 0
|
|
||||||
self.st_ino = 0
|
|
||||||
self.st_dev = 0
|
|
||||||
self.st_nlink = 0
|
|
||||||
self.st_uid = 0
|
|
||||||
self.st_gid = 0
|
|
||||||
self.st_size = 0
|
|
||||||
self.st_atime = 0
|
|
||||||
self.st_mtime = 0
|
|
||||||
self.st_ctime = 0
|
|
||||||
|
|
||||||
class CacheEntry(object):
|
|
||||||
def __init__(self):
|
|
||||||
self.stat = None
|
|
||||||
self.handle = None
|
|
||||||
self.tmpname = None
|
|
||||||
|
|
||||||
class oscFS(fuse.Fuse):
|
|
||||||
|
|
||||||
def __init__(self, *args, **kw):
|
|
||||||
fuse.Fuse.__init__(self, *args, **kw)
|
|
||||||
print 'OK'
|
|
||||||
|
|
||||||
def getattr(self, path):
|
|
||||||
st = EmptyStat()
|
|
||||||
# path is project
|
|
||||||
if path == '/' or path in projects or len(filter(lambda x: x.startswith(path), projects)) > 0:
|
|
||||||
st.st_mode = stat.S_IFDIR | 0555
|
|
||||||
st.st_nlink = 2
|
|
||||||
return st
|
|
||||||
# path is package
|
|
||||||
if os.path.dirname(path) in projects:
|
|
||||||
st.st_mode = stat.S_IFDIR | 0555
|
|
||||||
st.st_nlink = 2
|
|
||||||
return st
|
|
||||||
# path is file
|
|
||||||
if cache.has_key(path):
|
|
||||||
return cache[path].stat
|
|
||||||
else:
|
|
||||||
return -errno.ENOENT
|
|
||||||
|
|
||||||
def readdir(self, path, offset):
|
|
||||||
yield fuse.Direntry('.')
|
|
||||||
yield fuse.Direntry('..')
|
|
||||||
|
|
||||||
if os.path.dirname(path) in projects: # path is package
|
|
||||||
prj = os.path.dirname(path).replace('/','')
|
|
||||||
pkg = os.path.basename(path)
|
|
||||||
for f in osc.core.meta_get_filelist(osc.conf.config['apiurl'], prj, pkg, verbose=True):
|
|
||||||
st = EmptyStat()
|
|
||||||
st.st_mode = stat.S_IFREG | 0444
|
|
||||||
st.st_size = f.size
|
|
||||||
st.st_atime = f.mtime
|
|
||||||
st.st_ctime = f.mtime
|
|
||||||
st.st_mtime = f.mtime
|
|
||||||
cache[path + '/' + f.name] = CacheEntry()
|
|
||||||
cache[path + '/' + f.name].stat = st
|
|
||||||
yield fuse.Direntry(f.name)
|
|
||||||
return
|
|
||||||
|
|
||||||
if path in projects: # path is project
|
|
||||||
prj = path.replace('/','')
|
|
||||||
for p in osc.core.meta_get_packagelist(osc.conf.config['apiurl'], prj):
|
|
||||||
yield fuse.Direntry(p)
|
|
||||||
|
|
||||||
else: # path is project structure
|
|
||||||
if (path != '/'):
|
|
||||||
path += '/'
|
|
||||||
l = len(path)
|
|
||||||
for d in set( map(lambda x: x[l:].split('/')[0], filter(lambda x: x.startswith(path), projects) ) ) :
|
|
||||||
yield fuse.Direntry(d)
|
|
||||||
|
|
||||||
def mythread ( self ):
|
|
||||||
print '*** mythread'
|
|
||||||
return -errno.ENOSYS
|
|
||||||
|
|
||||||
def chmod ( self, path, mode ):
|
|
||||||
print '*** chmod', path, oct(mode)
|
|
||||||
return -errno.ENOSYS
|
|
||||||
|
|
||||||
def chown ( self, path, uid, gid ):
|
|
||||||
print '*** chown', path, uid, gid
|
|
||||||
return -errno.ENOSYS
|
|
||||||
|
|
||||||
def fsync ( self, path, isFsyncFile ):
|
|
||||||
print '*** fsync', path, isFsyncFile
|
|
||||||
return -errno.ENOSYS
|
|
||||||
|
|
||||||
def link ( self, targetPath, linkPath ):
|
|
||||||
print '*** link', targetPath, linkPath
|
|
||||||
return -errno.ENOSYS
|
|
||||||
|
|
||||||
def mkdir ( self, path, mode ):
|
|
||||||
print '*** mkdir', path, oct(mode)
|
|
||||||
return -errno.ENOSYS
|
|
||||||
|
|
||||||
def mknod ( self, path, mode, dev ):
|
|
||||||
print '*** mknod', path, oct(mode), dev
|
|
||||||
return -errno.ENOSYS
|
|
||||||
|
|
||||||
def open ( self, path, flags ):
|
|
||||||
file = os.path.basename(path)
|
|
||||||
d = os.path.dirname(path)
|
|
||||||
pkg = os.path.basename(d)
|
|
||||||
prj = os.path.dirname(d).replace('/','')
|
|
||||||
if not cache.has_key(path):
|
|
||||||
return -errno.ENOENT
|
|
||||||
if cache[path].stat == None:
|
|
||||||
return -errno.ENOENT
|
|
||||||
tmp = tempfile.mktemp(prefix = 'oscfs_')
|
|
||||||
osc.core.get_source_file(osc.conf.config['apiurl'], prj, pkg, file, tmp)
|
|
||||||
cache[path].handle = open(tmp, 'r')
|
|
||||||
cache[path].tmpname = tmp
|
|
||||||
|
|
||||||
def read ( self, path, length, offset ):
|
|
||||||
if not cache.has_key(path):
|
|
||||||
return -errno.EACCES
|
|
||||||
f = cache[path].handle
|
|
||||||
f.seek(offset)
|
|
||||||
return f.read(length)
|
|
||||||
|
|
||||||
def readlink ( self, path ):
|
|
||||||
print '*** readlink', path
|
|
||||||
return -errno.ENOSYS
|
|
||||||
|
|
||||||
def release ( self, path, flags ):
|
|
||||||
if cache.has_key(path):
|
|
||||||
cache[path].handle.close()
|
|
||||||
cache[path].handle = None
|
|
||||||
os.unlink(f.cache[path].tmpname)
|
|
||||||
cache[path].tmpname = None
|
|
||||||
|
|
||||||
def rename ( self, oldPath, newPath ):
|
|
||||||
print '*** rename', oldPath, newPath
|
|
||||||
return -errno.ENOSYS
|
|
||||||
|
|
||||||
def rmdir ( self, path ):
|
|
||||||
print '*** rmdir', path
|
|
||||||
return -errno.ENOSYS
|
|
||||||
|
|
||||||
def statfs ( self ):
|
|
||||||
print '*** statfs'
|
|
||||||
return -errno.ENOSYS
|
|
||||||
|
|
||||||
def symlink ( self, targetPath, linkPath ):
|
|
||||||
print '*** symlink', targetPath, linkPath
|
|
||||||
return -errno.ENOSYS
|
|
||||||
|
|
||||||
def truncate ( self, path, size ):
|
|
||||||
print '*** truncate', path, size
|
|
||||||
return -errno.ENOSYS
|
|
||||||
|
|
||||||
def unlink ( self, path ):
|
|
||||||
print '*** unlink', path
|
|
||||||
return -errno.ENOSYS
|
|
||||||
|
|
||||||
def utime ( self, path, times ):
|
|
||||||
print '*** utime', path, times
|
|
||||||
return -errno.ENOSYS
|
|
||||||
|
|
||||||
def write ( self, path, buf, offset ):
|
|
||||||
print '*** write', path, buf, offset
|
|
||||||
return -errno.ENOSYS
|
|
||||||
|
|
||||||
def fill_projects():
|
|
||||||
try:
|
|
||||||
for prj in osc.core.meta_get_project_list(osc.conf.config['apiurl']):
|
|
||||||
projects.append( '/' + prj.replace(':', ':/') )
|
|
||||||
except:
|
|
||||||
print 'failed'
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
print 'Loading config ...',
|
|
||||||
osc.conf.get_config()
|
|
||||||
print 'OK'
|
|
||||||
print 'Getting projects list ...',
|
|
||||||
fill_projects()
|
|
||||||
print 'OK'
|
|
||||||
print 'Starting FUSE ...',
|
|
||||||
oscfs = oscFS( version = '%prog ' + fuse.__version__, usage = '', dash_s_do = 'setsingle')
|
|
||||||
oscfs.flags = 0
|
|
||||||
oscfs.multithreaded = 0
|
|
||||||
oscfs.parse(values = oscfs, errex = 1)
|
|
||||||
oscfs.main()
|
|
@ -1,3 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
mkdir -p ./test
|
|
||||||
./fuseosc ./test
|
|
@ -1,491 +0,0 @@
|
|||||||
#! /usr/bin/perl -w
|
|
||||||
#
|
|
||||||
# osc_expand_link.pl -- a tool to help osc build packages where an _link exists.
|
|
||||||
# (C) 2006 jw@suse.de, distribute under GPL v2.
|
|
||||||
#
|
|
||||||
# 2006-12-12, jw
|
|
||||||
# 2006-12-15, jw, v0.2 -- {files}{error} gets printed if present.
|
|
||||||
# 2008-03-25, jw, v0.3 -- go via api using iChains and ~/.oscrc
|
|
||||||
# 2008-03-26, jw, v0.4 -- added linked file retrieval and usage.
|
|
||||||
# 2009-10-21, jw, added obsolete warning, in favour of osc co -e
|
|
||||||
|
|
||||||
use Data::Dumper;
|
|
||||||
use LWP::UserAgent;
|
|
||||||
use HTTP::Status;
|
|
||||||
use Digest::MD5;
|
|
||||||
|
|
||||||
my $version = '0.4';
|
|
||||||
my $verbose = 1;
|
|
||||||
|
|
||||||
print "This $0 is obsolete. Please use instead: osc co -e\n";
|
|
||||||
sleep 5;
|
|
||||||
|
|
||||||
# curl buildservice:5352/source/home:jnweiger/vim
|
|
||||||
# curl 'buildservice:5352/source/home:jnweiger/vim?rev=d90bfab4301f758e0d82cf09aa263d37'
|
|
||||||
# curl 'buildservice:5352/source/home:jnweiger/vim/vim.spec?rev=d90bfab4301f758e0d82cf09aa263d37'
|
|
||||||
|
|
||||||
my $cfg = {
|
|
||||||
apiurl => slurp_file(".osc/_apiurl", 1),
|
|
||||||
package => slurp_file(".osc/_package", 1),
|
|
||||||
project => slurp_file(".osc/_project", 1),
|
|
||||||
files => xml_slurp_file(".osc/_files", { container => 'directory', attr => 'merge' }),
|
|
||||||
link => xml_slurp_file(".osc/_link", { container => 'link', attr => 'merge' }),
|
|
||||||
};
|
|
||||||
|
|
||||||
{
|
|
||||||
package CredUserAgent;
|
|
||||||
@ISA = qw(LWP::UserAgent);
|
|
||||||
|
|
||||||
sub new
|
|
||||||
{
|
|
||||||
my $self = LWP::UserAgent::new(@_);
|
|
||||||
$self->agent("osc_expand_link.pl/$version");
|
|
||||||
$self;
|
|
||||||
}
|
|
||||||
sub get_basic_credentials
|
|
||||||
{
|
|
||||||
my ($self, $realm, $uri) = @_;
|
|
||||||
my $netloc = $uri->host_port;
|
|
||||||
|
|
||||||
unless ($self->{auth})
|
|
||||||
{
|
|
||||||
print STDERR "Auth for $realm at $netloc\n";
|
|
||||||
unless (open IN, "<", "$ENV{HOME}/.oscrc")
|
|
||||||
{
|
|
||||||
print STDERR "$ENV{HOME}/.oscrc: $!\n";
|
|
||||||
return (undef, undef);
|
|
||||||
}
|
|
||||||
while (defined (my $line = <IN>))
|
|
||||||
{
|
|
||||||
chomp $line;
|
|
||||||
$self->{auth}{pass} = $1 if $line =~ m{^pass\s*=\s*(\S+)};
|
|
||||||
$self->{auth}{user} = $1 if $line =~ m{^user\s*=\s*(\S+)};
|
|
||||||
}
|
|
||||||
close IN;
|
|
||||||
print STDERR "~/.oscrc: user=$self->{auth}{user}\n";
|
|
||||||
}
|
|
||||||
return ($self->{auth}{user},$self->{auth}{pass});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
my $ua = CredUserAgent->new (keep_alive => 1);
|
|
||||||
|
|
||||||
sub cred_get
|
|
||||||
{
|
|
||||||
my ($url) = @_;
|
|
||||||
my $r = $ua->get($url);
|
|
||||||
die "$url: " . $r->status_line . "\n" unless $r->is_success;
|
|
||||||
return $r->content;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub cred_getstore
|
|
||||||
{
|
|
||||||
my ($url, $file) = @_;
|
|
||||||
my $r = $ua->get($url, ':content_file' => $file);
|
|
||||||
die "$url: " . $r->status_line . "\n" unless $r->is_success;
|
|
||||||
$r->code;
|
|
||||||
}
|
|
||||||
|
|
||||||
$cfg->{apiurl} ||= 'https://api.opensuse.org';
|
|
||||||
$cfg->{project} ||= '<Project>';
|
|
||||||
$cfg->{package} ||= '<Package>';
|
|
||||||
|
|
||||||
chomp $cfg->{apiurl};
|
|
||||||
chomp $cfg->{project};
|
|
||||||
chomp $cfg->{package};
|
|
||||||
|
|
||||||
my $source = "$cfg->{apiurl}/source";
|
|
||||||
my $url = "$source/$cfg->{project}/$cfg->{package}";
|
|
||||||
|
|
||||||
if (my $url = $ARGV[0])
|
|
||||||
{
|
|
||||||
|
|
||||||
die qq{osc_expand_link $version;
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
|
|
||||||
osc co $cfg->{project} $cfg->{package}
|
|
||||||
cd $cfg->{project}/$cfg->{package}
|
|
||||||
$0
|
|
||||||
|
|
||||||
to resolve a _link.
|
|
||||||
|
|
||||||
or
|
|
||||||
|
|
||||||
$0 $cfg->{apiurl}/source/$cfg->{project}/$cfg->{package}
|
|
||||||
|
|
||||||
to review internal buildservice data.
|
|
||||||
|
|
||||||
or
|
|
||||||
$0 $cfg->{apiurl}/source/$cfg->{project}/$cfg->{package}/linked/\\*.spec
|
|
||||||
|
|
||||||
cd $cfg->{project}/$cfg->{package}
|
|
||||||
$0 linked \\*.spec
|
|
||||||
|
|
||||||
to retrieve the original specfile behind a link.
|
|
||||||
|
|
||||||
} if $url =~ m{^-};
|
|
||||||
|
|
||||||
$url = "$url/$ARGV[1]" if $url eq 'linked' and $ARGV[1];
|
|
||||||
if ($url =~ m{^(.*/)?linked/(.*)$})
|
|
||||||
{
|
|
||||||
$url = (defined $1) ? $1 : "$cfg->{project}/$cfg->{package}";
|
|
||||||
my $file = $2;
|
|
||||||
$url = "$source/$url" if $cfg->{apiurl} and $url !~ m{://};
|
|
||||||
print STDERR "$url\n";
|
|
||||||
my $dir = xml_parse(cred_get($url), 'merge');
|
|
||||||
my $li = $dir->{directory}{linkinfo} || die "no linkinfo in $url\n";
|
|
||||||
$url = "$source/$li->{project}/$li->{package}";
|
|
||||||
mkdir("linked");
|
|
||||||
|
|
||||||
if ($file =~ m{\*})
|
|
||||||
{
|
|
||||||
my $dir = xml_parse(cred_get($url), 'merge');
|
|
||||||
$dir = $dir->{directory} if $dir->{directory};
|
|
||||||
my @list = sort map { $_->{name} } @{$dir->{entry}};
|
|
||||||
my $file_re = "\Q$file\E"; $file_re =~ s{\\\*}{\.\*}g;
|
|
||||||
my @match = grep { $_ =~ m{^$file_re$} } @list;
|
|
||||||
die "pattern $file not found in\n @list\n" unless @match;
|
|
||||||
$file = $match[0];
|
|
||||||
}
|
|
||||||
$url .= "/$file";
|
|
||||||
|
|
||||||
print STDERR "$url -> linked/$file\n";
|
|
||||||
my $r = cred_getstore($url, "linked/$file");
|
|
||||||
print STDERR " Error: $r\n" if $r != RC_OK;
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$url = "$cfg->{project}/$cfg->{package}/$url" unless $url =~ m{/};
|
|
||||||
$url = "$source/$url" if $cfg->{apiurl} and $url !~ m{://};
|
|
||||||
print cred_get($url);
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
warn "$cfg->{project}/$cfg->{package} error: $cfg->{files}{error}\n" if $cfg->{files}{error};
|
|
||||||
die "$cfg->{project}/$cfg->{package} has no _link\n" unless $cfg->{link};
|
|
||||||
die "$cfg->{project}/$cfg->{package} has no xsrcmd5\n" unless $cfg->{files}{xsrcmd5};
|
|
||||||
|
|
||||||
print STDERR "expanding link to $cfg->{link}{project}/$cfg->{link}{package}\n";
|
|
||||||
if (my $p = $cfg->{link}{patches})
|
|
||||||
{
|
|
||||||
$p = [ $p ] if ref $p ne 'ARRAY';
|
|
||||||
my @p = map { "$_->{apply}{name}" } @$p;
|
|
||||||
print STDERR "applied patches: " . join(',', @p) . "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
my $dir = xml_parse(cred_get("$url?rev=$cfg->{files}{xsrcmd5}"), 'merge');
|
|
||||||
$dir = $dir->{directory} if defined $dir->{directory};
|
|
||||||
$dir->{entry} = [ $dir->{entry} ] if ref $dir->{entry} ne 'ARRAY';
|
|
||||||
for my $file (@{$dir->{entry}})
|
|
||||||
{
|
|
||||||
if (-f $file->{name})
|
|
||||||
{
|
|
||||||
## check the md5sum of the existing file and be happy.
|
|
||||||
$md5 = Digest::MD5->new;
|
|
||||||
open IN, "<", $file->{name} or die "md5sum($file->{name} failed: $!";
|
|
||||||
$md5->addfile(*IN);
|
|
||||||
close IN;
|
|
||||||
if ($md5->hexdigest eq $file->{md5})
|
|
||||||
{
|
|
||||||
print STDERR " - $file->{name} (md5 unchanged)\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print STDERR "Modified: $file->{name}, please commit changes!\n";
|
|
||||||
}
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
print STDERR " get $file->{name}";
|
|
||||||
# fixme: xsrcmd5 is obsolete.
|
|
||||||
# use <linkinfo project="openSUSE:Factory" package="avrdude" xsrcmd5="a39c2bd14c3ad5dbb82edd7909fcdfc4">
|
|
||||||
my $response = cred_getstore("$url/$file->{name}?rev=$cfg->{files}{xsrcmd5}", $file->{name});
|
|
||||||
print STDERR ($response == RC_OK) ? "\n" : " Error:$response\n";
|
|
||||||
}
|
|
||||||
exit 0;
|
|
||||||
##########################################################################
|
|
||||||
|
|
||||||
sub slurp_file
|
|
||||||
{
|
|
||||||
my ($path, $silent) = @_;
|
|
||||||
open IN, "<", $path or ($silent ? return undef : die "slurp_file($path) failed: $!\n");
|
|
||||||
my $body = join '', <IN>;
|
|
||||||
close IN;
|
|
||||||
return $body;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#################################################################
|
|
||||||
## xml parser imported from w3dcm.pl and somewhat expanded.
|
|
||||||
## 2006-12-15, jw
|
|
||||||
##
|
|
||||||
## xml_parse assumes correct container closing.
|
|
||||||
## Any </...> tag would closes an open <foo>.
|
|
||||||
## Thus xml_parse is not suitable for HTML.
|
|
||||||
##
|
|
||||||
sub xml_parse
|
|
||||||
{
|
|
||||||
my ($text, $attr) = @_;
|
|
||||||
my %xml;
|
|
||||||
my @stack = ();
|
|
||||||
my $t = \%xml;
|
|
||||||
|
|
||||||
#print "xml_parse: '$text'\n";
|
|
||||||
my @tags = find_tags($text);
|
|
||||||
for my $i (0 .. $#tags)
|
|
||||||
{
|
|
||||||
my $tag = substr $text, $tags[$i]->{offset}, $tags[$i]->{tag_len};
|
|
||||||
my $cdata = '';
|
|
||||||
my $s = $tags[$i]->{offset} + $tags[$i]->{tag_len};
|
|
||||||
if (defined $tags[$i+1])
|
|
||||||
{
|
|
||||||
my $l = $tags[$i+1]->{offset} - $s;
|
|
||||||
$cdata = substr $text, $s, $l;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$cdata = substr $text, $s;
|
|
||||||
}
|
|
||||||
|
|
||||||
# print "tag=$tag\n";
|
|
||||||
my $name = $1 if $tag =~ s{<([\?/]?[\w:-]+)\s*}{};
|
|
||||||
$tag =~ s{>\s*$}{};
|
|
||||||
my $nest = ($tag =~ s{[\?/]$}{}) ? 0 : 1;
|
|
||||||
my $close = ($name =~ s{^/}{}) ? 1 : 0;
|
|
||||||
# print "name=$name, attr='$tag', $close, $nest, '$cdata'\n";
|
|
||||||
|
|
||||||
my $x = {};
|
|
||||||
$x->{-cdata} .= $cdata if $nest;
|
|
||||||
xml_add_attr($x, $tag, $attr) unless $tag eq '';
|
|
||||||
|
|
||||||
if (!$close)
|
|
||||||
{
|
|
||||||
delete $t->{-cdata} if $t->{-cdata} and $t->{-cdata} =~ m{^\s*$};
|
|
||||||
unless ($t->{$name})
|
|
||||||
{
|
|
||||||
$t->{$name} = $x;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$t->{$name} = [ $t->{$name} ] unless ref $t->{$name} eq 'ARRAY';
|
|
||||||
push @{$t->{$name}}, $x;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ($close)
|
|
||||||
{
|
|
||||||
$t = pop @stack;
|
|
||||||
}
|
|
||||||
elsif ($nest)
|
|
||||||
{
|
|
||||||
push @stack, $t;
|
|
||||||
$t = $x;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print "stack=", Data::Dumper::Dumper(\@stack) if $verbose > 2;
|
|
||||||
scalar_cdata($t);
|
|
||||||
return $t;
|
|
||||||
}
|
|
||||||
|
|
||||||
##
|
|
||||||
## reads a file formatted by xml_make, and returns a hash.
|
|
||||||
## The toplevel container is removed from that hash, if specified.
|
|
||||||
## A wildcard '*' can be specified to remove any toplevel container.
|
|
||||||
## Otherwise the name of the container must match precisely.
|
|
||||||
##
|
|
||||||
sub xml_slurp_file
|
|
||||||
{
|
|
||||||
my ($file, $opt) = @_;
|
|
||||||
unless (open IN, "<$file")
|
|
||||||
{
|
|
||||||
return undef unless $opt->{die};
|
|
||||||
die "xml_slurp($opt->{container}): cannot read $file: $!\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
my $xml = join '', <IN>; close IN;
|
|
||||||
$xml = xml_parse($xml, $opt->{attr});
|
|
||||||
if (my $container = $opt->{container})
|
|
||||||
{
|
|
||||||
die "xml_slurp($file, '$container') malformed file, should have only one toplevel node.\n"
|
|
||||||
unless scalar keys %$xml == 1;
|
|
||||||
$container = (keys %$xml)[0] if $container eq '' or $container eq '*';
|
|
||||||
die "xml_slurp($file, '$container') toplevel tag missing or wrong.\n" unless $xml->{$container};
|
|
||||||
$xml = $xml->{$container};
|
|
||||||
}
|
|
||||||
return $xml;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub xml_escape
|
|
||||||
{
|
|
||||||
my ($text) = @_;
|
|
||||||
|
|
||||||
## XML::Simple does just that:
|
|
||||||
$text =~ s{&}{&}g;
|
|
||||||
$text =~ s{<}{<}g;
|
|
||||||
$text =~ s{>}{>}g;
|
|
||||||
$text =~ s{"}{"}g;
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub xml_unescape
|
|
||||||
{
|
|
||||||
my ($text) = @_;
|
|
||||||
|
|
||||||
## XX: Fimxe: we should handle some more escapes here...
|
|
||||||
## and better do it in a single pass.
|
|
||||||
$text =~ s{&#([\d]{3});}{chr $1}eg;
|
|
||||||
$text =~ s{<}{<}g;
|
|
||||||
$text =~ s{>}{>}g;
|
|
||||||
$text =~ s{"}{"}g;
|
|
||||||
$text =~ s{&}{&}g;
|
|
||||||
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
|
|
||||||
##
|
|
||||||
## find all hashes, that contain exactly one key named '-cdata'
|
|
||||||
## and replace these hashes with the value of that key.
|
|
||||||
## These values are scalar when created by xml_parse(), hence the name.
|
|
||||||
##
|
|
||||||
sub scalar_cdata
|
|
||||||
{
|
|
||||||
my ($hash) = @_;
|
|
||||||
my $selftag = '.scalar_cdata_running';
|
|
||||||
|
|
||||||
return unless ref $hash eq 'HASH';
|
|
||||||
return if $hash->{$selftag};
|
|
||||||
$hash->{$selftag} = 1;
|
|
||||||
|
|
||||||
for my $key (keys %$hash)
|
|
||||||
{
|
|
||||||
my $val = $hash->{$key};
|
|
||||||
if (ref $val eq 'ARRAY')
|
|
||||||
{
|
|
||||||
for my $i (0..$#$val)
|
|
||||||
{
|
|
||||||
scalar_cdata($hash->{$key}[$i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elsif (ref $val eq 'HASH')
|
|
||||||
{
|
|
||||||
my @k = keys %$val;
|
|
||||||
if (scalar(@k) == 1 && ($k[0] eq '-cdata'))
|
|
||||||
{
|
|
||||||
$hash->{$key} = $hash->{$key}{-cdata};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
delete $hash->{$key}{-cdata} if exists $val->{-cdata} && $val->{-cdata} =~ m{^\s*$};
|
|
||||||
scalar_cdata($hash->{$key});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete $hash->{$selftag};
|
|
||||||
}
|
|
||||||
|
|
||||||
##
|
|
||||||
## find_tags -- a brute force tag finder.
|
|
||||||
## This code is robust enough to parse the weirdest HTML.
|
|
||||||
## An Array containing hashes of { offset, name, tag_len } is returned.
|
|
||||||
## CDATA is skipped, but can be determined from gaps between tags.
|
|
||||||
## The name parser may chop names, so XML-style tag names are
|
|
||||||
## unreliable.
|
|
||||||
##
|
|
||||||
sub find_tags
|
|
||||||
{
|
|
||||||
my ($text) = @_;
|
|
||||||
my $last = '';
|
|
||||||
my @tags;
|
|
||||||
my $inquotes = 0;
|
|
||||||
my $incomment = 0;
|
|
||||||
|
|
||||||
while ($text =~ m{(<!--|-->|"|>|<)(/?\w*)}g)
|
|
||||||
{
|
|
||||||
my ($offset, $what, $name) = (length $`, $1, $2);
|
|
||||||
|
|
||||||
if ($inquotes)
|
|
||||||
{
|
|
||||||
$inquotes = 0 if $what eq '"';
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($incomment)
|
|
||||||
{
|
|
||||||
$incomment = 0 if $what eq '-->';
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($what eq '"')
|
|
||||||
{
|
|
||||||
$inquotes = 1;
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($what eq '<!--')
|
|
||||||
{
|
|
||||||
$incomment = 1;
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
next if $what eq $last; # opening and closing angular brackets are polar.
|
|
||||||
|
|
||||||
if ($what eq '>' and scalar @tags)
|
|
||||||
{
|
|
||||||
$tags[$#tags]{tag_len} = 1 + $offset - $tags[$#tags]{offset};
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($what eq '<')
|
|
||||||
{
|
|
||||||
push @tags, {name => $name, offset => $offset };
|
|
||||||
}
|
|
||||||
|
|
||||||
$last = $what;
|
|
||||||
}
|
|
||||||
return @tags;
|
|
||||||
}
|
|
||||||
|
|
||||||
##
|
|
||||||
## how = undef: defaults to '-attr plain'
|
|
||||||
## how = '-attr plain': add the attributes as one scalar value to hash-element -attr
|
|
||||||
## how = '-attr hash': add the attributes as a hash-ref to hash-element -attr
|
|
||||||
## how = 'merge': add the attributes as direct hash elements. (This is irreversible)
|
|
||||||
##
|
|
||||||
## attributes are either space-separated, or delimited with '' or "".
|
|
||||||
sub xml_add_attr
|
|
||||||
{
|
|
||||||
my ($hash, $text, $how) = @_;
|
|
||||||
$how = 'plain' unless $how;
|
|
||||||
my $tag = '-attr'; $tag = $1 if $how =~ s{^\s*([\w_:-]+)\s+(.*)$}{$2};
|
|
||||||
$how = lc $how;
|
|
||||||
|
|
||||||
return $hash->{$tag} = $text if $how eq 'plain';
|
|
||||||
|
|
||||||
if ($how eq 'hash')
|
|
||||||
{
|
|
||||||
$hash = $hash->{$tag} = {};
|
|
||||||
$how = 'merge';
|
|
||||||
## fallthrough
|
|
||||||
}
|
|
||||||
if ($how eq 'merge')
|
|
||||||
{
|
|
||||||
while ($text =~ m{([\w_:-]+)\s*=("[^"]*"|'[^']'|\S*)\s*}g)
|
|
||||||
{
|
|
||||||
my ($key, $val) = ($1, $2);
|
|
||||||
$val =~ s{^"(.*)"$}{$1} unless $val =~ s{^'(.*)'$}{$1};
|
|
||||||
if (defined($hash->{$key}))
|
|
||||||
{
|
|
||||||
## redefinition. promote to array and push.
|
|
||||||
$hash->{$key} = [ $hash->{$key} ] unless ref $hash->{$key};
|
|
||||||
push @{$hash->{$key}}, $val;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$hash->{$key} = $val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $hash;
|
|
||||||
}
|
|
||||||
die "xml_expand_attr: unknown method '$how'\n";
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# you can pass as argument "csv","json" or "txt" (default)
|
|
||||||
if [ "$1" != "" ];then
|
|
||||||
OUTPUT=$1
|
|
||||||
else
|
|
||||||
OUTPUT="txt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# check if bandit is installed
|
|
||||||
command -v bandit >/dev/null 2>&1 || { echo "bandit should be installed. get the package from https://build.opensuse.org/package/show/home:vpereirabr/python-bandit. Aborting." >&2; exit 1; }
|
|
||||||
|
|
||||||
bandit -c /usr/etc/bandit/bandit.yaml -r osc -f $OUTPUT
|
|
||||||
|
|
||||||
if [ "$OUTPUT" == "csv" ];then
|
|
||||||
cat bandit_results.csv
|
|
||||||
rm -f bandit_results.csv
|
|
||||||
fi
|
|
Loading…
Reference in New Issue
Block a user