pungi-koji: add option for not creating latest symbol link
Fixes: #53 Signed-off-by: Qixiang Wan <qwan@redhat.com>
This commit is contained in:
parent
e02ed6c04b
commit
1345eb87a4
@ -119,6 +119,13 @@ def main():
|
|||||||
"--notification-script",
|
"--notification-script",
|
||||||
help="script for sending progress notification messages"
|
help="script for sending progress notification messages"
|
||||||
)
|
)
|
||||||
|
parser.add_option(
|
||||||
|
"--no-latest-link",
|
||||||
|
action="store_true",
|
||||||
|
default=False,
|
||||||
|
dest="no_latest_link",
|
||||||
|
help="don't create latest symbol link to this compose"
|
||||||
|
)
|
||||||
|
|
||||||
opts, args = parser.parse_args()
|
opts, args = parser.parse_args()
|
||||||
import pungi.notifier
|
import pungi.notifier
|
||||||
@ -160,6 +167,8 @@ def main():
|
|||||||
abort("please specify a config")
|
abort("please specify a config")
|
||||||
opts.config = os.path.abspath(opts.config)
|
opts.config = os.path.abspath(opts.config)
|
||||||
|
|
||||||
|
create_latest_link = not opts.no_latest_link
|
||||||
|
|
||||||
import kobo.conf
|
import kobo.conf
|
||||||
import kobo.log
|
import kobo.log
|
||||||
import productmd.composeinfo
|
import productmd.composeinfo
|
||||||
@ -210,13 +219,13 @@ def main():
|
|||||||
notifier.compose = compose
|
notifier.compose = compose
|
||||||
COMPOSE = compose
|
COMPOSE = compose
|
||||||
try:
|
try:
|
||||||
run_compose(compose)
|
run_compose(compose, create_latest_link)
|
||||||
except Exception, ex:
|
except Exception, ex:
|
||||||
compose.log_error("Compose run failed: %s" % ex)
|
compose.log_error("Compose run failed: %s" % ex)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
def run_compose(compose):
|
def run_compose(compose, create_latest_link=True):
|
||||||
import pungi.phases
|
import pungi.phases
|
||||||
import pungi.metadata
|
import pungi.metadata
|
||||||
|
|
||||||
@ -390,25 +399,26 @@ def run_compose(compose):
|
|||||||
test_phase.start()
|
test_phase.start()
|
||||||
test_phase.stop()
|
test_phase.stop()
|
||||||
|
|
||||||
# create a latest symlink
|
if create_latest_link:
|
||||||
compose_dir = os.path.basename(compose.topdir)
|
# create a latest symlink
|
||||||
if len(compose.conf["release_version"].split(".")) == 1:
|
compose_dir = os.path.basename(compose.topdir)
|
||||||
symlink_name = "latest-%s-%s" % (compose.conf["release_short"], compose.conf["release_version"])
|
if len(compose.conf["release_version"].split(".")) == 1:
|
||||||
else:
|
symlink_name = "latest-%s-%s" % (compose.conf["release_short"], compose.conf["release_version"])
|
||||||
symlink_name = "latest-%s-%s" % (compose.conf["release_short"], ".".join(compose.conf["release_version"].split(".")[:-1]))
|
else:
|
||||||
if compose.conf["release_is_layered"]:
|
symlink_name = "latest-%s-%s" % (compose.conf["release_short"], ".".join(compose.conf["release_version"].split(".")[:-1]))
|
||||||
symlink_name += "-%s-%s" % (compose.conf["base_product_short"], compose.conf["base_product_version"])
|
if compose.conf["release_is_layered"]:
|
||||||
symlink = os.path.join(compose.topdir, "..", symlink_name)
|
symlink_name += "-%s-%s" % (compose.conf["base_product_short"], compose.conf["base_product_version"])
|
||||||
|
symlink = os.path.join(compose.topdir, "..", symlink_name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.unlink(symlink)
|
os.unlink(symlink)
|
||||||
except OSError as ex:
|
except OSError as ex:
|
||||||
if ex.errno != 2:
|
if ex.errno != 2:
|
||||||
raise
|
raise
|
||||||
try:
|
try:
|
||||||
os.symlink(compose_dir, symlink)
|
os.symlink(compose_dir, symlink)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
compose.log_error("Couldn't create latest symlink: %s" % ex)
|
compose.log_error("Couldn't create latest symlink: %s" % ex)
|
||||||
|
|
||||||
compose.log_info("Compose finished: %s" % compose.topdir)
|
compose.log_info("Compose finished: %s" % compose.topdir)
|
||||||
compose.write_status("FINISHED")
|
compose.write_status("FINISHED")
|
||||||
|
Loading…
Reference in New Issue
Block a user