]> granicus.if.org Git - handbrake/commitdiff
build: use git version info instead of svn
authorJohn Stebbins <jstebbins.hb@gmail.com>
Tue, 25 Aug 2015 16:48:14 +0000 (09:48 -0700)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Tue, 25 Aug 2015 21:17:11 +0000 (14:17 -0700)
Migrate from svn to git.  Since our build system automatically generates
version info from the svn repo, this needs to change when we move the
repo to git.

17 files changed:
doc/texi/Building.linux.texi
doc/texi/base/handbrake.texi.m4
doc/texi/building/appendix.repo.texi
doc/texi/building/chapter.via.terminal.texi
doc/texi/building/command.texi
doc/texi/building/prerequisites.common.texi
libhb/hb.c
libhb/hb.h
libhb/project.h.m4
make/configure.py
make/include/tool.defs
pkg/linux/module.defs
pkg/linux/module.rules
pkg/module.rules
scripts/repo-info.sh [new file with mode: 0755]
scripts/tag-release.sh [new file with mode: 0755]
test/test.c

index ddab914abb3235e2d8a5c1e1469edf0ac7c4238e..015f013e18cfcb74bc22d93ab42a7b3e686032b8 100644 (file)
@@ -33,7 +33,7 @@ The @b{GTK UI} introduces some significant extra build requirements. GTK version
 
 Ubuntu 14.04 packages:
 @itemize @bullet
-@item subversion (cli/gui)
+@item git (cli/gui)
 @item cmake (cli/gui)
 @item yasm (cli/gui)
 @item build-essential (cli/gui)
@@ -67,7 +67,7 @@ Ubuntu 14.04 packages:
 
 To install these packages:
 @example
-sudo apt-get install subversion cmake yasm build-essential autoconf libtool \
+sudo apt-get install git cmake yasm build-essential autoconf libtool \
 zlib1g-dev libbz2-dev libogg-dev libtheora-dev libvorbis-dev \
 libsamplerate-dev libxml2-dev libfribidi-dev libfreetype6-dev \
 libfontconfig1-dev libass-dev libmp3lame-dev libx264-dev libjansson-dev \
index 1367c4d585f404e7b7d3505abd3d0fa24bc649c9..099e7f78fbbad4d949703c6ffd865781b6265a21 100644 (file)
@@ -20,10 +20,10 @@ dnl
 @set HB-version-hex     __HB_version_hex
 @set HB-build           __HB_build
 @set HB-repo-url        __HB_repo_url
-@set HB-repo-root       __HB_repo_root
 @set HB-repo-branch     __HB_repo_branch
-@set HB-repo-uuid       __HB_repo_uuid
+@set HB-repo-tag        __HB_repo_tag
 @set HB-repo-rev        __HB_repo_rev
+@set HB-repo-hash       __HB_repo_hash
 @set HB-repo-date       __HB_repo_date
 @set HB-repo-official   __HB_repo_official
 @set HB-repo-type       __HB_repo_type
index ea7bf2d8a1b1676665a0105f0912c1b826ec5c77..59b501ed0ede2e21a1a42b152ce338951a3a3339 100644 (file)
@@ -1,10 +1,10 @@
 @appendix Project Repository Details
 @example
 url:    @value{HB-repo-url}
-root:   @value{HB-repo-root}
 branch: @value{HB-repo-branch}
-uuid:   @value{HB-repo-uuid}
+tag:    @value{HB-repo-tag}
 rev:    @value{HB-repo-rev}
+hash:   @value{HB-repo-hash}
 date:   @value{HB-repo-date}
 type:   @value{HB-repo-type}
 @end example
index b5c61eb386d88d552dd312e6b96c5270a3e5e541..b98301b6685e7f844edf4e02ab6568a697ded6dd 100644 (file)
@@ -62,7 +62,7 @@ Clean-room procedures dictate that when certain factors change, old builds shoul
 
 @itemize
 @item configure with different options
-@item subversion working dir is updated and you want configure to re-evaluate working dir metadata.
+@item git working dir is updated and you want configure to re-evaluate working dir metadata.
 @item build corruption is suspected
 @end itemize
 
index fedb58188a76f3127f118f8320d8143db7fab9ae..cd97764c0806965cd36d09a1c7be270c0fa00d75 100644 (file)
@@ -1,4 +1,4 @@
 @macro COMMAND-checkout{}
-svn checkout @value{HB-repo-url} @value{HB-acro-lower}-@value{HB-repo-branch}
+git clone @value{HB-repo-url} @value{HB-acro-lower}-@value{HB-repo-branch}
 cd @value{HB-acro-lower}-@value{HB-repo-branch}
 @end macro
index 64c21fd38bfdb435b228e69dbc1c0e920a27ad90..30b1621f18689fe29b2db72d9503a0a272fa435e 100644 (file)
@@ -1,7 +1,7 @@
 The following general tools are used on various platforms and it is recommended you use these versions or similar:
 
 @itemize @bullet
-@item subversion - 1.6.16
+@item git - 2.4.3
 @item python - Python 2.7.1
 @item curl - curl 7.21.4 (or wget)
 @item m4 - GNU M4 1.4.6
index e8418e7413bc455fa259ae78d0633775e8e09d8c..2f4a7172044003f587c66227448d3843f7c54dfa 100644 (file)
@@ -460,14 +460,68 @@ hb_handle_t * hb_init( int verbose, int update_check )
     return h;
 }
 
