Factor out create_dist.
This commit is contained in:
parent
c657df7b17
commit
45e0f797e4
3 changed files with 29 additions and 9 deletions
|
@ -69,4 +69,3 @@ class UpstreamOutput(object):
|
||||||
|
|
||||||
def get_declared_dependencies(self):
|
def get_declared_dependencies(self):
|
||||||
raise NotImplementedError(self.get_declared_dependencies)
|
raise NotImplementedError(self.get_declared_dependencies)
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ from .buildsystem import NoBuildToolsFound, detect_buildsystems
|
||||||
from .resolver import (
|
from .resolver import (
|
||||||
auto_resolver,
|
auto_resolver,
|
||||||
native_resolvers,
|
native_resolvers,
|
||||||
UnsatisfiedRequirements,
|
|
||||||
)
|
)
|
||||||
from .resolver.apt import AptResolver
|
from .resolver.apt import AptResolver
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,13 @@
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
'UnidentifiedError',
|
||||||
|
'DetailedFailure',
|
||||||
|
'create_dist',
|
||||||
|
'create_dist_schroot',
|
||||||
|
]
|
||||||
|
|
||||||
import errno
|
import errno
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
@ -33,7 +40,7 @@ from buildlog_consultant.common import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
from . import DetailedFailure
|
from . import DetailedFailure, UnidentifiedError
|
||||||
from .buildsystem import NoBuildToolsFound
|
from .buildsystem import NoBuildToolsFound
|
||||||
from .session import Session
|
from .session import Session
|
||||||
from .session.schroot import SchrootSession
|
from .session.schroot import SchrootSession
|
||||||
|
@ -129,7 +136,7 @@ def create_dist(
|
||||||
packaging_tree: Optional[Tree] = None,
|
packaging_tree: Optional[Tree] = None,
|
||||||
include_controldir: bool = True,
|
include_controldir: bool = True,
|
||||||
subdir: Optional[str] = None,
|
subdir: Optional[str] = None,
|
||||||
) -> str:
|
) -> Optional[str]:
|
||||||
from .buildsystem import detect_buildsystems
|
from .buildsystem import detect_buildsystems
|
||||||
from .resolver.apt import AptResolver
|
from .resolver.apt import AptResolver
|
||||||
from .buildlog import InstallFixer
|
from .buildlog import InstallFixer
|
||||||
|
@ -158,9 +165,16 @@ def create_dist(
|
||||||
session.chdir(reldir)
|
session.chdir(reldir)
|
||||||
run_dist(session, buildsystems, resolver, fixers)
|
run_dist(session, buildsystems, resolver, fixers)
|
||||||
|
|
||||||
for path in dc.files:
|
try:
|
||||||
shutil.copy(path, target_dir)
|
for path in dc.files:
|
||||||
return os.path.join(target_dir, os.path.basename(path))
|
shutil.copy(path, target_dir)
|
||||||
|
return os.path.join(target_dir, os.path.basename(path))
|
||||||
|
finally:
|
||||||
|
for path in dc.files:
|
||||||
|
if os.path.isdir(path):
|
||||||
|
shutil.rmtree(path)
|
||||||
|
else:
|
||||||
|
os.unlink(path)
|
||||||
|
|
||||||
logging.info("No tarball created :(")
|
logging.info("No tarball created :(")
|
||||||
raise DistNoTarball()
|
raise DistNoTarball()
|
||||||
|
@ -173,7 +187,7 @@ def create_dist_schroot(
|
||||||
packaging_tree: Optional[Tree] = None,
|
packaging_tree: Optional[Tree] = None,
|
||||||
include_controldir: bool = True,
|
include_controldir: bool = True,
|
||||||
subdir: Optional[str] = None,
|
subdir: Optional[str] = None,
|
||||||
) -> str:
|
) -> Optional[str]:
|
||||||
session = SchrootSession(chroot)
|
session = SchrootSession(chroot)
|
||||||
return create_dist(
|
return create_dist(
|
||||||
session, tree, target_dir,
|
session, tree, target_dir,
|
||||||
|
@ -239,6 +253,14 @@ if __name__ == "__main__":
|
||||||
except NoBuildToolsFound:
|
except NoBuildToolsFound:
|
||||||
logging.info("No build tools found, falling back to simple export.")
|
logging.info("No build tools found, falling back to simple export.")
|
||||||
export(tree, "dist.tar.gz", "tgz", None)
|
export(tree, "dist.tar.gz", "tgz", None)
|
||||||
|
except NotImplementedError:
|
||||||
|
logging.info("Build system does not support dist tarball creation, "
|
||||||
|
"falling back to simple export.")
|
||||||
|
export(tree, "dist.tar.gz", "tgz", None)
|
||||||
|
except UnidentifiedError as e:
|
||||||
|
logging.fatal('Unidentified error: %r', e.lines)
|
||||||
|
except DetailedFailure as e:
|
||||||
|
logging.fatal('Identified error during dist creation: %s', e.error)
|
||||||
else:
|
else:
|
||||||
print("Created %s" % ret)
|
logging.info("Created %s", ret)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue