[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: debian/rules and "git rev-list" in a subshell - Automatically retrieve upstream GIT repository using ISO date to package source tarball

Dne 6.11.2010 14:09, Danai SAE-HAN (韓達耐) napsal(a):
upstream_version := cjk-4.8.2+git20090105
unixdate := 1231196400

	git clone git://git.sv.gnu.org/cjk.git cjk-$(upstream_version)
	cd cjk-$(upstream_version)&&  git reset --hard $(shell cd
cjk-$(upstream_version)&&  git rev-list --all -n 1

In other words, I clone the GIT repository, and then want to revert it
to a somewhat older version, based on the UNIX timestamp.  I open a
subshell to get the hash of the latest GIT commit before the UNIX

You may find some inspiration in Tito where we do something similar. There is no need to do "reset --hard", you can pass commit/tag directly to git "archive"

def get_commit_timestamp(sha1_or_tag):
    Get the timestamp of the git commit or tag we're building. Used to
    keep the hash the same on all .tar.gz's we generate for a particular
    version regardless of when they are generated.
    output = run_command(
            "git rev-list --timestamp --max-count=1 %s | awk '{print $1}'"
            % sha1_or_tag)
    return output

def create_tgz(git_root, prefix, commit, relative_dir, rel_eng_dir,
    Create a .tar.gz from a projects source in git.
    timestamp = get_commit_timestamp(commit)

    timestamp_script = get_script_path("tar-fixup-stamp-comment.pl")

    # Accomodate standalone projects with specfile in root of git repo:
    relative_git_dir = "%s" % relative_dir
    if relative_git_dir == '/':
        relative_git_dir = ""

    archive_cmd = ('git archive --format=tar --prefix=%s/ %s:%s '
'| grep -a -v "^%s/rel-eng/" | %s %s %s | gzip -n -c - | tee %s' % (
        prefix, commit, relative_git_dir, prefix, timestamp_script,
        timestamp, commit, dest_tgz))

That tar-fixup-stamp-comment.pl can be find here:
You can study rest of Tito here:
Tito is made to produce rpm files, but that part from git to tar.gz will be the same for Debian.

Miroslav Suchy

Reply to: