Skip to content

Commit

Permalink
Allow to use "tar" service also standalone.
Browse files Browse the repository at this point in the history
One use case is to maintain a package in git repo and just
create tar balls at buildtime.

Example (in this case with submodule) can be found here

  https://github.com/adrianschroeter/git-example-4
  • Loading branch information
adrianschroeter committed Feb 14, 2024
1 parent e7c0883 commit 82fdcd4
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions TarSCM/scm/tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,35 @@ def fetch_upstream(self):
if files:
# or we refactor and loop about all on future
self.args.obsinfo = files[0]
if self.args.obsinfo is None:
raise SystemExit("ERROR: no .obsinfo file found in directory: "

version = None
if self.args.obsinfo:
self.basename = self.clone_dir = self.read_from_obsinfo(
self.args.obsinfo, "name"
)
version = self.read_from_obsinfo(self.args.obsinfo, "version")

if self.args.filename:
self.basename = self.clone_dir = self.args.filename

if self.args.version:
version = self.args.version

if not self.basename or not self.clone_dir:
raise SystemExit("ERROR: no .obsinfo file found in directory\n"
" and no manual configuration: "
"'%s'" % os.getcwd())
self.basename = self.clone_dir = self.read_from_obsinfo(
self.args.obsinfo,
"name"
)
if "/" in self.clone_dir:
sys.exit("name in obsinfo contains '/'.")

version = self.read_from_obsinfo(self.args.obsinfo, "version")

if "/" in version or '..' in version:
sys.exit("verion in obsinfo contains '/' or '..'.")
sys.exit("version in obsinfo contains '/' or '..'.")

if version != '':
if version != '' and version != '_none_':
self.clone_dir += "-" + version

if not os.path.exists(self.clone_dir):
if not os.path.exists(self.clone_dir) and
self.basename != self.clone_dir:
self._final_rename_needed = True
# not need in case of local osc build
try:
Expand All @@ -51,10 +61,14 @@ def update_cache(self):

def detect_version(self, args):
"""Read former stored version."""
return self.read_from_obsinfo(self.args.obsinfo, "version")
if self.args.obsinfo:
return self.read_from_obsinfo(self.args.obsinfo, "version")

def get_timestamp(self):
return int(self.read_from_obsinfo(self.args.obsinfo, "mtime"))
if self.args.obsinfo:
return int(self.read_from_obsinfo(self.args.obsinfo, "mtime"))
if self.args.filename:
return int(os.path.getmtime(self.args.filename))

def read_from_obsinfo(self, filename, key):
infofile = open(filename, "r")
Expand Down

0 comments on commit 82fdcd4

Please sign in to comment.