Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
New command cleanbuild (using lxd) #328
Conversation
|
Hello there, this is I skipped adding an integration test as it seemed way to invasive. |
elopio
reviewed
Feb 19, 2016
| +""" | ||
| +snapcraft cleanbuild | ||
| + | ||
| +Uses a container using lxd to create the resulting snap. |
elopio
Feb 19, 2016
Member
Maybe also instead of "to create the resulting snap", just "to build the snap".
elopio
reviewed
Feb 19, 2016
| +local sources is not using any dependencies local to the developer system. | ||
| + | ||
| +The cleanbuild command requires a properly setup lxd environment that | ||
| +can connect to external networks. |
elopio
reviewed
Feb 19, 2016
| + | ||
| +from snapcraft import repo | ||
| +from snapcraft.lxd import Cleanbuilder | ||
| +from snapcraft.common import format_snap_name |
elopio
Feb 19, 2016
Member
hum, I dislike the import of symbols instead of modules.
But if you prefer it this way, as long as we are consistent I can live with it. Should we start using this style?
sergiusens
Feb 19, 2016
Collaborator
We already have this all over; it really depends on the length of what you import.
elopio
reviewed
Feb 19, 2016
| + | ||
| +def _create_tar_filter(tar_filename): | ||
| + def _tar_filter(tarinfo): | ||
| + fn = tarinfo.name |
elopio
Feb 19, 2016
Member
why not file_name instead of fn? oh no, you are a go programmer again! :D
sergiusens
Feb 19, 2016
Collaborator
hah, it's because the resulting lines below would have the horrible python semantics due to line length restrictions
elopio
reviewed
Feb 19, 2016
| +from snapcraft.yaml import load_config | ||
| + | ||
| +logger = logging.getLogger(__name__) | ||
| +_DEFAULT_IMAGE_SERVER = 'https://images.linuxcontainers.org:8443' |
elopio
reviewed
Feb 19, 2016
| + self._container_name]) | ||
| + yield | ||
| + finally: | ||
| + check_call(['lxc', 'stop', self._container_name]) |
elopio
reviewed
Feb 19, 2016
| + def _setup_project(self): | ||
| + logger.info('Setting up container with project assets') | ||
| + dst = os.path.join('/root', os.path.basename(self._project)) | ||
| + self._push_file(self._project, dst) |
elopio
Feb 19, 2016
Member
I thought it would be nice (and easier) to mount the directory in the container. Then you could inspect the part dirs after the container was killed, and no need to copy things around.
sergiusens
Feb 19, 2016
Collaborator
Mounting requires root though. I prefer this non requiring root scenario as an initial implementation.
elopio
reviewed
Feb 19, 2016
| + self._setup_project() | ||
| + self._wait_for_network() | ||
| + self._container_run(['apt-get', 'update']) | ||
| + self._container_run(['apt-get', 'install', 'snapcraft', '-y']) |
elopio
Feb 19, 2016
Member
Oh, I was kind of hoping that we could use the same snapcraft from the host. If we get it from the archive then it's not really useful for testing snapcraft itself.
sergiusens
Feb 19, 2016
Collaborator
The problem with that is that you won't be able to drive builds from a different snapcraft version on a different series.
elopio
reviewed
Feb 19, 2016
| + self.state_file = os.path.join(common.get_partsdir(), 'part1', 'state') | ||
| + | ||
| + @mock.patch('snapcraft.lxd.check_call') | ||
| + def test_cleanbuild(self, mock_call): |
elopio
reviewed
Feb 19, 2016
| @@ -91,7 +91,7 @@ def get_arch(): | ||
| return _DEB_TRANSLATIONS[platform.machine()]['arch'] | ||
| except KeyError: | ||
| raise EnvironmentError( | ||
| - '{} is not supported, please log a bug at' | ||
| + '{} is not supported, please log a bug at ' |
|
I like this very much. I left many comments just because I'm cranky and want to start my vacations :) |
chipaca
reviewed
Feb 19, 2016
| + fn = tarinfo.name | ||
| + if fn.startswith('./parts/') and not fn.startswith('./parts/plugins'): | ||
| + return None | ||
| + elif any(fn == d for d in ('./stage', './snap', tar_filename)): |
chipaca
Feb 19, 2016
Member
I find fn in ('./stage', './snap', tar_filename) more readable than this
chipaca
reviewed
Feb 19, 2016
| + | ||
| + | ||
| +def main(argv=None): | ||
| + argv = argv if argv else [] |
chipaca
reviewed
Feb 19, 2016
| @@ -100,10 +100,16 @@ def get_arch_triplet(): | ||
| return _DEB_TRANSLATIONS[platform.machine()]['triplet'] | ||
| except KeyError: | ||
| raise EnvironmentError( | ||
| - '{} is not supported, please log a bug at' | ||
| + '{} is not supported, please log a bug at ' | ||
| 'https://bugs.launchpad.net/snapcraft'.format(platform.machine())) |
chipaca
Feb 19, 2016
Member
ooh :-) can I suggest you change the link to go to e.g. https://bugs.launchpad.net/snapcraft/+filebug?field.title=please+add+support+for+{1} ?
chipaca
reviewed
Feb 19, 2016
| + retry_count -= 1 | ||
| + if retry_count == 0: | ||
| + raise e | ||
| + pass |
chipaca
Feb 19, 2016
Member
pass is spurious there.
Personally I would've done this without the flag variable, but that's probably because I don't like flag variables :-)
while True:
sleep(5)
try: ...
except: ...
else: break # done
|
|
sergiusens commentedFeb 19, 2016
This new command's intention is to make building with a clean
slate and easy chore.
LP: #1480144
Signed-off-by: Sergio Schvezov sergio.schvezov@ubuntu.com