Skip to content

Commit dd7153c

Browse files
committed
docs: Add documentation on how to fetch packages from other sources, add build instructions, cleanup Readme.
1 parent 6d419a5 commit dd7153c

File tree

3 files changed

+134
-89
lines changed

3 files changed

+134
-89
lines changed

Building.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Building clib from source
2+
3+
## OSx
4+
5+
```sh
6+
$ git clone https://github.com/clibs/clib.git /tmp/clib
7+
$ cd /tmp/clib
8+
$ make install
9+
```
10+
11+
## Ubuntu or debian
12+
13+
```sh
14+
# install libcurl
15+
$ sudo apt install libcurl4-gnutls-dev -qq
16+
# clone
17+
$ git clone https://github.com/clibs/clib.git /tmp/clib && cd /tmp/clib
18+
# build
19+
$ make
20+
# put on path
21+
$ sudo make install
22+
```
23+
24+
## Windows (crosscompiling from linux)
25+
The docker image contains the mingw toolchain which is used to compile for windows.
26+
Curl needs to be built from source.
27+
```shell
28+
# Download and compile curl
29+
$ docker run --rm dockcross/windows-static-64-posix > dockcross-windows-x64
30+
$ cat dockcross-windows-x64
31+
$ chmod +x dockcross-windows-x64
32+
$ wget https://curl.haxx.se/download/curl-7.76.0.tar.gz
33+
$ tar xzf curl-*
34+
$ CURL_SRC=curl-*
35+
$ ./dockcross-windows-x64 bash -c 'cd '"$CURL_SRC"' && ./configure --prefix="/work/deps/curl" --host=x86_64-w64-mingw32.static --with-winssl --disable-dependency-tracking --disable-pthreads --enable-threaded-resolver --disable-imap --disable-pop3 --disable-smpt --disable-ldap --disable-mqtt --disable-smb'
36+
$ ./dockcross-windows-x64 bash -c 'cd '"$CURL_SRC"' && make'
37+
$ ./dockcross-windows-x64 bash -c 'cd '"$CURL_SRC"' && make install'
38+
$ git clone https://github.com/clibs/clib.git && cd clib
39+
$ ./dockcross-windows-x64 make all NO_PTHREADS=1 EXE=true
40+
```

Readme.md

+35-67
Original file line numberDiff line numberDiff line change
@@ -7,58 +7,28 @@
77

