building a standalone rpm from the standalone tarball

This allows the rpm to be built anywhere the necessary build deps are
available (including on debian) and the resulting package will work on as
broad a range of rpm distributions as the libc/kernel supports.

The DistributionUpdate changes to use the new script have not yet been
tested.
This commit is contained in:
Joey Hess 2019-09-12 19:02:59 -04:00
parent 53fd746705
commit 4508198507
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 121 additions and 4 deletions

View file

@ -5,6 +5,9 @@
- Generates info files, containing the version (of the corresponding file
- from the autobuild).
-
- Builds standalone rpms from the standalone tarballs, and populates
- a rpm package repository with them using the createrepo program.
-
- Also gpg signs the files.
-}
@ -44,15 +47,46 @@ autobuilds =
)
autobuild f = "https://downloads.kitenet.net/git-annex/autobuild/" ++ f
-- Names of architectures in standalone tarballs and the corresponding
-- rpm architecture.
tarrpmarches :: [(String, String)]
tarrpmarches =
[ ("i386", "i386")
, ("amd64", "x86_64")
, ("arm64", "aarch64")
]
buildrpms :: FilePath -> [(FilePath, Version)] -> Annex ()
buildrpms topdir l = do
liftIO $ createDirectoryIfMissing True rpmrepo
forM_ tarrpmarches $ \(tararch, rpmarch) ->
forM_ (filter (isstandalonetarball tararch . fst) l) $ \(tarball, v) ->
void $ liftIO $ boolSystem script
[ Param rpmarch
, File tarball
, Param v
, File rpmrepo
]
void $ liftIO $ boolSystem "createrepo" [File rpmrepo]
void $ inRepo $ runBool [Param "annex", Param "add", File rpmrepo]
where
isstandalonetarball tararch f =
("git-annex-standalone-" ++ tararch ++ ".tar.gz") `isSuffixOf` f
script = topdir </> "standalone" </> "rpm" </> "rpmbuild-from-standalone-tarball"
rpmrepo = "git-annex/linux/current/rpms"
main :: IO ()
main = do
useFileSystemEncoding
version <- liftIO getChangelogVersion
version <- getChangelogVersion
repodir <- getRepoDir
topdir <- getCurrentDirectory
changeWorkingDirectory repodir
updated <- catMaybes <$> mapM (getbuild repodir) autobuilds
state <- Annex.new =<< Git.Construct.fromPath "."
Annex.eval state (makeinfos updated version)
Annex.eval state $ do
buildrpms topdir updated
makeinfos updated version
-- Download a build from the autobuilder, virus check it, and return its
-- version.

View file

@ -32,6 +32,7 @@ git-annex (7.20190912) UNRELEASED; urgency=medium
* init: Catch more exceptions when testing locking.
* init: Fix a reversion that broke initialization on systems that
need to use pid locking.
* Added standalone/rpm/rpmbuild-from-standalone-tarball script.
-- Joey Hess <id@joeyh.name> Sat, 24 Aug 2019 12:54:35 -0400

View file

@ -179,9 +179,9 @@ linuxstandalone:
cd tmp/git-annex.linux && find . -type l >> git-annex.MANIFEST
cd tmp && tar c git-annex.linux | gzip -9 --rsyncable > git-annex-standalone-$(shell dpkg --print-architecture).tar.gz
# Run this target to build git-annex-standalone*.deb
# Run this target to build git-annex-standalone.deb
debianstandalone: dpkg-buildpackage-F
# Run this target to build git-annex-standalone*.dsc
# Run this target to build git-annex-standalone.dsc
debianstandalone-dsc: dpkg-buildpackage-S
prep-standalone:

View file

@ -0,0 +1,44 @@
Name: git-annex-standalone
Version: %{version}
Release: %{release}
Summary: manage files with git, without checking their contents into git
License: AGPL
AutoReqProv: no
Requires: git
%description
git-annex allows managing files with git, without checking the file
contents into git. While that may seem paradoxical, it is useful when
dealing with files larger than git can currently easily handle, whether due
to limitations in memory, time, or disk space.
It can store large files in many places, from local hard drives, to a
large number of cloud storage services, including S3, WebDAV,
and rsync, with a dozen cloud storage providers usable via plugins.
Files can be stored encrypted with gpg, so that the cloud storage
provider cannot see your data. git-annex keeps track of where each file
is stored, so it knows how many copies are available, and has many
facilities to ensure your data is preserved.
git-annex can also be used to keep a folder in sync between computers,
noticing when files are changed, and automatically committing them
to git and transferring them to other computers. The git-annex webapp
makes it easy to set up and use git-annex this way.
%build
# Need to have run make linuxstandalone (or untarred the standalone
# tarball) before building this rpm; the git-annex source code is not built
# here. --build-root has to be pointed at the git-annex.linux directory.
%install
mkdir -p %{buildroot}/usr/lib/
cp -a %{buildroot}/../git-annex.linux %{buildroot}/usr/lib
mkdir -p %{buildroot}/usr/bin/
ln -sf /usr/lib/git-annex.linux/git-annex %{buildroot}/usr/bin/git-annex
ln -sf /usr/lib/git-annex.linux/git-annex %{buildroot}/usr/bin/git-annex-shell
%files
%attr(-, root, root)
/usr/bin/git-annex
/usr/bin/git-annex-shell
/usr/lib/git-annex.linux

View file

@ -0,0 +1,38 @@
#!/bin/sh
# Create a standalone rpm from a standalone tarball.
#
# This can build a rpm for any architecture you have a standalone tarball
# for, and does not need to be run on a machine of the same architecture.
set -e
rpmarch="$1"
tarball="$2"
version="$(echo "$3" | sed 's/-.*//')"
release=1
rpmrepo="$4"
if [ -z "$rpmarch" ] || [ -z "$tarball" ] || [ -z "$version" ] || [ -z "$rpmrepo" ]; then
echo "usage: rpmbuild-from-standalone-tarball rpmarch file.tar.gz version rpmrepo"
fi
basedir="$(dirname "$0")"
tmpdir=$(mktemp -d)
trap cleanup exit
cleanup () {
rm -rf "$tmpdir"
}
cat "$tarball" | (cd "$tmpdir" && tar zx)
buildroot="$tmpdir/rpmbuild"
mkdir -p "$buildroot"
rpmbuild \
--buildroot="$buildroot" \
--define="_rpmdir `pwd`" \
--define="_rpmfilename git-annex-standalone.rpm" \
--define="version $version" \
--define="release $release" \
--target="$rpmarch" \
-bb "$basedir/git-annex-standalone.spec" \
--quiet
package="git-annex-standalone-$version-$release.$rpmarch.rpm"
mv git-annex-standalone.rpm "$rpmrepo/$package"