Skip to content

Commit

Permalink
Add a multi-distro spec file to build procdump
Browse files Browse the repository at this point in the history
This commit simultaneously removes the old way to produce a Debian package.

Signed-off-by: Neal Gompa <ngompa13@gmail.com>
  • Loading branch information
Conan-Kudo committed Oct 20, 2018
1 parent ddfa626 commit c6ec2d6
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -34,3 +34,4 @@
# Project directories
bin/
release/
pkgbuild/
19 changes: 19 additions & 0 deletions BUILDING_PACKAGE.md
@@ -0,0 +1,19 @@
# Building the package

This package is built using [debbuild](https://github.com/ascherer/debbuild) for Debian targets.

The Makefile included in this project helps you to do builds, but you need
to have debbuild installed first.

You can install debbuild from the deb published on [the GitHub project releases](https://github.com/ascherer/debbuild/releases).

Once installed, `make deb` will let you build a Debian package.

For building RPMs, you just need `rpmbuild`. For example, on Fedora:

```bash
$ sudo dnf install rpm-build

```

Once installed, `make rpm` will let you build an RPM package.
16 changes: 0 additions & 16 deletions DEBIAN_PACKAGE.control

This file was deleted.

46 changes: 24 additions & 22 deletions Makefile
Expand Up @@ -23,15 +23,17 @@ INSTALLDIR=/usr/bin
MANDIR=/usr/share/man/man1

# package creation directories
RELEASEDIR=release
RELEASEBINDIR=$(RELEASEDIR)/procdump/usr/bin
RELEASECONTROLDIR=$(RELEASEDIR)/procdump/DEBIAN
RELEASEMANDIR=$(RELEASEDIR)/procdump/usr/share/man/man1
BUILDDIR := $(CURDIR)/pkgbuild

# Flags to pass to debbuild/rpmbuild
PKGBUILDFLAGS := --define "_topdir $(BUILDDIR)" -bb

# Command to create the build directory structure
PKGBUILDROOT_CREATE_CMD = mkdir -p $(BUILDDIR)/DEBS $(BUILDDIR)/SDEBS $(BUILDDIR)/RPMS $(BUILDDIR)/SRPMS \
$(BUILDDIR)/SOURCES $(BUILDDIR)/SPECS $(BUILDDIR)/BUILD $(BUILDDIR)/BUILDROOT

# package details
PKG_VERSION=1.0.1
PKG_ARCH=amd64
PKG_DEB=procdump_$(PKG_VERSION)_$(PKG_ARCH).deb

all: clean build

Expand Down Expand Up @@ -61,28 +63,28 @@ $(OBJDIR):
$(BINDIR):
-@mkdir -p $(BINDIR)

.PHONY: clean
clean:
-rm -rf $(OBJDIR)
-rm -rf $(BINDIR)
-rm -rf $(RELEASEDIR)
-rm -rf $(BUILDDIR)

test: build
./tests/integration/run.sh

release: deb tarball

deb: build
mkdir -p $(RELEASEBINDIR)
mkdir -p $(RELEASECONTROLDIR)
mkdir -p $(RELEASEMANDIR)
md5sum $(OUT) > $(RELEASECONTROLDIR)/md5sums
cp $(OUT) $(RELEASEBINDIR)
cp DEBIAN_PACKAGE.control $(RELEASECONTROLDIR)/control
cp procdump.1 $(RELEASEMANDIR)
dpkg-deb -b $(RELEASEDIR)/procdump $(RELEASEDIR)/$(PKG_DEB)
rm -rf $(RELEASEDIR)/procdump
release: clean tarball

.PHONY: tarball
tarball:
mkdir -p $(RELEASEDIR)
tar -czf $(RELEASEDIR)/procdump_$(PKG_VERSION).tar.gz Makefile README.md CODE_OF_CONDUCT.md CONTRIBUTING.md DEBIAN_PACKAGE.control procdump.1 ./tests ./include ./src

$(PKGBUILDROOT_CREATE_CMD)
tar --exclude=./pkgbuild --exclude=./.git --transform 's,^\.,procdump-$(PKG_VERSION),' -czf $(BUILDDIR)/SOURCES/procdump-$(PKG_VERSION).tar.gz .
cp dist/procdump.spec.in $(BUILDDIR)/SPECS/procdump.spec
sed -e "s/@PKG_VERSION@/$(PKG_VERSION)/g" -i $(BUILDDIR)/SPECS/procdump.spec

.PHONY: deb
deb: tarball
debbuild $(PKGBUILDFLAGS) $(BUILDDIR)/SPECS/procdump.spec

.PHONY: rpm
rpm: tarball
rpmbuild $(PKGBUILDFLAGS) $(BUILDDIR)/SPECS/procdump.spec
65 changes: 65 additions & 0 deletions dist/procdump.spec.in
@@ -0,0 +1,65 @@
Name: procdump
Version: @PKG_VERSION@
Release: 1%{?dist}
Summary: Sysinternals process dump utility

%if %{_vendor} == "debbuild"
Group: devel
%else
Group: Development/Tools%{?suse_version:/Other}
%endif

Packager: OSS Tooling Dev Team <OSSToolingDevTeam@service.microsoft.com>

License: MIT
URL: https://github.com/Microsoft/ProcDump-for-Linux
Source0: %{url}/releases/download/%{version}/%{name}-%{version}.tar.gz

BuildRequires: gcc, make

%if %{_vendor} == "debbuild"
BuildRequires: zlib1g-dev
%else
BuildRequires: zlib-devel
%endif

Requires: gdb >= 7.6.1

%description
ProcDump is a command-line utility whose primary purpose is monitoring an application
for various resources and generating crash dumps during a spike that an administrator
or developer can use to determine the cause of the issue. ProcDump also serves as a
general process dump utility that you can embed in other scripts.


%prep
%autosetup


%build
# The makefile doesn't like %%make_build (parallel make)
make CFLAGS="%{optflags}"


%install
%make_install


%files
%license LICENSE
%doc README.md procdump.gif
%{_bindir}/procdump
%{_mandir}/man1/procdump.1*



%changelog
* Wed Jan 10 2018 Javid Habibi <jahabibi@microsoft.com> - 1.0.1
- fixed potential deadlock upon malloc failing
- fixed improper process name parsing and sanitizing process
name for dump file generation
- fixed various typos
- fixed post-build check failures on openSUSE

* Tue Dec 05 2017 Javid Habibi <jahabibi@microsoft.com> - 1.0
- Initial release

0 comments on commit c6ec2d6

Please sign in to comment.