Skip to content

Commit ab46e2b

Browse files
author
Kareem Zidane
committed
building with fpm, deploying to packagecloud
1 parent 2eccace commit ab46e2b

33 files changed

+737
-592
lines changed

.travis.yml

+64-21
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,71 @@
1-
dist: trusty
2-
sudo: required
1+
packagecloud: &packagecloud
2+
provider: packagecloud
3+
username: cs50
4+
repository: libcs50
5+
token: $PACKAGECLOUD_TOKEN
6+
local-dir: build/deb
7+
package_glob: *.deb
8+
skip_cleanup: true
9+
on:
10+
branch: master
11+
312
branches:
413
except: "/^v\\d/"
5-
env:
6-
matrix:
7-
- DIST=precise DIST_VERSION=12.04
8-
- DIST=trusty DIST_VERSION=14.04
9-
- DIST=vivid DIST_VERSION=15.04
10-
- DIST=xenial DIST_VERSION=16.04
11-
- DIST=zesty DIST_VERSION=17.04
12-
before_install:
13-
- sudo apt-get install build-essential debhelper devscripts dh-make lintian
14-
- gem install asciidoctor
14+
before_install: gem install fpm
1515
install: true
16-
script: if [ "$TRAVIS_BRANCH" != "master" ]; then SIGNING_OPTS="-uc -us" make deb; fi
17-
before_deploy:
18-
- echo -e $GPG_SECRET | gpg --import
19-
- make deb
16+
script: make deb
2017
deploy:
21-
provider: script
22-
script: dput ppa:cs50/ppa build/deb/*.changes
23-
skip_cleanup: true
24-
on:
25-
branch: master
18+
# 12.04
19+
- <<: *packagecloud
20+
dist: ubuntu/precise
21+
22+
# 12.10
23+
- <<: *packagecloud
24+
dist: ubuntu/quantal
25+
26+
# 13.04
27+
- <<: *packagecloud
28+
dist: ubuntu/raring
29+
30+
# 13.10
31+
- <<: *packagecloud
32+
dist: ubuntu/saucy
33+
34+
# 14.04
35+
- <<: *packagecloud
36+
dist: ubuntu/trusty
37+
38+
# 14.10
39+
- <<: *packagecloud
40+
dist: ubuntu/utopic
41+
42+
# 15.04
43+
- <<: *packagecloud
44+
dist: ubuntu/vivid
45+
46+
# 15.10
47+
- <<: *packagecloud
48+
dist: ubuntu/wily
49+
50+
# 16.04
51+
- <<: *packagecloud
52+
dist: ubuntu/xenial
53+
54+
# 16.10
55+
- <<: *packagecloud
56+
dist: ubuntu/yakkety
57+
58+
# 17.04
59+
- <<: *packagecloud
60+
dist: ubuntu/zesty
61+
62+
# 17.10
63+
- <<: *packagecloud
64+
dist: ubuntu/artful
65+
66+
# 18.04
67+
- <<: *packagecloud
68+
dist: ubuntu/bionic
2669
notifications:
2770
slack:
2871
secure: ISOGlNSGXOrMBrKTnjTWQXVjjoBn78++xF1mUv/PYZxn3J4L4WpybLLjAuBENsD7YeHSaXUnSbIV5mDzlx5Q1cyrS+auGOHqi5xGV01zNBB1Fig1SkUf7zJS8KyjiPKyi+DexnTt1BY4xaA1uGzq9hoGZEPXKHNlz4v1I6f6fHQ=

Makefile

+40-32
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ MANDIR ?= share/man/man3
77

88
SRC := src/cs50.c
99
INCLUDE := src/cs50.h
10-
DOCS := $(wildcard docs/*.adoc)
11-
MANS := $(addprefix debian/, $(DOCS:%.adoc=%.3))
10+
MANS := $(wildcard docs/*.3)
1211

1312
CFLAGS=-Wall -Wextra -Werror -pedantic -std=c99
1413

1514
OS := $(shell uname)
15+
1616
# Linux
1717
ifeq ($(OS),Linux)
1818
LIB_BASE := libcs50.so
@@ -30,56 +30,64 @@ endif
3030
LIBS := $(addprefix build/lib/, $(LIB_BASE) $(LIB_MAJOR) $(LIB_VERSION))
3131

3232
.PHONY: all
33-
all: $(LIBS) $(MANS)
33+
all: $(LIBS)
3434

3535
$(LIBS): $(SRC) $(INCLUDE) Makefile
3636
$(CC) $(CFLAGS) -fPIC -shared $(LINKER_FLAGS) -o $(LIB_VERSION) $(SRC)
3737
ln -s $(LIB_VERSION) $(LIB_MAJOR)
3838
ln -s $(LIB_MAJOR) $(LIB_BASE)
39-
mkdir -p src build/include
40-
install -m 644 src/cs50.h build/include/cs50.h
41-
mkdir -p build/lib build/src/libcs50
39+
mkdir -p $(addprefix build/, include lib src)
40+
install -m 644 $(SRC) build/src
41+
install -m 644 $(INCLUDE) build/include
4242
mv $(LIB_VERSION) $(LIB_MAJOR) $(LIB_BASE) build/lib
43-
cp -r $(SRC) $(INCLUDE) build/src/libcs50
4443

4544
.PHONY: install
4645
install: all
4746
mkdir -p $(addprefix $(DESTDIR)/, src lib include $(MANDIR))
48-
cp -r build/* $(DESTDIR)
49-
cp debian/docs/* $(DESTDIR)/$(MANDIR)
47+
cp -r $(filter-out deb, $(wildcard build/*)) $(DESTDIR)
48+
cp -r $(MANS) $(DESTDIR)/$(MANDIR)
49+
5050
ifeq ($(OS),Linux)
5151
ldconfig
5252
endif
5353

5454
.PHONY: clean
5555
clean:
56-
rm -rf build debian/docs/
57-
58-
# requires asciidoctor (gem install asciidoctor)
59-
$(MANS): $(DOCS) Makefile
60-
asciidoctor -d manpage -b manpage -D debian/docs/ $(DOCS)
56+
rm -rf build
6157

6258
.PHONY: deb
6359
deb: $(LIBS) $(MANS)
64-
rm -rf build/deb &>/dev/null
65-
@echo "libcs50 ($(VERSION)-0ubuntu$(DIST_VERSION)) $(DIST); urgency=low" > debian/changelog
66-
@echo " * v$(VERSION)" >> debian/changelog
67-
@echo " -- CS50 Sysadmins <[email protected]> $$(date --rfc-2822)" >> debian/changelog
68-
mkdir -p libcs50-$(VERSION)/usr
69-
cp -r build/* libcs50-$(VERSION)/usr
70-
GZIP=-n tar --mtime='2017-01-01' -cvzf libcs50_$(VERSION).orig.tar.gz libcs50-$(VERSION)
71-
cp -r debian libcs50-$(VERSION)
72-
cd libcs50-$(VERSION) && debuild $(SIGNING_OPTS) -S -sa --lintian-opts --display-info --info --show-overrides
73-
mkdir -p build/deb
74-
mv libcs50-* libcs50_* build/deb
60+
rm -rf build/deb
7561

76-
.PHONY: hack
77-
hack:
78-
mkdir -p build/hack
79-
echo "\n#ifndef _CS50_C\n#define _CS50_C\ntypedef char *string;\n" > build/hack/cs50.h
80-
grep -v '^#include "cs50.h"' src/cs50.c >> build/hack/cs50.h
81-
echo "\n#endif" >> build/hack/cs50.h
82-
cat src/cs50.h >> build/hack/cs50.h
62+
# temporary fpm source
63+
mkdir -p build/deb/libcs50/usr/local
64+
cp -r $(addprefix build/, include lib src) build/deb/libcs50/usr/local
65+
mkdir -p build/deb/libcs50/usr/local/share/man/man3
66+
cp -r $(MANS) build/deb/libcs50/usr/local/share/man/man3
67+
fpm \
68+
--category libs \
69+
--chdir build/deb/libcs50 \
70+
--conflicts lib50-c \
71+
--conflicts libcs50 \
72+
--conflicts library50-c \
73+
--deb-priority optional \
74+
--description "CS50 library for C" \
75+
--input-type dir \
76+
--license "" \
77+
--maintainer "CS50 <[email protected]>" \
78+
--name libcs50 \
79+
--output-type deb \
80+
--package build/deb \
81+
--provides lib50-c \
82+
--provides libcs50 \
83+
--provides library50-c \
84+
--replaces lib50-c \
85+
--replaces libcs50 \
86+
--replaces library50-c \
87+
--url https://github.com/cs50/libcs50 \
88+
--vendor CS50 \
89+
--version $(VERSION) \
90+
.
8391

8492
# used by .travis.yml
8593
.PHONY: version

debian/compat

-1
This file was deleted.

debian/control

-16
This file was deleted.

debian/copyright

-37
This file was deleted.

debian/libcs50.dirs

-3
This file was deleted.

debian/libcs50.install

-3
This file was deleted.

debian/libcs50.manpages

-8
This file was deleted.

debian/libcs50.postinst.debhelper

-5
This file was deleted.

debian/libcs50.postrm.debhelper

-5
This file was deleted.

debian/libcs50.substvars

-2
This file was deleted.

debian/rules

-8
This file was deleted.

debian/source.lintian-overrides

-1
This file was deleted.

debian/source/format

-1
This file was deleted.

debian/watch

Whitespace-only changes.

docs/eprintf.3

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
'\" t
2+
.\" Title: eprintf
3+
.\" Author: [see the "AUTHOR(S)" section]
4+
.\" Generator: Asciidoctor 1.5.7.1
5+
.\" Date: 2017-09-16
6+
.\" Manual: CS50 Programmer's Manual
7+
.\" Source: CS50
8+
.\" Language: English
9+
.\"
10+
.TH "EPRINTF" "3" "2017-09-16" "CS50" "CS50 Programmer\(aqs Manual"
11+
.ie \n(.g .ds Aq \(aq
12+
.el .ds Aq '
13+
.ss \n[.ss] 0
14+
.nh
15+
.ad l
16+
.de URL
17+
\fI\\$2\fP <\\$1>\\$3
18+
..
19+
.als MTO URL
20+
.if \n[.g] \{\
21+
. mso www.tmac
22+
. am URL
23+
. ad l
24+
. .
25+
. am MTO
26+
. ad l
27+
. .
28+
. LINKSTYLE blue R < >
29+
.\}
30+
.SH "NAME"
31+
eprintf \- prints an error message to stderr
32+
.SH "SYNOPSIS"
33+
.sp
34+
\fB#include <cs50.h>\fP
35+
.sp
36+
\fBvoid eprintf(const string format, ...);\fP
37+
.SH "DESCRIPTION"
38+
.sp
39+
Prints an error message formatted like \fBprintf(3)\fP to standard error, prefixing it with file and line number from which the function was called. See \fBprintf(3)\fP for more on formatting.
40+
.SH "EXAMPLE"
41+
.sp
42+
.if n .RS 4
43+
.nf
44+
int main(void)
45+
{
46+
eprintf("This line of code should be executed\(rsn");
47+
48+
int i;
49+
for (i = 0; i < 50; i++)
50+
{
51+
printf("i is %d\(rsn", i);
52+
}
53+
54+
eprintf("Expected i to be 49 but it is actually %d\(rsn", i);
55+
}
56+
.fi
57+
.if n .RE
58+
.SH "SEE ALSO"
59+
.sp
60+
.if n .RS 4
61+
.nf
62+
printf(3)
63+
.fi
64+
.if n .RE

0 commit comments

Comments
 (0)