Changes between Version 35 and Version 36 of RpmHowToPackagers


Ignore:
Timestamp:
Jul 1, 2015, 4:18:43 PM (9 years ago)
Author:
dmik
Comment:

Added info about downloading sources from Git and Github

Legend:

Unmodified
Added
Removed
Modified
  • RpmHowToPackagers

    v35 v36  
    208208Note the commented out `svn_rev` variable — this causes the local changes from the working copy to be picked up. If `svn_rev` is not commented out then the specified revision w/o any local modifications will be used (the same way as when giving an URL; the only difference is that no network connection is required given that the specified revision is already contained in the working copy).
    209209
     210=== Git ===
     211
     212Projects that use git may be handled similarly but they have their own specifics. There is currently no real-life example of such a project in our repositories but let's assume there is a project called `foobar` with a remote repository at  `git://mygitserver.com`.
     213
     214Paste this block after the main keyword block and before the `%description` field for the main package:
     215{{{
     216%define git_url     git://mygitserver.com/foobar.git
     217%define git_rev     mytag
     218
     219Source: %{name}-%{git_rev}.zip
     220
     221BuildRequires: gcc make git zip
     222}}}
     223
     224Paste this block instead of the usual `%prep / %setup / %patch` sequence:
     225{{{
     226%prep
     227%if %(sh -c 'if test -f "%{_sourcedir}/%{name}-%{git_rev}.zip" ; then echo 1 ; else echo 0 ; fi')
     228%setup -q
     229%else
     230%setup -n "%{name}-%{version}" -Tc
     231rm -f "%{_sourcedir}/%{name}-%{git_rev}.zip"
     232git archive --format zip --output "%{_sourcedir}/%{name}-%{git_rev}.zip" --prefix "%{name}-%{version}/" --remote "%{git_url}" "%{git_rev}"
     233unzip "%{name}-%{git_rev}.zip" -d ..
     234%endif
     235}}}
     236
     237Note that you may use your local clone instead of the remote repository as well as with SVN to save some traffic. The URL in this case should be something like `file://D:/Coding/foobar`.
     238
     239=== Github ===
     240
     241If a project is hosted at [http://github.com github], we will need to use `curl` instead of `git archive` because github does not support the `archive` command and instead provides a special URL for downloading ZIPs of the tree at any given commit or tag. The snippets below are based on this real-life [http://trac.netlabs.org/rpm/browser/spec/trunk/SPECS/libkai.spec?rev=576 spec file].
     242
     243Paste this block after the main keyword block and before the `%description` field for the main package:
     244{{{
     245%define github_name kai
     246%define github_url  https://github.com/komh/%{github_name}/archive
     247%define github_rev  kai-%{version}
     248
     249Source: %{github_name}-%{github_rev}.zip
     250
     251BuildRequires: gcc make curl zip
     252}}}
     253
     254Paste this block instead of the usual `%prep / %setup / %patch` sequence:
     255{{{
     256%prep
     257%if %(sh -c 'if test -f "%{_sourcedir}/%{github_name}-%{github_rev}.zip" ; then echo 1 ; else echo 0 ; fi')
     258%setup -n "%{github_name}-%{github_rev}" -q
     259%else
     260%setup -n "%{github_name}-%{github_rev}" -Tc
     261rm -f "%{_sourcedir}/%{github_name}-%{github_rev}.zip"
     262curl -sSL "%{github_url}/%{github_rev}.zip" -o "%{_sourcedir}/%{github_name}-%{github_rev}.zip"
     263unzip "%{_sourcedir}/%{github_name}-%{github_rev}.zip" -d ..
     264%endif
     265}}}
     266
     267Note that due to github naming specifics (and especially if the github's project name doesn't match the RPM package name, (like `kai` vs `libkai` in the example above), the source ZIP will have a name that differs from the usual `%{name}-%{version}` scheme (in the example above it will be `kai-kai-1.1.4.zip` rather than `libkai-1.1.4.zip`).
     268
     269You could use your local clone instead of the remote repository here as well but in this case magic github URLs for downloading ZIPs won't work so you will have to use the `git archive` command as in the [#Git] section above which is not very practical because you will have to make a lot of temporary changes to your `.spec` file which you will have to revert before committing it to the SPEC repo.
     270
    210271== Handling documentation in Info format ==
    211272