88
![c package manager screenshot](https://i.cloudup.com/GwqOU2hh9Y.png)
99

10-
## Installation
11-
12-
Expects [libcurl](http://curl.haxx.se/libcurl/) to be installed and linkable.
13-
14-
With [homebrew](https://github.com/Homebrew/homebrew):
15-
16-
```sh
17-
$ brew install clib
18-
```
19-
20-
Or [MacPorts](https://www.macports.org):
21-
22-
```sh
23-
$ sudo port selfupdate
24-
$ sudo port install clib
25-
```
26-
27-
With git:
28-
29-
```sh
30-
$ git clone https://github.com/clibs/clib.git /tmp/clib
31-
$ cd /tmp/clib
32-
$ make install
33-
```
10+
## About
3411

35-
Ubuntu:
12+
Basically the lazy-man's copy/paste promoting smaller C utilities, also
13+
serving as a nice way to discover these sort of libraries. From my experience
14+
C libraries are scattered all over the web and discovery is relatively poor. The footprint of these libraries is usually quite large and unfocused. The goal of `clibs` is to provide
15+
stand-alone "micro" C libraries for developers to quickly install without coupling
16+
to large frameworks.
3617

37-
```sh
38-
# install libcurl
39-
$ sudo apt-get install libcurl4-gnutls-dev -qq
40-
# clone
41-
$ git clone https://github.com/clibs/clib.git /tmp/clib && cd /tmp/clib
42-
# build
43-
$ make
44-
# put on path
45-
$ sudo make install
46-
```
18+
You should use `clib(1)` to fetch these files for you and check them into your repository, the end-user and contributors should not require having `clib(1)` installed. This allows `clib(1)` to fit into any new or existing C workflow without friction.
4719

48-
## About
20+
The [listing of packages](https://github.com/clibs/clib/wiki/Packages) acts as the "registry". The registry is used by `clib(1)` when searching for packages.
4921

50-
Basically the lazy-man's copy/paste promoting smaller C utilities, also
51-
serving as a nice way to discover these sort of libraries. From my experience
52-
C libraries are scattered all over the web and discovery is relatively poor. The footprint of these libraries is usually quite large and unfocused. The goal of `clibs` is to provide
53-
stand-alone "micro" C libraries for developers to quickly install without coupling
54-
to large frameworks.
22+
## Installation and building
23+
Binaries for `clib(1)` releases can be found at [releases](https://github.com/clibs/clib/releases/).
24+
For OSx and linux [libcurl](http://curl.haxx.se/libcurl/) should be installed and linkable.
25+
The windows binaries do not require any libraries to be installed.
5526

56-
You should use `clib(1)` to fetch these files for you and check them into your repository, the end-user and contributors should not require having `clib(1)` installed. This allows `clib(1)` to fit into any new or existing C workflow without friction.
27+
See [Building](Building.md) for instructions on how to build clib.
5728

58-
The wiki [listing of packages](https://github.com/clibs/clib/wiki/Packages) acts as the "registry" and populates the `clib-search(1)` results.
5929

6030
## Usage
61-
31+
More detailed information on how to use `clib` can be found in [Usage](Usage.md).
6232
```
6333
clib <command> [options]
6434
@@ -78,13 +48,9 @@ $ sudo make install
7848
search [query] Search for packages
7949
help <cmd> Display help for cmd
8050
```
51+
More information about the Command Line Interface can be found [here](https://github.com/clibs/clib/wiki/Command-Line-Interface).
8152

82-
More about the Command Line Interface [here](https://github.com/clibs/clib/wiki/Command-Line-Interface).
83-
84-
## Examples
85-
86-
More examples and best practices at [BEST_PRACTICE.md](https://github.com/clibs/clib/blob/master/BEST_PRACTICE.md).
87-
53+
### Example usage
8854
Install a few dependencies to `./deps`:
8955

9056
```sh
@@ -109,10 +75,26 @@ $ clib install ms file hash
10975
$ clib install visionmedia/mon visionmedia/every visionmedia/watch
11076
```
11177

112-
## clib.json
113-
114-
Example of a clib.json explicitly listing the source:
78+
## Clib.json
79+
Information about a clib project or a package is stored in `clib.json`.
80+
In a project that uses `clib` to install dependencies a typical `clib.json` will only contain the required dependencies.
81+
It may look something like:
82+
```json
83+
{
84+
"name": "Copy and Paste-Inator",
85+
"version": "0.4.2",
86+
"description": "Creates copies of yourself to do all of his waiting in lines for you.",
87+
"dependencies": {
88+
"clibs/buffer": "0.0.1",
89+
"clibs/term": "0.0.1",
90+
"jwerle/throw.h": "0.0.0"
91+
}
92+
}
93+
```
11594

95+
Packages that can be installed by `clib` should also provide a `clib.json`.
96+
It contains the files that should be installed by `clib` in `"src"`
97+
An example of a clib.json for a package may look like:
11698
```json
11799
{
118100
"name": "term",
@@ -123,20 +105,6 @@ $ clib install visionmedia/mon visionmedia/every visionmedia/watch
123105
"license": "MIT",
124106
"src": ["src/term.c", "src/term.h"]
125107
}
126-
```
127-
128-
Example of a clib.json for an executable:
129-
130-
```json
131-
{
132-
"name": "mon",
133-
"version": "1.1.1",
134-
"repo": "visionmedia/mon",
135-
"description": "Simple process monitoring",
136-
"keywords": ["process", "monitoring", "monitor", "availability"],
137-
"license": "MIT",
138-
"install": "make install"
139-
}
140108
```
141109

142110
See [explanation of clib.json](https://github.com/clibs/clib/wiki/Explanation-of-package.json) for more details.

BEST_PRACTICE.md renamed to Usage.md

+59-22
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
This page will cover:
44

55
- [How to use libraries](#how-to-use-installed-libraries-for-your-project).
6-
- [Example Makefile](#example-makefile).
7-
- [Example `package.json` for executables](#example-packagejson-for-executable-project).
6+
- [Example Makefile](#example-makefile).
7+
- [Example `clib.json` for executables](#example-packagejson-for-executable-project).
88
- [Making your own library package](#making-your-own-libraries).
9-
- [Example `package.json` for libraries](#example-packagejson-for-libraries).
9+
- [Example `clib.json` for libraries](#example-packagejson-for-libraries).
1010
- [How to install/uninstall executables](#install-and-uninstall-executables-packages).
11-
12-
For instructions on installation, check out the [README](https://github.com/clibs/clib#installation).
11+
- [How to fetch packages from other sources](#how-to-fetch-packages-from-other-sources).
1312

1413
## How to use installed libraries for your project
1514

@@ -22,25 +21,25 @@ your-project/
2221
│   ├── trim.c/
2322
│ │ ├── trim.h
2423
│  │   ├── trim.c
25-
│ │ └── package.json
24+
│ │ └── clib.json
2625
│ │
2726
│ ├── commander/
2827
│ │ ├─ commander.h
2928
│ │ ├─ commander.c
30-
│ │ └─ package.json
29+
│ │ └─ clib.json
3130
│ │
3231
│ └── logger/
3332
│ ├── logger.h
3433
│ ├── logger.c
35-
│ └── package.json
34+
│ └── clib.json
3635
3736
├── LICENSE
3837
3938
├── Makefile
4039
4140
├── README.md
4241
43-
├── package.json
42+
├── clib.json
4443
4544
└── src/
4645
   ├── main.c
@@ -102,11 +101,11 @@ This is a basic Makefile, and should work for most of your projects.
102101
You *could* have your Makefile install the libraries upon running it, but you
103102
would only need to do that to get the latest version of the library(s), in this
104103
case you probably don't want that. You typically want yo get the latest stable version
105-
for that library. By having a `package.json` file in your project repo, you can
104+
for that library. By having a `clib.json` file in your project repo, you can
106105
specify what packages you need, and what version of that package. Now have a look
107-
at a example `package.json` file for your project: (executable package)
106+
at a example `clib.json` file for your project: (executable package)
108107

109-
### Example package.json for executable project
108+
### Example clib.json for executable project
110109

111110
```json
112111
{
@@ -125,13 +124,13 @@ at a example `package.json` file for your project: (executable package)
125124

126125
Starting from the top, `"name"` is your package name. `"version"` is your package version. `"repo"` is the location of your project, (not including the `https://github.com/`). `"dependencies"` is all the dependencies your project requires, along with there version. `"install"` is the command to install your program (ran as root), (tip: if your project requires more then one command to install it, like need to run `./configure`, before `make`, then do this: `"install": "./configure && make && make install"`). `"uninstall"` is the command to uninstall your project, [more on that later](#install-and-uninstall-executables).
127126

128-
_**NOTE:** Make sure you have a release as the same version in your `package.json` file, otherwise the download will fail. If you always want your package at the latest version, then put `master` as your version._
127+
_**NOTE:** Make sure you have a release as the same version in your `clib.json` file, otherwise the download will fail. If you always want your package at the latest version, then put `master` as your version._
129128

130129
## Making your own libraries
131130

132-
Now that you know how to use libraries, heres how to make your own:
131+
Now that you know how to use libraries, here is how to make your own:
133132

134-
Like before, heres a typical project directory tree:
133+
Like before, a typical project directory tree:
135134

136135
```
137136
your-library-c/
@@ -140,20 +139,20 @@ your-library-c/
140139
│   ├── path-join.c/
141140
│ │ ├── path-join.h
142141
│  │   ├── path-join.c
143-
│ │ └── package.json
142+
│ │ └── clib.json
144143
│ │
145144
│ └── strdup/
146145
│ ├─ strdup.h
147146
│ ├─ strdup.c
148-
│ └─ package.json
147+
│ └─ clib.json
149148
150149
├── LICENSE
151150
152151
├── Makefile
153152
154153
├── README.md
155154
156-
├── package.json
155+
├── clib.json
157156
158157
├── src/
159158
│   ├── library.c
@@ -165,11 +164,11 @@ your-library-c/
165164

166165
Also like before, your have a `deps` directory (depending on your library, you may not need any
167166
dependencies). Your `Makefile` in this case it is only for the `test.sh`, not needed for installing.
168-
`package.json` contains your library name, dependencies (if you need them), keywords, etc... In
167+
`clib.json` contains your library name, dependencies (if you need them), keywords, etc... In
169168
`src/` contains your make code (usally the same name as your library). And you have your `test.sh`
170169
used for testing.
171170

172-
### Example package.json for libraries
171+
### Example clib.json for libraries
173172

174173
```
175174
{
@@ -194,14 +193,14 @@ used for testing.
194193
}
195194
```
196195

197-
The main differences (between this, and the executable `package.json`), is now there is `"src"`,
196+
The main differences (between this, and the executable `clib.json`), is now there is `"src"`,
198197
this is where your make library source code is, your can change it, but src is petty standard.
199198

200199
**TIP:** In the `"dependencies"` section, if you define `"*"` as the version, clib will install
201200
the latest version of that library.
202201

203202
_**NOTE:** Just like your executable package, you will want to tag a release with the same name
204-
as your version specified in your `package.json`._
203+
as your version specified in your `clib.json`._
205204

206205
## Install and uninstall executables packages
207206

@@ -230,3 +229,41 @@ $ sudo clib-uninstall visionmedia/mon
230229
```
231230

232231
<br>
232+
233+
## How to fetch packages from other sources
234+
By default `clib` uses the [listing of packages](https://github.com/clibs/clib/wiki/Packages) as the place to look for packages, the registry, and [github.com](https://github.com) for downloading packages.
235+
You can specify additional registries and download from other repositories than github.
236+
This might be useful when using `clib` to install a mix of private and public packages.
237+
238+
### Adding additional registries
239+
Additional registries can be provided in the `clib.json` of a project.
240+
Currently github wiki's and gitlab &mdash; both [gitlab.com](https://www.gitlab.com) and self hosted &mdash; are supported.
241+
For gitlab the format is a bit complicated as it has to conform to the gitlab api.
242+
You should use the same format as the default registry but in a file in a repository instead of in a wiki.
243+
```json
244+
{
245+
// other definitions
246+
"registries": [
247+
"https://gitlab.com/api/v4/projects/25447829/repository/files/README.md/raw?ref=master",
248+
"https://github.com/awesome-org/clib/wiki/Packages"
249+
]
250+
}
251+
```
252+
253+
_**CAUTION:** For gitlab, the url should be of the form `/project/<id>` and not `/group/repo` check [my-gitlab-registry](https://gitlab.com/nouwaarom/my-clib-registry) for an example._
254+
255+
### Downloading from gitlab or private sources
256+
To download from some sources, authentication might be required.
257+
To facilitate this `clib_secrets.json` is used to store the credentials.
258+
259+
```json
260+
{
261+
"github.com": "GITHUB_API_TOKEN",
262+
"github.example.com": "GITLAB_USER_TOKEN"
263+
}
264+
```
265+
266+
Gitlab always requires a secret in order to use the API.
267+
The secret can be obtained by clicking your profile and then (Preferences -> Access Tokens) and create a token with only `read_repository` rights.
268+
269+
_**TIP:** To prevent accidentally commiting your secrets add `clib_secrets.json` to `.gitignore` and use `clib_secrets.json.dist` to specify for which domains a secret is required._

0 commit comments

Comments
 (0)