+// Make sure these strings at least exist in the executable even though
+// they may not all be visible in the frontend.
+static const char* hb_title          = HB_PROJECT_TITLE;
+static const char* hb_name           = HB_PROJECT_NAME;
+static const char* hb_website        = HB_PROJECT_URL_WEBSITE;
+static const char* hb_community      = HB_PROJECT_URL_COMMUNITY;
+static const char* hb_irc            = HB_PROJECT_URL_IRC;
+static const char* hb_version        = HB_PROJECT_VERSION;
+static const int   hb_build          = HB_PROJECT_BUILD;
+static const char* hb_repo_url       = HB_PROJECT_REPO_URL;
+static const char* hb_repo_tag       = HB_PROJECT_REPO_TAG;
+static const int   hb_repo_rev       = HB_PROJECT_REPO_REV;
+static const char* hb_repo_hash      = HB_PROJECT_REPO_HASH;
+static const char* hb_repo_branch    = HB_PROJECT_REPO_BRANCH;
+static const char* hb_repo_remote    = HB_PROJECT_REPO_REMOTE;
+static const char* hb_repo_type      = HB_PROJECT_REPO_TYPE;
+
+const char * hb_get_full_description()
+{
+    static char * desc = NULL;
+    if (desc == NULL)
+    {
+        desc = hb_strdup_printf("%s\n"
+                                "\tWebsite:     %s\n"
+                                "\tForum:       %s\n"
+                                "\tIRC:         %s\n"
+                                "\tBuild Type:  %s\n"
+                                "\tRepository:  %s\n"
+                                "\tRelease Tag: %s\n"
+                                "\tRevision:    %d\n"
+                                "\tCommit Hash: %s\n"
+                                "\tBranch:      %s\n"
+                                "\tRemote:      %s",
+                                hb_title, hb_website, hb_community, hb_irc,
+                                hb_repo_type, hb_repo_url, hb_repo_tag, hb_repo_rev,
+                                hb_repo_hash, hb_repo_branch, hb_repo_remote);
+    }
+    return desc;
+}
+
 /**
  * Returns current version of libhb.
  * @param h Handle to hb_handle_t.
  * @return character array of version number.
  */
-char * hb_get_version( hb_handle_t * h )
+const char * hb_get_version( hb_handle_t * h )
 {
-    return HB_PROJECT_VERSION;
+    // Silence compiler warnings for unused variables
+    ((void)(hb_title));
+    ((void)(hb_name));
+    ((void)(hb_website));
+    ((void)(hb_community));
+    ((void)(hb_irc));
+    ((void)(hb_version));
+    ((void)(hb_repo_url));
+    ((void)(hb_repo_tag));
+    ((void)(hb_repo_rev));
+    ((void)(hb_repo_hash));
+    ((void)(hb_repo_branch));
+    ((void)(hb_repo_remote));
+    ((void)(hb_repo_type));
+    return hb_version;
 }
 
 /**
@@ -477,7 +531,7 @@ char * hb_get_version( hb_handle_t * h )
  */
 int hb_get_build( hb_handle_t * h )
 {
-    return HB_PROJECT_BUILD;
+    return hb_build;
 }
 
 /**
index cbf25f712121205dc710041a1eff202cc175d1e3..c8101ed68fbf612044ccb7e352270f00302a2a3a 100644 (file)
@@ -39,7 +39,8 @@ int           hb_hwd_enabled( hb_handle_t *h );
 hb_hwd_t    * hb_hwd_get_context();
 
 /* hb_get_version() */
