Add install rules, rpm spec, and workflow

This commit is contained in:
Gordon Messmer 2026-01-31 12:02:41 -08:00
commit 55a1f7244c
5 changed files with 95 additions and 5 deletions

20
.github/workflows/sourcegit.yml vendored Normal file
View file

@ -0,0 +1,20 @@
name: source-git build and test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: source-git build
uses: gordonmessmer/source-git-action@main
with:
mock-root: 'fedora-44-x86_64'

View file

@ -2,6 +2,11 @@ CC = gcc
CFLAGS = -Wall -fPIC
LDFLAGS = -shared
PREFIX ?= /usr/local
LIBDIR = $(PREFIX)/lib
INCLUDEDIR = $(PREFIX)/include
BINDIR = $(PREFIX)/bin
UNVERSIONED_DIR = lib-unversioned
VERSIONED_DIR = lib-versioned
@ -9,7 +14,7 @@ LIB_NAME = libFoo.so
LIB_SONAME = libFoo.so.1
LIB_REALNAME = libFoo.so.1.0.0
.PHONY: all unversioned versioned bar bar-versioned clean
.PHONY: all unversioned versioned bar bar-versioned clean install uninstall
all: unversioned bar versioned bar-versioned
@ -55,3 +60,20 @@ $(VERSIONED_DIR)/$(LIB_NAME): $(VERSIONED_DIR)/$(LIB_REALNAME)
clean:
rm -rf $(UNVERSIONED_DIR) $(VERSIONED_DIR) Bar Bar-versioned
install: versioned bar
install -d $(DESTDIR)$(LIBDIR)
install -d $(DESTDIR)$(INCLUDEDIR)
install -d $(DESTDIR)$(BINDIR)
install -m 755 $(VERSIONED_DIR)/$(LIB_REALNAME) $(DESTDIR)$(LIBDIR)/$(LIB_REALNAME)
ln -sf $(LIB_REALNAME) $(DESTDIR)$(LIBDIR)/$(LIB_SONAME)
ln -sf $(LIB_REALNAME) $(DESTDIR)$(LIBDIR)/$(LIB_NAME)
install -m 644 foo.h $(DESTDIR)$(INCLUDEDIR)/foo.h
install -m 755 Bar $(DESTDIR)$(BINDIR)/Bar
uninstall:
rm -f $(DESTDIR)$(LIBDIR)/$(LIB_REALNAME)
rm -f $(DESTDIR)$(LIBDIR)/$(LIB_SONAME)
rm -f $(DESTDIR)$(LIBDIR)/$(LIB_NAME)
rm -f $(DESTDIR)$(INCLUDEDIR)/foo.h
rm -f $(DESTDIR)$(BINDIR)/Bar

View file

@ -1,4 +1,4 @@
Run `make` in both v1.0 and v1.1 to build four applications and shared libraries:
Run `build.sh` in both v1.0 and v1.1 to build four applications and shared libraries:
* v1.0/Bar: Bar linked to libFoo v1.0 without versioned symbols
* v1.0/Bar-versioned: Bar linked to libFoo v1.0 with versioned symbols
@ -9,7 +9,7 @@ This is intended to demonstrate three things:
## Adding versioned symbols to a library is a backward compatible change
`./Bar` is linked to a library without versioned symbols, but can be
Each `Bar` is linked to a library without versioned symbols, but can be
run with the library after versioned symbols are added.
```
@ -24,7 +24,7 @@ Usage: ./Bar <width> <height> <perimeter|area>
## Adding features to the library is a backward compatible change
The version of `./Bar` in the v1.0 directory can be used with the libraries
The version of `Bar` in the v1.0 directory can be used with the libraries
in the v1.1 directory.
```
@ -40,7 +40,7 @@ Usage: ./Bar <width> <height> <perimeter>
## Libraries are not forward compatible with new binaries
The reverse of the previous arrangement does not work. The version of
`./Bar` in the v1.1 directory cannot be used with the libraries in the
`Bar` in the v1.1 directory cannot be used with the libraries in the
v1.0 directory.
```

11
build.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/bash
# Minimal build script
set -e
# Build
make
branch=$(git branch --show-current)
mkdir $branch
cp -r Bar Bar-versioned lib-unversioned lib-versioned $branch

37
libFoo.spec Normal file
View file

@ -0,0 +1,37 @@
# Bar is built with an invalid rpath for demo purposes. Disable rpath check:
%global __brp_check_rpaths %{nil}
%global debug_package %{nil}
Name: libFoo
Version: 1.0
Release: %autorelease
Summary: A simple library
License: MIT
Source0: %{name}-%{version}.tar.gz
BuildRequires: gcc
BuildRequires: make
%description
A simple example spec file for Fedora.
%prep
%setup -q
%build
%make_build
%install
%make_install PREFIX=%{_prefix} LIBDIR=%{_libdir}
%check
%files
%{_bindir}/Bar
%{_includedir}/foo.h
%{_libdir}/libFoo.so
%{_libdir}/libFoo.so.1
%{_libdir}/libFoo.so.1.0.0
%changelog
%autochangelog