Git and packaging: common pattern to keep packaging-files out of the way?

For the last python project I developed, I used git as versioning system. Now it’s that time of the development cycle in which I should begin to ship out packages to the beta testers (in my case they would be .deb packages).

In order to build my packages I need a number of extra files (copyright, icon.xpm., setup.cfg, stdeb.cfg, etc…) but I would like to keep them separate from the source of the program, as the source might be used to prepare packages for other platforms, and it would make no sense having those debian-specific files lingering around.

  • Security in Gitlab. With gitolite?
  • How to install git 1.8 or above on Debian Wheezy
  • Versioning of debian packaging Information
  • convert current git repo to one compatible with git-buildpackage
  • eclipse : impossible to import git project
  • osm2pgrouting import not completed using postgresql-9.4-pgrouting in Debian
  • My question: is there a standard way/best practice to do so? In my google wanderings I stumbled a couple of times (including here on SO) on the git-buildpackage suite, but I am not sure this is what I am looking for, as it seems that is thought for packagers that download a tar.gz from an upstream repository.

    I thought a possible way to achive what I want would be to have a branch on the git repository where I keep my packaging-files, but this branch should also be able to “see” the files on the master branch without me having every time to manually merge the master into the packaging branch. However:

    • I don’t know if this is a good idea / the way it should be done
    • Although I suspect it might involve some git symbolic-ref magic, I have no idea how to do what I imagined

    Any help appreciated, thanks in advance for your time!

  • error: git checkout-index: unable to create file (Permission denied)
  • Git clone with preexisting public key
  • How to update GitHub forked repository using TortoiseGIT?
  • How to include matplotlib into a C++ project
  • Is it possible to setup git merge for automatic resolving? (git rerere)
  • errors while committing the repository in sourcetree, Git window client
  • 3 Solutions collect form web for “Git and packaging: common pattern to keep packaging-files out of the way?”

    why would you want to keep those out of the source control? They are part of the inputs to generate the final, built output! You definately don’t want to lose track of them, and you probably want to keep track of how they change over time, as you continue to develop your application.

    What you most likely want to do is create a subdirectory for all of these distribution specific files to live, say ./debian or ./packaging/debian and commit them there; You can have a makefile or some such that, when you run it in that directory, copies all of the files where they need to be to create the package, and you’ll be in great shape!

    At the end I settled for a branch with a makefile in it, so that my packaging procedure now looks something like:

    git checkout debian-packaging
    make get-source
    make deb
    make reset

    If you are interested you can find the full makefile here (disclaimer: that is my first makefile ever, so it’s quite possible it’s not the best makefile you will ever see).

    In a nutshell, the core of the “trick” is in the get-source directive, and it is the use of the git archive command, that accepts the name of a branch as an argument and produces a tarball with the source from that branch. Here’s the snippet:

    # Fetch the source code from desired branch
        git archive $(SOURCE_BRANCH) -o $(SOURCE_BRANCH).tar
        tar xf $(SOURCE_BRANCH).tar
        rm $(SOURCE_BRANCH).tar
        @echo "The source code has been fetched."

    Hope this helps somebody else too!

    You can have the extra files in a separate repo ( so that they are versioned too) and use submodules to use it in your source code repo.

    Git Baby is a git and github fan, let's start git clone.