Skip to content

packagecloud #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 24, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 100 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,107 @@
dist: trusty
sudo: required
packagecloud: &packagecloud
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What’s the & do?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This defines a variable of some sort in YAML, allowing us to substitute them later using the <<: *packagecloud syntax to avoid repeating all these key/value pairs.

http://yaml.org/type/merge.html

provider: packagecloud
username: cs50
repository: libcs50
token: $PACKAGECLOUD_TOKEN
skip_cleanup: true
on:
branch: master

deb: &deb
<<: *packagecloud
local-dir: build/deb

rpm: &rpm
<<: *packagecloud
local-dir: build/rpm

branches:
except: "/^v\\d/"
env:
matrix:
- DIST=precise DIST_VERSION=12.04
- DIST=trusty DIST_VERSION=14.04
- DIST=vivid DIST_VERSION=15.04
- DIST=xenial DIST_VERSION=16.04
- DIST=zesty DIST_VERSION=17.04
before_install:
- sudo apt-get install build-essential debhelper devscripts dh-make lintian
- gem install asciidoctor
install: true
script: if [ "$TRAVIS_BRANCH" != "master" ]; then SIGNING_OPTS="-uc -us" make deb; fi
before_deploy:
- echo -e $GPG_SECRET | gpg --import
addons:
apt:
packages: rpm
before_install: gem install fpm
script:
- make deb
- make rpm
before_deploy: |
if [ -z "$(git tag --list "v$(make version)")" ]; then \
git config --local user.name "bot50"; \
git config --local user.email "[email protected]"; \
git tag "v$(make version)"; \
fi
deploy:
provider: script
script: dput ppa:cs50/ppa build/deb/*.changes
skip_cleanup: true
on:
branch: master
# Ubuntu
# 12.04
- <<: *deb
dist: ubuntu/precise

# 12.10
- <<: *deb
dist: ubuntu/quantal

# 13.04
- <<: *deb
dist: ubuntu/raring

# 13.10
- <<: *deb
dist: ubuntu/saucy

# 14.04
- <<: *deb
dist: ubuntu/trusty

# 14.10
- <<: *deb
dist: ubuntu/utopic

# 15.04
- <<: *deb
dist: ubuntu/vivid

# 15.10
- <<: *deb
dist: ubuntu/wily

# 16.04
- <<: *deb
dist: ubuntu/xenial

# 16.10
- <<: *deb
dist: ubuntu/yakkety

# 17.04
- <<: *deb
dist: ubuntu/zesty

# 17.10
- <<: *deb
dist: ubuntu/artful

# 18.04
- <<: *deb
dist: ubuntu/bionic

# Fedora
- <<: *rpm
dist: fedora/24
- <<: *rpm
dist: fedora/25
- <<: *rpm
dist: fedora/26
- <<: *rpm
dist: fedora/27
- <<: *rpm
dist: fedora/28

# GitHub release
- provider: releases
api_key: $GITHUB_TOKEN
skip_cleanup: true
on:
branch: libcs50
notifications:
slack:
secure: ISOGlNSGXOrMBrKTnjTWQXVjjoBn78++xF1mUv/PYZxn3J4L4WpybLLjAuBENsD7YeHSaXUnSbIV5mDzlx5Q1cyrS+auGOHqi5xGV01zNBB1Fig1SkUf7zJS8KyjiPKyi+DexnTt1BY4xaA1uGzq9hoGZEPXKHNlz4v1I6f6fHQ=
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2012-2018 CS50

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
104 changes: 72 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
@@ -7,12 +7,12 @@ MANDIR ?= share/man/man3

SRC := src/cs50.c
INCLUDE := src/cs50.h
DOCS := $(wildcard docs/*.adoc)
MANS := $(addprefix debian/, $(DOCS:%.adoc=%.3))
MANS := $(wildcard docs/*.3)

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

OS := $(shell uname)

# Linux
ifeq ($(OS),Linux)
LIB_BASE := libcs50.so
@@ -36,50 +36,90 @@ $(LIBS): $(SRC) $(INCLUDE) Makefile
$(CC) $(CFLAGS) -fPIC -shared $(LINKER_FLAGS) -o $(LIB_VERSION) $(SRC)
ln -s $(LIB_VERSION) $(LIB_MAJOR)
ln -s $(LIB_MAJOR) $(LIB_BASE)
mkdir -p src build/include
install -m 644 src/cs50.h build/include/cs50.h
mkdir -p build/lib build/src/libcs50
mkdir -p $(addprefix build/, include lib src)
install -m 644 $(SRC) build/src
install -m 644 $(INCLUDE) build/include
mv $(LIB_VERSION) $(LIB_MAJOR) $(LIB_BASE) build/lib
cp -r $(SRC) $(INCLUDE) build/src/libcs50

.PHONY: install
install: all
mkdir -p $(addprefix $(DESTDIR)/, src lib include $(MANDIR))
cp -r build/* $(DESTDIR)
cp debian/docs/* $(DESTDIR)/$(MANDIR)
cp -r $(filter-out deb, $(wildcard build/*)) $(DESTDIR)
cp -r $(MANS) $(DESTDIR)/$(MANDIR)

ifeq ($(OS),Linux)
ldconfig
endif

.PHONY: clean
clean:
rm -rf build debian/docs/

# requires asciidoctor (gem install asciidoctor)
$(MANS): $(DOCS) Makefile
asciidoctor -d manpage -b manpage -D debian/docs/ $(DOCS)
rm -rf build

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

.PHONY: hack
hack:
mkdir -p build/hack
echo "\n#ifndef _CS50_C\n#define _CS50_C\ntypedef char *string;\n" > build/hack/cs50.h
grep -v '^#include "cs50.h"' src/cs50.c >> build/hack/cs50.h
echo "\n#endif" >> build/hack/cs50.h
cat src/cs50.h >> build/hack/cs50.h
rm -rf build/deb

# temporary fpm source
mkdir -p build/deb/libcs50/usr/local
cp -r $(addprefix build/, include lib src) build/deb/libcs50/usr/local
mkdir -p build/deb/libcs50/usr/local/share/man/man3
cp -r $(MANS) build/deb/libcs50/usr/local/share/man/man3
fpm \
--after-install postinst \
--after-remove postrm \
--category libs \
--chdir build/deb/libcs50 \
--conflicts lib50-c \
--conflicts libcs50 \
--conflicts library50-c \
--deb-priority optional \
--description "CS50 library for C" \
--input-type dir \
--license "MIT" \
--maintainer "CS50 <[email protected]>" \
--name libcs50 \
--output-type deb \
--package build/deb \
--provides lib50-c \
--provides libcs50 \
--provides library50-c \
--replaces lib50-c \
--replaces libcs50 \
--replaces library50-c \
--url https://github.com/cs50/libcs50 \
--vendor CS50 \
--version $(VERSION) \
.

rm -rf build/deb/libcs50

rpm: $(LIBS) $(MANS)
rm -rf build/rpm

# temporary fpm source
mkdir -p build/rpm/libcs50/usr/local
cp -r $(addprefix build/, include lib src) build/rpm/libcs50/usr/local
mkdir -p build/rpm/libcs50/usr/local/share/man/man3
cp -r $(MANS) build/rpm/libcs50/usr/local/share/man/man3
fpm \
--after-install post \
--after-remove postun \
--category libs \
--chdir build/rpm/libcs50 \
--description "CS50 library for C" \
--input-type dir \
--license "MIT" \
--maintainer "CS50 <[email protected]>" \
--name libcs50 \
--output-type rpm \
--package build/rpm \
--provides libcs50 \
--url https://github.com/cs50/libcs50 \
--vendor CS50 \
--version $(VERSION) \
.

rm -rf build/rpm/libcs50

# used by .travis.yml
.PHONY: version
26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -8,34 +8,30 @@

`make deb`: builds source deb

`make hack`: combines library into `cs50.h`

`make install`: installs the library under `/usr/local` by default (set `DESTDIR` to change that)

## Installation

### Ubuntu

```
sudo apt-get install software-properties-common whiptail
sudo apt-add-repository ppa:cs50/ppa
sudo apt-get update
sudo apt-get install libcs50
$ curl -s https://packagecloud.io/install/repositories/cs50/libcs50/script.deb.sh | sudo bash
$ sudo apt-get install libcs50
```

### Fedora

```
$ curl -s https://packagecloud.io/install/repositories/cs50/libcs50/script.rpm.sh | sudo bash
$ yum install libcs50
```

### From Source (Linux and Mac)

1. Download the latest release per https://github.com/cs50/libcs50/releases
1. Download the latest release from https://github.com/cs50/libcs50/releases
1. Extract `libcs50-*.*`
1. `cd libcs50-*`
1. `gem install asciidoctor`, as needed

If on Mac:
* `make install`

If on Linux:
* `make`
* `sudo make install`
1. `sudo make install`

By default, we install to `/usr/local`. If you'd like to change the installation location, run
`sudo DESTDIR=/path/to/install make install` as desired.
1 change: 0 additions & 1 deletion debian/compat

This file was deleted.

16 changes: 0 additions & 16 deletions debian/control

This file was deleted.

37 changes: 0 additions & 37 deletions debian/copyright

This file was deleted.

3 changes: 0 additions & 3 deletions debian/libcs50.dirs

This file was deleted.

3 changes: 0 additions & 3 deletions debian/libcs50.install

This file was deleted.

8 changes: 0 additions & 8 deletions debian/libcs50.manpages

This file was deleted.

5 changes: 0 additions & 5 deletions debian/libcs50.postinst.debhelper

This file was deleted.

Loading