Skip to content
This repository was archived by the owner on Feb 6, 2020. It is now read-only.

Commit 5c728b4

Browse files
authored
Merge pull request #31 from crush-157/consistent-install
recommend Docker as best practice
2 parents 834b1fa + a2cc963 commit 5c728b4

File tree

1 file changed

+79
-81
lines changed

1 file changed

+79
-81
lines changed

README.md

Lines changed: 79 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -23,47 +23,93 @@ from rpm packages or oci images.
2323
placed into a directory called `/read`. Ephemeral files such as pid files
2424
can be written to `/run`.
2525

26-
## Building `smith` ##
26+
## Building and Running `smith` ##
27+
28+
You can build and run `smith` either as:
29+
- A Docker image
30+
- A Binary
31+
32+
Both methods are described below, but __the Docker route is recommended__ as the simplest and easiest option.
33+
34+
### Docker based `smith` ###
35+
36+
#### Dependencies ####
37+
- Docker
38+
39+
#### Method ####
40+
1. Clone `smith`:
41+
42+
`git clone https://github.com/oracle/smith.git`
43+
44+
2. Build `smith` Docker image using the Dockerfile provided, optionally adding your own docker-repo-id to the tag:
45+
46+
`sudo docker build -t [<docker-repo-id>/]smith .`
47+
48+
3. Set up an alias (or script) to run `smith` from the command line:
49+
```
50+
smith(){
51+
sudo docker run -it --rm \
52+
--privileged -v $PWD:/write \
53+
-v cache:/var/cache \
54+
-v mock:/var/lib/mock [<docker-repo-id>/]smith $@
55+
}
56+
```
57+
You should now be able to start building microcontainers (see below).
58+
59+
### Binary `smith` ###
60+
2761

