adafruit / arduino-board-index

Adafruit Package Lists for the Arduino v1.6.4+ Board Manager
https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
39 stars 29 forks source link

"bpt.py update_index" should remove .git folder before writing archive file #14

Closed hathach closed 5 years ago

hathach commented 6 years ago

.git folder is included in the tar.bz2 archive file. It should be removed to reduce BSP size.

ladyada commented 6 years ago

you mean this line? https://github.com/adafruit/arduino-board-index/blob/gh-pages/bpt.py#L181

hathach commented 6 years ago

yeah I think it is that one, It will later call the write_archive https://github.com/adafruit/arduino-board-index/blob/gh-pages/bpt_model.py#L152

which will add the whole folder including the .git . looking at some recent package e.g boards/adafruit-samd-1.2.2.tar.bz2 The .git folder is half of the size but not useful to end user.

image

ladyada commented 6 years ago

got it! next time we do an update let me know, and ill test/update the script then, OK?

hathach commented 6 years ago

ok, I will ping you next release :+1:

hathach commented 5 years ago

@ladyada doing release for nrf52. Seem like bpt_model did try to exclude .git when write_archive() but somehow .git still manage to go through.

https://github.com/adafruit/arduino-board-index/blob/gh-pages/bpt_model.py#L155

ladyada commented 5 years ago

sorry i did not get to it yet! do you want to wait before relesae and i can look this weekend?

hathach commented 5 years ago

@ladyada no problem, I am debugging it. It is good chance to get more familiar with python. seem like the exclude is deprecated and we should use filter in python 3 for TarFile.add

    def add(self, name, arcname=None, recursive=True, exclude=None, *, filter=None):
        """Add the file `name' to the archive. `name' may be any type of file
           (directory, fifo, symbolic link, etc.). If given, `arcname'
           specifies an alternative name for the file in the archive.
           Directories are added recursively by default. This can be avoided by
           setting `recursive' to False. `exclude' is a function that should
           return True for each filename to be excluded. `filter' is a function
           that expects a TarInfo object argument and returns the changed
           TarInfo object, if it returns None the TarInfo object will be
           excluded from the archive.
        """
        self._check("awx")

        if arcname is None:
            arcname = name

        # Exclude pathnames.
        if exclude is not None:
            import warnings
            warnings.warn("use the filter argument instead",
                    DeprecationWarning, 2)
            if exclude(name):
                self._dbg(2, "tarfile: Excluded %r" % name)
                return