-char        * hb_get_version( hb_handle_t * );
+const char  * hb_get_full_description();
+const char  * hb_get_version( hb_handle_t * );
 int           hb_get_build( hb_handle_t * );
 
 /* hb_check_update()
index 7e70b5b360032dadcfb31d5380e5f467ddc8c48b..ae54f255c027ad7870b35b317c6db2a6c3401673 100644 (file)
@@ -21,12 +21,14 @@ dnl
 <<#>>define HB_PROJECT_VERSION_HEX     0x<<>>__HB_version_hex<<>>LL
 <<#>>define HB_PROJECT_BUILD           __HB_build
 <<#>>define HB_PROJECT_REPO_URL        "__HB_repo_url"
-<<#>>define HB_PROJECT_REPO_ROOT       "__HB_repo_root"
-<<#>>define HB_PROJECT_REPO_UUID       "__HB_repo_uuid"
+<<#>>define HB_PROJECT_REPO_TAG        "__HB_repo_tag"
 <<#>>define HB_PROJECT_REPO_REV        __HB_repo_rev
-<<#>>define HB_PROJECT_REPO_DATE       "__HB_repo_date"
-<<#>>define HB_PROJECT_REPO_OFFICIAL   __HB_repo_official
+<<#>>define HB_PROJECT_REPO_HASH       "__HB_repo_hash"
+<<#>>define HB_PROJECT_REPO_BRANCH     "__HB_repo_branch"
+<<#>>define HB_PROJECT_REPO_REMOTE     "__HB_repo_remote"
 <<#>>define HB_PROJECT_REPO_TYPE       "__HB_repo_type"
+<<#>>define HB_PROJECT_REPO_OFFICIAL   __HB_repo_official
+<<#>>define HB_PROJECT_REPO_DATE       "__HB_repo_date"
 
 <<#>>define HB_PROJECT_BUILD_SPEC      "__BUILD_spec"
 <<#>>define HB_PROJECT_BUILD_MACHINE   "__BUILD_machine"
index 5f35ed4a663aa26c60e447c4386e8d60257de3db..7976a03c56cb03fd8fe4525d2039a236a70fa0a6 100644 (file)
@@ -159,12 +159,12 @@ class Configure( object ):
             if os.access( name, os.X_OK ):
                 return name
             return None
-        
+
         if not os.environ.has_key( 'PATH' ) or os.environ[ 'PATH' ] == '':
             path = os.defpath
         else:
             path = os.environ['PATH']
-        
+
         for dir in path.split( os.pathsep ):
             f = os.path.join( dir, name )
             if os.access( f, os.X_OK ):
@@ -317,7 +317,7 @@ class ShellProbe( Action ):
 ##
 ## returns true if feature successfully compiles
 ##
-##   
+##
 class CCProbe( Action ):
     def __init__( self, pretext, command, test_file ):
         super( CCProbe, self ).__init__( 'probe', pretext )
@@ -358,7 +358,7 @@ class CCProbe( Action ):
 ##
 ## returns true if feature successfully compiles
 ##
-##   
+##
 class LDProbe( Action ):
     def __init__( self, pretext, command, lib, test_file ):
         super( LDProbe, self ).__init__( 'probe', pretext )
@@ -444,7 +444,7 @@ class HostTupleProbe( ShellProbe, list ):
 
         if self.match( '*-*-cygwin*' ):
             self.systemf = self[2][0].upper() + self[2][1:]
-            
+
     ## glob-match against spec
     def match( self, *specs ):
         for spec in specs:
@@ -519,7 +519,7 @@ class IfHost( object ):
 
     def __nonzero__( self ):
         return self.value != None
-        
+
     def __str__( self ):
         return self.value
 
@@ -551,7 +551,7 @@ class ArchAction( Action ):
     def _action( self ):
         self.fail = False
 
-        ## some match on system should be made here; otherwise we signal a warning. 
+        ## some match on system should be made here; otherwise we signal a warning.
         if host.match( '*-*-cygwin*' ):
             pass
         elif host.match( '*-*-darwin11.*' ):
@@ -673,74 +673,67 @@ class SelectMode( dict ):
 ## Builds are classed into one of the following types:
 ##
 ##  release
-##      must be built from official svn with '/tags/' in the url
+##      must be built from official git at version tag
 ##  developer
-##      must be built from official svn but is not a release
-##  unofficial
-##      all other builds
+##      must be built from official git but is not a release
 ##
 class RepoProbe( ShellProbe ):
     def __init__( self ):
-        svn = 'svn'
-
-        ## Possible the repo was created using an incompatible version than what is
-        ## available in PATH when probe runs. Workaround by checking for file
-        ## .svn/HANDBRAKE_REPO_PROBE which points to a preferred svn executable.
+        # Find script that creates repo info
         try:
-            hrp = os.path.join( cfg.src_dir, '.svn', 'HANDBRAKE_REPO_PROBE' )
-            if os.path.isfile( hrp ) and os.path.getsize( hrp ) > 0:
-                file = cfg.open( hrp, 'r' )
-                line = file.readline().strip()
-                file.close()
-                if line:
-                    svn = line
+            repo_info = os.path.join( cfg.src_dir, 'scripts', 'repo-info.sh' )
+            if not os.path.isfile( repo_info ):
+                cfg.errln( 'Missing required script %s\n', repo_info )
+                sys.exit( 1 )
         except:
-            pass
+            sys.exit( 1 )
 
-        super( RepoProbe, self ).__init__( 'svn info', '%s info %s' % (svn,cfg.src_dir) )
+        super( RepoProbe, self ).__init__( 'repo info', '%s %s' %
+                                            (repo_info, cfg.src_dir) )
 
-        self.url       = 'svn://nowhere.com/project/unknown'
-        self.root      = 'svn://nowhere.com/project'
+        self.url       = 'git://nowhere.com/project/unknown'
+        self.tag       = ''
         self.branch    = 'unknown'
-        self.uuid      = '00000000-0000-0000-0000-000000000000';
+        self.remote    = 'unknown'
         self.rev       = 0
+        self.hash      = 'deadbeaf'
+        self.shorthash = 'deadbea'
         self.date      = '0000-00-00 00:00:00 -0000'
         self.official  = 0
-        self.type      = 'unofficial'
+        self.type      = 'developer'
 
     def _parseSession( self ):
         for line in self.session:
             ## grok fields
-            m = re.match( '([^:]+):\\s+(.+)', line )
+            m = re.match( '([^\=]+)\=(.*)', line )
             if not m:
                 continue
 
             (name,value) = m.groups()
-            if name == 'URL':
+            if name == 'URL' and value != '':
                 self.url = value
-            elif name == 'Repository Root':
-                self.root = value
-            elif name == 'Repository UUID':
-                self.uuid = value
-            elif name == 'Revision':
+            elif name == 'TAG':
+                self.tag = value
+            elif name == 'BRANCH':
+                self.branch = value
+            elif name == 'REMOTE':
+                self.remote = value
+            elif name == 'REV':
                 self.rev = int( value )
-            elif name == 'Last Changed Date':
-                # strip chars in parens
-                if value.find( ' (' ):
-                    self.date = value[0:value.find(' (')]
-                else:
-                    self.date = value
-
-        ## grok branch
-        i = self.url.rfind( '/' )
-        if i != -1 and i < len(self.url)-1:
-            self.branch = self.url[i+1:]
-
-        # type-classification via repository UUID
-        if self.uuid == 'b64f7644-9d1e-0410-96f1-a4d463321fa5':
+            elif name == 'DATE':
+                self.date = value
+            elif name == 'HASH':
+                self.hash = value
+                self.shorthash = value[:7]
+
+        # type-classification via repository URL
+        official_url = 'https://github.com/HandBrake/HandBrake.git' # HTTPS
+        if self.url == 'git@github.com:HandBrake/HandBrake.git':    # SSH
+            self.url = official_url
+
+        if self.url == official_url:
             self.official = 1
-            m = re.match( '([^:]+)://([^/]+)/(.+)', self.url )
-            if m and re.match( '.*tags/.*', m.group( 3 )):
+            if self.branch == '' and self.rev == 0:
                 self.type = 'release'
             else:
                 self.type = 'developer'
@@ -748,12 +741,12 @@ class RepoProbe( ShellProbe ):
         self.msg_end = self.url
 
     def _failSession( self ):
-        # Look for svn info in version file.
+        # Look for repo info in version file.
         #
         # Version file would be created manually by source packager.
         # e.g.
-        # $ svn info HandBrake > HandBrake/version.txt
-        # $ tar -czf handbrake-source.tgz --exclude .svn HandBrake
+        # $ HandBrake/scripts/repo-info.sh HandBrake > HandBrake/version.txt
+        # $ tar -czf handbrake-source.tgz --exclude .git HandBrake
         cfg.infof( 'probe: version.txt...' )
         try:
             hvp = os.path.join( cfg.src_dir, 'version.txt' )
@@ -793,7 +786,7 @@ class Project( Action ):
         self.name_upper = self.name.upper()
 
         self.vmajor = 0
-        self.vminor = 10
+        self.vminor = 0
         self.vpoint = 0
 
     def _action( self ):
@@ -803,24 +796,33 @@ class Project( Action ):
         else:
             url_arch = ''
 
+        if repo.tag != '':
+            m = re.match( '([0-9]+)\.([0-9]+)\.([0-9]+)', repo.tag )
+            if not m:
+                cfg.errln( 'Invalid repo tag format %s\n', repo.tag )
+                sys.exit( 1 )
+            (vmajor, vminor, vpoint) = m.groups()
+            self.vmajor = int(vmajor)
+            self.vminor = int(vminor)
+            self.vpoint = int(vpoint)
+
         if repo.type == 'release':
             self.version = '%d.%d.%d' % (self.vmajor,self.vminor,self.vpoint)
             url_ctype = ''
             url_ntype = 'stable'
             self.build = time.strftime('%Y%m%d') + '00'
             self.title = '%s %s (%s)' % (self.name,self.version,self.build)
-        elif repo.type == 'developer':
-            self.version = '%dsvn' % (repo.rev)
+        else:
+            if repo.branch != '':
+                self.version = '%d.%d.%d-%d-%s-%s' % (self.vmajor, self.vminor,
+                    self.vpoint, repo.rev, repo.shorthash, repo.branch)
+            else:
+                self.version = '%d.%d.%d-%d-%s' % (self.vmajor, self.vminor,
+                    self.vpoint, repo.rev, repo.shorthash)
             url_ctype = '_unstable'
             url_ntype = 'unstable'
             self.build = time.strftime('%Y%m%d') + '01'
-            self.title = '%s svn%d (%s)' % (self.name,repo.rev,self.build)
-        else:
-            self.version = 'rev%d' % (repo.rev)
-            url_ctype = '_unofficial'
-            url_ntype = 'unofficial'
-            self.build = time.strftime('%Y%m%d') + '99'
-            self.title = '%s rev%d (%s)' % (self.name,repo.rev,self.build)
+            self.title = '%s %s (%s)' % (self.name,self.version,self.build)
 
         self.url_appcast = 'https://handbrake.fr/appcast%s%s.xml' % (url_ctype,url_arch)
         self.url_appnote = 'https://handbrake.fr/appcast/%s.html' % (url_ntype)
@@ -1206,7 +1208,7 @@ def createCLI():
 
     h = IfHost( 'enable HWD features', '*-*-*', none=optparse.SUPPRESS_HELP ).value
     grp.add_option( '--enable-hwd', default=False, action='store_true', help=h )
-    
+
     h = IfHost( 'enable use of x265 encoding', '*-*-*', none=optparse.SUPPRESS_HELP ).value
     grp.add_option( '--enable-x265', default=True, action='store_true', help=h )
     grp.add_option( '--disable-x265', dest="enable_x265", action='store_false' )
@@ -1667,13 +1669,15 @@ int main ()
     doc.add( 'HB.build', project.build )
 
     doc.add( 'HB.repo.url',       repo.url )
-    doc.add( 'HB.repo.root',      repo.root )
-    doc.add( 'HB.repo.branch',    repo.branch )
-    doc.add( 'HB.repo.uuid',      repo.uuid )
+    doc.add( 'HB.repo.tag',       repo.tag )
     doc.add( 'HB.repo.rev',       repo.rev )
-    doc.add( 'HB.repo.date',      repo.date )
-    doc.add( 'HB.repo.official',  repo.official )
+    doc.add( 'HB.repo.hash',      repo.hash )
+    doc.add( 'HB.repo.shorthash', repo.shorthash )
+    doc.add( 'HB.repo.branch',    repo.branch )
+    doc.add( 'HB.repo.remote',    repo.remote )
     doc.add( 'HB.repo.type',      repo.type )
+    doc.add( 'HB.repo.official',  repo.official )
+    doc.add( 'HB.repo.date',      repo.date )
 
     doc.addBlank()
     doc.add( 'HOST.spec',    host.spec )
@@ -1714,7 +1718,7 @@ int main ()
     doc.add( 'BUILD/',  cfg.build_final + os.sep )
     doc.add( 'PREFIX',  cfg.prefix_final )
     doc.add( 'PREFIX/', cfg.prefix_final + os.sep )
-    
+
     doc.addBlank()
     doc.add( 'FEATURE.local_yasm', int( options.enable_local_yasm ))
     doc.add( 'FEATURE.local_autotools', int( options.enable_local_autotools ))
@@ -1867,7 +1871,7 @@ except AbortError, x:
     try:
         cfg.record_log()
     except:
-        pass        
-    sys.exit( 1 )    
+        pass
+    sys.exit( 1 )
 
 sys.exit( 0 )
index 29f45e9a7b70e558306f3ec6461b4a082e83ebd9..3efe5d83f6b72f705697821df1d5c060f9d2f785 100644 (file)
@@ -11,3 +11,4 @@ WGET.exe  = wget
 MV.exe    = mv
 ZIP.exe   = zip
 LN.exe    = ln
+GIT.exe   = git
index 2570d0857ceab4d26e712e5b139c7d2dc9f34907..3b1a81f8ed253f92906a0eca39ccbbef21b9fbcc 100644 (file)
@@ -1,8 +1,19 @@
 PKG.deb.machine = `dpkg --print-architecture`
 PKG.rpm.machine = `rpm -E "%_target_cpu"`
-PKG.release = 1
+PKG.release = $(HB.repo.rev)
 PKG.rpm.dist = `rpm -E "%dist"`
 
+ifeq ($(HB.repo.tag),)
+    tag = 0.0.0
+endif
+ifeq ($(HB.repo.type),release)
+    PKG.rpm.hb.version = $(tag)
+else ifeq ($(HB.repo.branch),)
+    PKG.rpm.hb.version = $(tab).$(HB.repo.shorthash)
+else
+    PKG.rpm.hb.version = $(tag).$(HB.repo.shorthash).$(HB.repo.branch)
+endif
+
 
 ###############################################################################
 
@@ -12,27 +23,29 @@ STAGE.out.cli/ = $(STAGE.out/)cli/
 
 ###############################################################################
 
-PKG.rpm.src.tar.bz2 = $(STAGE.out.src/)rpm/$(PKG.basename).tar.bz2
+PKG.rpm.basename = $(HB.name.lower)-$(PKG.rpm.hb.version)
+PKG.rpm.src.tar.bz2 = $(STAGE.out.src/)rpm/$(PKG.rpm.basename).tar.bz2
 STAGE.out.rpm.src/ = $(STAGE.out.src/)rpm/
 
 PKG.debian  = $(PKG.in/)linux/debian
 PKG.cli.deb = $(PKG.out/)$(HB.name)-$(HB.version)-Ubuntu_CLI_$(BUILD.machine).deb
 PKG.gui.deb = $(PKG.out/)$(HB.name)-$(HB.version)-Ubuntu_GUI_$(BUILD.machine).deb
-PKG.deb.basename = handbrake-$(HB.version)
-PKG.src.deb.tar = handbrake_$(HB.version).tar.gz
+PKG.deb.basename = $(HB.name.lower)-$(HB.version)
+PKG.src.deb.tar = $(HB.name.lower)_$(HB.version).tar.gz
 PKG.src.deb.stamp = $(STAGE.out.src/).debsrc.stamp
-PKG.src.deb = $(PKG.out/)handbrake_$(HB.version).deb
+PKG.src.deb = $(PKG.out/)$(HB.name.lower)_$(HB.version).deb
 
-PKG.cli.tmp.deb = $(PKG.out/)handbrake-cli_$(HB.version)_$(PKG.deb.machine).deb
-PKG.gui.tmp.deb = $(PKG.out/)handbrake-gtk_$(HB.version)_$(PKG.deb.machine).deb
+PKG.cli.tmp.deb = $(PKG.out/)$(HB.name.lower)-cli_$(HB.version)_$(PKG.deb.machine).deb
+PKG.gui.tmp.deb = $(PKG.out/)$(HB.name.lower)-gtk_$(HB.version)_$(PKG.deb.machine).deb
 
 PKG.native.rpm.stamp = $(RPM.out/).rpm.stamp
+PKG.rpm.stamp = $(PKG.out/).rpm.stamp
 
-PKG.gui.native.rpm = $(RPM.out/)RPMS/$(PKG.rpm.machine)/$(HB.name)-gui-$(HB.version)-$(PKG.release)$(PKG.rpm.dist).$(PKG.rpm.machine).rpm
-PKG.cli.native.rpm = $(RPM.out/)RPMS/$(PKG.rpm.machine)/$(HB.name)-cli-$(HB.version)-$(PKG.release)$(PKG.rpm.dist).$(PKG.rpm.machine).rpm
+PKG.gui.native.rpm = $(RPM.out/)RPMS/$(PKG.rpm.machine)/$(HB.name.lower)-gui-$(PKG.rpm.hb.version)-$(PKG.release)$(PKG.rpm.dist).$(PKG.rpm.machine).rpm
+PKG.cli.native.rpm = $(RPM.out/)RPMS/$(PKG.rpm.machine)/$(HB.name.lower)-cli-$(PKG.rpm.hb.version)-$(PKG.release)$(PKG.rpm.dist).$(PKG.rpm.machine).rpm
 
-PKG.cli.rpm  = $(PKG.out/)$(HB.name)-$(HB.version)-Fedora_CLI_$(BUILD.machine).rpm
-PKG.gui.rpm  = $(PKG.out/)$(HB.name)-$(HB.version)-Fedora_GUI_$(BUILD.machine).rpm
+PKG.cli.rpm  = $(PKG.out/)$(HB.name.lower)-cli-$(PKG.rpm.hb.version)-$(PKG.release)$(PKG.rpm.dist).$(PKG.rpm.machine).rpm
+PKG.gui.rpm  = $(PKG.out/)$(HB.name.lower)-gui-$(PKG.rpm.hb.version)-$(PKG.release)$(PKG.rpm.dist).$(PKG.rpm.machine).rpm
 RPM.out  = $(STAGE.out/)rpm
 RPM.out/ = $(STAGE.out/)rpm/
 RPMROOT.out  = $(PWD)/$(STAGE.out/)rpmroot
index b7b66a38a82d745ebc0297a936ed680bf03aa85a..c0c2fba343f00020b26eb72dd11c7ece3915816f 100644 (file)
@@ -1,5 +1,5 @@
 pkg.create.deb:: $(PKG.gui.deb) $(PKG.cli.deb)
-pkg.create.rpm:: $(PKG.gui.rpm)
+pkg.create.rpm:: $(PKG.rpm.stamp)
 pkg.create.src.deb:: $(PKG.src.deb.stamp)
 pkg.create.tar:: pkg.create $(PKG.cli.tar)
 
@@ -21,17 +21,18 @@ $(STAGE.out.cli/):
 # RPM binary package rules
 #
 $(PKG.rpm.src.tar.bz2): $(STAGE.out.rpm.src/)
-       $(TAR.exe) cjf $@ -C $(STAGE.out.rpm.src/) $(PKG.basename)
+       $(TAR.exe) cjf $(PKG.rpm.src.tar.bz2) -C $(STAGE.out.rpm.src/) $(PKG.rpm.basename)
 
 $(STAGE.out.rpm.src/): GNUmakefile
 #      -$(MKDIR.exe) -p $(STAGE.out.rpm.src/)$(PKG.basename)
 #      tar c --exclude build ../* | tar x -C $(STAGE.out.rpm.src/)$(PKG.basename)
        -$(RM.exe) -rf $(STAGE.out.src/)
        make contrib.fetch
-       svn export -r$(HB.repo.rev) $(HB.repo.url) $@/$(PKG.basename)
-       svn info $(HB.repo.url)@$(HB.repo.rev) > $@/$(PKG.basename)/version.txt
-       -$(MKDIR.exe) $(STAGE.out.rpm.src/)$(PKG.basename)/download
-       $(CP.exe) $(SRC/)download/*.tar.* $(STAGE.out.rpm.src/)$(PKG.basename)/download
+       $(MKDIR.exe) -p $@
+       $(GIT.exe) -C $(SRC/) archive --format=tar --prefix=$(PKG.rpm.basename)/ $(HB.repo.shorthash) | $(TAR.exe) -xC $@
+       $(SRC/)scripts/repo-info.sh $(SRC/) > $@/$(PKG.rpm.basename)/version.txt
+       -$(MKDIR.exe) $(STAGE.out.rpm.src/)$(PKG.rpm.basename)/download
+       $(CP.exe) $(SRC/)download/*.tar.* $(STAGE.out.rpm.src/)$(PKG.rpm.basename)/download
 
 $(PKG.native.rpm.stamp): $(PKG.rpm.src.tar.bz2)
        -$(MKDIR.exe) -p $(RPM.out/)SOURCES
@@ -40,18 +41,19 @@ $(PKG.native.rpm.stamp): $(PKG.rpm.src.tar.bz2)
        -$(MKDIR.exe) -p $(RPM.out/)RPMS
        -$(MKDIR.exe) -p $(RPM.out/)SRPMS
        -$(MKDIR.exe) -p $(RPMROOT.out/)
-       echo "%define name $(HB.name)" > $(RPM.out/)SPECS/ghb.spec
-       echo "%define release 1" >> $(RPM.out/)SPECS/ghb.spec
-       echo "%define version $(HB.version)" >> $(RPM.out/)SPECS/ghb.spec
+       echo "%define name $(HB.name.lower)" > $(RPM.out/)SPECS/ghb.spec
+       echo "%define release $(PKG.release)" >> $(RPM.out/)SPECS/ghb.spec
+       echo "%define version $(PKG.rpm.hb.version)" >> $(RPM.out/)SPECS/ghb.spec
        cat $(GTK.src/)ghb.spec >> $(RPM.out/)SPECS/ghb.spec
        $(CP.exe) $(PKG.rpm.src.tar.bz2) $(RPM.out/)SOURCES
        rpmbuild --define="_topdir $(PWD)/$(RPM.out)" --buildroot $(RPMROOT.out) -ba $(RPM.out/)SPECS/ghb.spec
        $(TOUCH.exe) $(PKG.native.rpm.stamp)
 
-$(PKG.gui.rpm): | $(dir $(PKG.gui.rpm))
-$(PKG.gui.rpm): $(PKG.native.rpm.stamp)
+$(PKG.rpm.stamp): | $(dir $(PKG.gui.rpm))
+$(PKG.rpm.stamp): $(PKG.native.rpm.stamp)
        $(CP.exe) $(PKG.gui.native.rpm) $(PKG.gui.rpm)
        $(CP.exe) $(PKG.cli.native.rpm) $(PKG.cli.rpm)
+       $(TOUCH.exe) $(PKG.rpm.stamp)
 
 #
 # Debian binary package rules
@@ -77,32 +79,34 @@ $(PKG.cli.deb): $(PKG.gui.tmp.deb)
 # Debian source package rules
 #
 pkg.push.src.deb:: $(PKG.src.deb.stamp)
-       (cd $(STAGE.out.src/)vivid && dput handbrake-snapshots handbrake_$(HB.version)ppa1~vivid1_source.changes )
-       (cd $(STAGE.out.src/)trusty && dput handbrake-snapshots handbrake_$(HB.version)ppa1~trusty1_source.changes )
+       (cd $(STAGE.out.src/)vivid && dput handbrake-snapshots $(HB.name.lower)_$(HB.version)ppa1~vivid1_source.changes )
+       (cd $(STAGE.out.src/)trusty && dput handbrake-snapshots $(HB.name.lower)_$(HB.version)ppa1~trusty1_source.changes )
 
 $(PKG.src.deb.stamp): GNUmakefile
        -$(RM.exe) -rf $(STAGE.out.src/)
        make contrib.fetch
-       svn export -r$(HB.repo.rev) $(HB.repo.url) $(STAGE.out.src/)vivid/$(PKG.deb.basename)
-       svn info $(HB.repo.url)@$(HB.repo.rev) >   $(STAGE.out.src/)vivid/$(PKG.deb.basename)/version.txt
+       $(MKDIR.exe) -p $(STAGE.out.src/)vivid
+       $(GIT.exe) -C $(SRC/) archive --format=tar --prefix=$(PKG.deb.basename)/ $(HB.repo.shorthash) | $(TAR.exe) -xC $(STAGE.out.src/)vivid/
+       $(SRC/)scripts/repo-info.sh $(SRC/) > $(STAGE.out.src/)vivid/$(PKG.deb.basename)/version.txt
        $(CP.exe) -a $(SRC/)download $(STAGE.out.src/)vivid/$(PKG.deb.basename)
        cp -a $(PWD)/$(PKG.debian) $(STAGE.out.src/)vivid/$(PKG.deb.basename)
        $(CP.exe) $(STAGE.out.src/)vivid/$(PKG.deb.basename)/debian/control.vivid $(STAGE.out.src/)vivid/$(PKG.deb.basename)/debian/control
        $(CP.exe) $(STAGE.out.src/)vivid/$(PKG.deb.basename)/debian/rules.vivid $(STAGE.out.src/)vivid/$(PKG.deb.basename)/debian/rules
-       echo "handbrake ($(HB.version)ppa1~vivid1) vivid; urgency=low" > $(STAGE.out.src/)vivid/$(PKG.deb.basename)/debian/changelog
+       echo "$(HB.name.lower) ($(HB.version)ppa1~vivid1) vivid; urgency=low" > $(STAGE.out.src/)vivid/$(PKG.deb.basename)/debian/changelog
        echo "  * Snapshot" >> $(STAGE.out.src/)vivid/$(PKG.deb.basename)/debian/changelog
        echo "    - See timeline at http://trac.handbrake.fr/timeline" >> $(STAGE.out.src/)vivid/$(PKG.deb.basename)/debian/changelog
        echo "" >> $(STAGE.out.src/)vivid/$(PKG.deb.basename)/debian/changelog
        echo " -- John Stebbins <jstebbins.hb@gmail.com>  Sun, 11 Apr 2010 9:51:07 -0800" >> $(STAGE.out.src/)vivid/$(PKG.deb.basename)/debian/changelog
        $(TAR.exe) czf $(STAGE.out.src/)vivid/$(PKG.src.deb.tar) -C $(STAGE.out.src/)vivid $(PKG.deb.basename)
        (cd $(STAGE.out.src/)vivid/$(PKG.deb.basename) && debuild -S -kjstebbins.hb)
-       svn export -r$(HB.repo.rev) $(HB.repo.url) $(STAGE.out.src/)trusty/$(PKG.deb.basename)
-       svn info $(HB.repo.url)@$(HB.repo.rev) >   $(STAGE.out.src/)trusty/$(PKG.deb.basename)/version.txt
+       $(MKDIR.exe) -p $(STAGE.out.src/)trusty
+       $(GIT.exe) -C $(SRC/) archive --format=tar --prefix=$(PKG.deb.basename)/ $(HB.repo.shorthash) | $(TAR.exe) -xC $(STAGE.out.src/)trusty/
+       $(SRC/)scripts/repo-info.sh $(SRC/) > $(STAGE.out.src/)trusty/$(PKG.deb.basename)/version.txt
        $(CP.exe) -a $(SRC/)download $(STAGE.out.src/)trusty/$(PKG.deb.basename)
        cp -a $(PWD)/$(PKG.debian) $(STAGE.out.src/)trusty/$(PKG.deb.basename)
        $(CP.exe) $(STAGE.out.src/)trusty/$(PKG.deb.basename)/debian/control.trusty $(STAGE.out.src/)trusty/$(PKG.deb.basename)/debian/control
        $(CP.exe) $(STAGE.out.src/)trusty/$(PKG.deb.basename)/debian/rules.trusty $(STAGE.out.src/)trusty/$(PKG.deb.basename)/debian/rules
-       echo "handbrake ($(HB.version)ppa1~trusty1) trusty; urgency=low" > $(STAGE.out.src/)trusty/$(PKG.deb.basename)/debian/changelog
+       echo "$(HB.name.lower) ($(HB.version)ppa1~trusty1) trusty; urgency=low" > $(STAGE.out.src/)trusty/$(PKG.deb.basename)/debian/changelog
        echo "  * Snapshot" >> $(STAGE.out.src/)trusty/$(PKG.deb.basename)/debian/changelog
        echo "    - See timeline at http://trac.handbrake.fr/timeline" >> $(STAGE.out.src/)trusty/$(PKG.deb.basename)/debian/changelog
        echo "" >> $(STAGE.out.src/)trusty/$(PKG.deb.basename)/debian/changelog
index 9c0457e3b4d504e4bb231f673b206f292b7851a4..5ec109fd3f152e0b9cd93cffbc9e32e631ab237f 100644 (file)
@@ -17,8 +17,9 @@ $(PKG.src.tar.bz2): | $(STAGE.out.src/)
        $(TAR.exe) cjf $@ -C $(STAGE.out.src/) $(PKG.basename)
 
 $(STAGE.out.src/):
-       svn export -r$(HB.repo.rev) $(HB.repo.url) $@/$(PKG.basename)
-       svn info $(HB.repo.url)@$(HB.repo.rev) > $@/$(PKG.basename)/version.txt
+       $(MKDIR.exe) -p $@
+       $(GIT.exe) -C $(SRC/) archive --format=tar --prefix=$(PKG.basename)/ $(HB.repo.shorthash) | $(TAR.exe) -xC $@
+       $(SRC/)scripts/repo-info.sh $(SRC/) $(GIT.exe) > $@/$(PKG.basename)/version.txt
 
 $(PKG.src-contrib.tar.bz2):
        $(TAR.exe) cjf $@ -C $(CONTRIB.download/) \
diff --git a/scripts/repo-info.sh b/scripts/repo-info.sh
new file mode 100755 (executable)
index 0000000..72d974d
--- /dev/null
@@ -0,0 +1,67 @@
+#! /bin/bash
+#
+# Retrieves git repository info for directory ${1} using command ${2}
+
+# Args
+REPO_DIR='.'
+if [[ ${1} ]]; then
+    REPO_DIR=${1}
+fi
+GIT_EXE='git'
+if [[ ${2} ]]; then
+    GIT_EXE=${2}
+fi
+
+# Switch to working directory
+if ! cd ${REPO_DIR} 2>/dev/null; then
+    echo "Invalid directory ${REPO_DIR}." 1>&2
+    exit 1
+fi
+
+# Check whether we have git
+if ! hash ${GIT_EXE} 2>/dev/null; then
+    echo "Command '${GIT_EXE}' not found." 1>&2
+    exit 1
+fi
+
+# Check if there is a valid git repo here
+HASH=$(${GIT_EXE} rev-parse HEAD)
+ERR=$?
+if [[ ${ERR} -ne 0 ]]; then
+    echo "Not a valid repository." 1>&2
+    exit ${ERR}
+elif [[ -z ${HASH} ]]; then
+    echo "Not a valid repository." 1>&2
+    exit 1
+fi
+
+# Retrieve info
+URL=$(${GIT_EXE} config remote.origin.url)
+TAG=$(${GIT_EXE} describe --abbrev=0)
+if [[ ${TAG} ]]; then
+    REV=$(${GIT_EXE} rev-list ${TAG}.. --count)
+else
+    TAG=$(${GIT_EXE} describe $(${GIT_EXE} rev-list --tags --max-count=1))
+    if [[ ${TAG} ]]; then
+        REV=$(${GIT_EXE} rev-list $(${GIT_EXE} merge-base 0.10.2 HEAD).. --count)
+    else
+        REV=$(${GIT_EXE} rev-list HEAD --count)
+    fi
+fi
+BRANCH=$(${GIT_EXE} symbolic-ref -q --short HEAD)
+REMOTE="${URL}"
+UPSTREAM=$(${GIT_EXE} config branch.${BRANCH}.remote)
+if [[ ${UPSTREAM} ]]; then
+    REMOTE="${UPSTREAM}"
+fi
+DATE=$(${GIT_EXE} log -1 --format="format:%ai")
+
+# Output
+# Only write tag and rev if they exist. A fresh clone currently has no tags.
+echo "URL=${URL}"
+echo "HASH=${HASH}"
+if [[ ${TAG} ]]; then echo "TAG=${TAG}"; fi
+if [[ ${REV} ]]; then echo "REV=${REV}"; fi
+echo "BRANCH=${BRANCH}"
+echo "REMOTE=${REMOTE}"
+echo "DATE=${DATE}"
diff --git a/scripts/tag-release.sh b/scripts/tag-release.sh
new file mode 100755 (executable)
index 0000000..64f9810
--- /dev/null
@@ -0,0 +1,86 @@
+#! /bin/bash
+#
+# Usage: tag-release.sh <release-ver> [<commit>]
+#
+# Creates a new branch and tag for the release
+# Optionally, the release can be based off a specific git commit.
+#
+
+TAG=${1}
+COMMIT=${2}
+
+if [ "x${TAG}" == "x" ]; then
+    echo "Missing release tag (e.g. 0.10.0)"
+fi
+
+if [ "x${COMMIT}" == "x" ]; then
+    echo "Creating release tag ${TAG} and branch ${TAG}-dev from HEAD, proceed?"
+else
+    echo "Creating release tag ${TAG} and branch ${TAG}-dev from ${COMMIT}, proceed?"
+fi
+read proceed
+if [[ ( "x${proceed}" != "xy" ) && ( "x${proceed}" != "xY" ) ]] ; then
+    echo "Aborting..."
+    exit 0
+fi
+
+if [ "x${COMMIT}" != "x" ]; then
+    # create release branch from specific commit
+    git checkout "${COMMIT}" -b "${TAG}-dev"
+    ERR=$?
+else
+    # create release branch from head of current branch
+    git checkout -b "${TAG}-dev"
+    ERR=$?
+fi
+if [ ${ERR} -ne 0 ]; then
+    echo "Failed to create branch ${TAG}-dev"
+    exit ${ERR}
+fi
+
+# creat tag
+git tag -a "${TAG}" -m "Release ${TAG}" HEAD
+ERR=$?
+if [ ${ERR} -ne 0 ]; then
+    echo "Failed to create tag ${TAG}"
+    # cleanup... remove the branch that was created
+    git branch -d "${TAG}-dev"
+    exit ${ERR}
+fi
+
+# checkout tag in preparation for building release
+# this should put you in a "detached HEAD" state
+git checkout "${TAG}"
+ERR=$?
+if [ ${ERR} -ne 0 ]; then
+    echo "Failed to checkout tag ${TAG}"
+    # cleanup... remove the branch that was created
+    git branch -d "${TAG}-dev"
+    exit ${ERR}
+fi
+
+remote=$(git config remote.origin.url)
+echo
+echo "Do you wish to push this release branch and tag to $remote? (y/N)"
+echo "You may want to do this manually after creating and verifying release."
+echo "e.g."
+echo "    git push -u origin ${TAG}-dev"
+echo "    git push origin ${TAG}"
+read proceed
+if [[ ( "x${proceed}" == "xy" ) || ( "x${proceed}" == "xY" ) ]] ; then
+    git push -u origin "${TAG}-dev"
+    ERR=$?
+    if [ ${ERR} -ne 0 ]; then
+        echo "Failed to push branch ${TAG}-dev to remote"
+        exit ${ERR}
+    fi
+    git push origin "${TAG}"
+    ERR=$?
+    if [ ${ERR} -ne 0 ]; then
+        echo "Failed to push tag ${TAG}-dev to remote"
+        exit ${ERR}
+    fi
+else
+    echo "Branch and tag are local, changes not pushed to remote!"
+fi
+
index 7aa8aad0aea063cd47c5841cee8fcdced4b7ae62..a0bb1b3f36284ea4585bc307d8963bbdbbe0650f 100644 (file)
@@ -1731,12 +1731,16 @@ static int ParseOptions( int argc, char ** argv )
     #define PRESET_EXPORT_FILE   304
     #define PRESET_IMPORT        305
     #define PRESET_IMPORT_GUI    306
+    #define VERSION              307
+    #define DESCRIBE             308
 
     for( ;; )
     {
         static struct option long_options[] =
           {
             { "help",        no_argument,       NULL,    'h' },
+            { "version",     no_argument,       NULL,    VERSION },
+            { "describe",    no_argument,       NULL,    DESCRIBE },
             { "update",      no_argument,       NULL,    'u' },
             { "verbose",     optional_argument, NULL,    'v' },
             { "no-dvdnav",   no_argument,       NULL,    DVDNAV },
@@ -1906,6 +1910,12 @@ static int ParseOptions( int argc, char ** argv )
             case 'h':
                 ShowHelp();
                 exit( 0 );
+            case VERSION:
+                printf("HandBrake %s\n", hb_get_version(NULL));
+                exit(0);
+            case DESCRIBE:
+                printf("%s\n", hb_get_full_description());
+                exit(0);
             case 'u':
                 update = 1;
                 break;