2862
[![wercker status](https://app.wercker.com/status/3795ec11f790da9b58d5acbdd1dafc9d/s/master "wercker status")](https://app.wercker.com/project/byKey/3795ec11f790da9b58d5acbdd1dafc9d)
2963

3064
Building can be done via the Makefile:
3165

3266
make
3367

34-
Build dependencies:
68+
#### Dependencies ####
69+
##### Build #####
70+
- Docker
71+
- Go
3572

36-
golang-bin
73+
To install go run `sudo yum install golang-bin` or `sudo apt install golang-go` as appropriate
3774

3875
Go dependencies are vendored in the vendor directory.
3976

40-
## Runtime dependencies ##
41-
42-
To build from rpms, smith requires:
43-
44-
mock
45-
46-
Although mock is used for rpm packaging, it can be installed on debian/ubuntu
47-
if you are willing to be a little tricky. Specifically you need at least mock
48-
1.2. Version 1.1.X will not work because the -r flag does not support abspath
49-
to the mock config file. Instructions for debian/ubuntu:
50-
51-
sudo apt-get install createrepo yum
52-
# At the time of this writing the below package is suitable and available
53-
# for download. Your milage may vary and we suggest finding an official
54-
# debian mock package that is 1.2 or 1.3.
55-
wget http://ftp.debian.org/debian/pool/main/m/mock/mock_1.3.2-1_all.deb
56-
sudo dpkg -i mock_1.3.2-1_all.deb
57-
usermod -a -G mock <your_username>
58-
# rpm on debian has a patch to macros that messes up mock so undo it. Note
59-
# that updating your os will sometimes reset this file and you will have
60-
# to run this command again.
61-
sudo sed -i 's;%_dbpath\t.*;%_dbpath\t\t%{_var}/lib/rpm;g' /usr/lib/rpm/macros
62-
# on debian/ubuntu for some reason yum tries to install packages for
63-
# multiple archs, so it is necessary to update the yum.conf section in
64-
# default.cfg to prevent that. If you switch your default.cfg you may
65-
# have to do this again.
66-
sudo sed -i '/\[main\]/a multilib_policy=best' /etc/mock/default.cfg
77+
##### Runtime #####
78+
79+
To build from RPMs, `smith` requires:
80+
81+
- mock
82+
83+
mock can have issues with non - RPM distros.
84+
85+
**If you have problems installing or running `smith` natively on a non - RPM distro, best advice is to build it and run it in a Docker container (see above)**
86+
87+
mock can be installed on Debian/Ubuntu with some extra care (see below). Specifically you need at least mock
88+
1.2. Version 1.1.X will not work because the -r flag does not support abspath to the mock config file.
89+
Be aware that your `smith` builds may still fail.
90+
91+
Debian/Ubuntu specific instructions (_Here be Dragons_):
92+
93+
```sudo apt install mock createrepo yum```
94+
95+
```
96+
# Fedora rawhide chroot (which mock uses by default) does not play well with
97+
# Debian, so point /etc/mock/default.cfg to EPEL 7 (6 on Ubuntu):
98+
sudo ln -s /etc/mock/epel-7-x86_64.cfg /etc/mock/default.cfg
99+
```
100+
```
101+
# rpm on Debian has a patch to macros that messes up mock so undo it. Note
102+
# that updating your os will sometimes reset this file and you will have
103+
# to run this command again.
104+
sudo sed -i 's;%_dbpath\t.*;%_dbpath\t\t%{_var}/lib/rpm;g' /usr/lib/rpm/macros
105+
```
106+
```
107+
# on debian/ubuntu for some reason yum tries to install packages for
108+
# multiple archs, so it is necessary to update the yum.conf section in
109+
# default.cfg to prevent that. If you switch your default.cfg you may
110+
# have to do this again.
111+
sudo sed -i '/\[main\]/a multilib_policy=best' /etc/mock/default.cfg
112+
```
67113

68114
Whichever distro you are using check that your user is a member of the group mock:
69115

@@ -77,19 +123,13 @@ On Oracle Linux edit your /etc/mock/site-defaults.cfg and add:
77123

78124
config_opts['use_nspawn'] = False
79125

80-
## Installing `smith` ##
126+
#### Installing `smith` ####
81127

82128
Installing can be done via the Makefile:
83129

84130
sudo make install
85131

86132

87-
## Installing `smith` using a Docker container ##
88-
89-
```bash
90-
docker build -t smith .
91-
```
92-
93133
## Using `smith` ##
94134

95135
To use smith, simply create a smith.yaml defining your container and run
@@ -100,9 +140,9 @@ If you are building the same container multiple times without editing the
100140
package line, the `-f` parameter will rebuild the container without
101141
reinstalling the package.
102142

103-
## Build ##
143+
## Building Microcontainers ##
104144

105-
To build a container with smith, create a smith.yaml file and invoke smith with no
145+
To build a container with `smith`, create a smith.yaml file and invoke smith with no
106146
parameters:
107147

108148
mkdir cat
@@ -121,48 +161,6 @@ parameters:
121161
echo "Hello World!" >rootfs/read/data
122162

123163
smith
124-
125-
## Build using a Docker container ##
126-
127-
Run the container mounting `smith.yaml` folder:
128-
129-
```bash
130-
mkdir cat
131-
cd cat
132-
133-
cat >smith.yaml <<EOF
134-
package: coreutils
135-
paths:
136-
- /usr/bin/cat
137-
cmd:
138-
- /usr/bin/cat
139-
- /read/data
140-
EOF
141-
142-
mkdir -p rootfs/read
143-
echo "Hello World!" >rootfs/read/data
144-
```
145-
146-
Build `smith.yml`:
147-
148-
```bash
149-
docker run -it --rm \
150-
--privileged -v $PWD:/write \
151-
-v cache:/var/cache \
152-
-v mock:/var/lib/mock vishvananda/smith
153-
```
154-
155-
156-
You can also use an alias to run smith commands from your host:
157-
158-
```bash
159-
smith(){
160-
docker run -it --rm \
161-
--privileged -v $PWD:/write \
162-
-v cache:/var/cache \
163-
-v mock:/var/lib/mock vishvananda/smith $@
164-
}
165-
```
166164

167165
Your image will be saved as image.tar.gz. You can change the name with a
168166
parameter:

0 commit comments

Comments
 (0)