Compare commits
No commits in common. "d44d8ddd8ca47adcaed7a09b1b951dec43d18028" and "1662776d6b3aba14fde091ec30f1ab53768d67ba" have entirely different histories.
d44d8ddd8c
...
1662776d6b
2 changed files with 22 additions and 65 deletions
52
Makefile
52
Makefile
|
@ -1,52 +0,0 @@
|
||||||
NAME := qemush
|
|
||||||
|
|
||||||
# qemu Unix user
|
|
||||||
QEMU_USER := qemu
|
|
||||||
# sudo as qemu
|
|
||||||
SUDO_QEMU := sudo -u $(QEMU_USER)
|
|
||||||
|
|
||||||
QEMUSH := /usr/local/bin/$(NAME)
|
|
||||||
SRC_QEMUSH := bin/$(NAME)
|
|
||||||
|
|
||||||
# This repo's equivalent of effective qemu Unix user home
|
|
||||||
SRC_QEMU_HOME := qemu
|
|
||||||
SRC_QEMU_BIN := $(SRC_QEMU_HOME)/bin
|
|
||||||
# Actual qemu Unix user home
|
|
||||||
QEMU_HOME := $(shell echo ~$(QEMU_USER))
|
|
||||||
QEMU_BIN := $(QEMU_HOME)/bin
|
|
||||||
|
|
||||||
# Names of all qemush modules
|
|
||||||
SRC_MODULES_NAMES := $(notdir $(wildcard $(SRC_QEMU_BIN)/*))
|
|
||||||
# Target location of modules
|
|
||||||
MODULES := $(addprefix $(QEMU_BIN)/,$(SRC_MODULES_NAMES))
|
|
||||||
# Mode to apply
|
|
||||||
BINS_MODE := 740
|
|
||||||
|
|
||||||
# Compiler options
|
|
||||||
CC := cc
|
|
||||||
CC_OPTIONS = -O3
|
|
||||||
# C sources file format
|
|
||||||
SRC_FMT := c
|
|
||||||
# Names of C programs to compile
|
|
||||||
SRC_C_SOURCES_NAMES := $(notdir $(basename $(wildcard $(SRCD)/*.$(SRC_FMT))))
|
|
||||||
# Location of C binaries
|
|
||||||
C_BINARIES := $(addprefix $(QEMU_BIN)/,$(SRC_C_SOURCES_NAMES))
|
|
||||||
|
|
||||||
# Directories in ~qemu necessary for qemush to work
|
|
||||||
QEMUSH_DIRS_NAMES := bin launchers images
|
|
||||||
QEMUSH_DIRS := $(addprefix $(QEMU_HOME)/,$(QEMUSH_DIRS_NAMES))
|
|
||||||
|
|
||||||
all: $(QEMUSH_DIRS) $(MODULES) $(C_BINARIES) $(QEMUSH)
|
|
||||||
|
|
||||||
$(QEMUSH_DIRS):
|
|
||||||
$(SUDO_QEMU) mkdir -p $@
|
|
||||||
|
|
||||||
$(QEMUSH): $(SRC_QEMUSH)
|
|
||||||
sudo install -m 755 $^ $@
|
|
||||||
|
|
||||||
$(MODULES): $(QEMU_HOME)%: $(SRC_QEMU_HOME)%
|
|
||||||
$(SUDO_QEMU) install -m $(BINS_MODE) $^ $@
|
|
||||||
|
|
||||||
$(C_BINARIES): $(QEMU_BIN)%: $(SRCD)/%.$(SRC_FMT)
|
|
||||||
$(SUDO_QEMU) $(QEMU_USER) $(CC) $(CC_OPTIONS) -o $@ $^
|
|
||||||
$(SUDO_QEMU) chmod $(BINS_MODE) $@
|
|
35
README.md
35
README.md
|
@ -75,27 +75,36 @@ For ease of use, you need to grant every user in the `qemu` group via
|
||||||
`sudo` the right to execute commands as `qemu`. You can find an example
|
`sudo` the right to execute commands as `qemu`. You can find an example
|
||||||
`sudoers` rule in this repo's `etc/sudoers.d` folder.
|
`sudoers` rule in this repo's `etc/sudoers.d` folder.
|
||||||
|
|
||||||
### Via `Makefile` (recommended)
|
### Add `qemush` in the `PATH`
|
||||||
|
|
||||||
Just run the following command at the root of this repository to install
|
Use your preferred way to add the `qemush` script to a folder of `PATH`.
|
||||||
`qemush` (previous step is **mandatory**) :
|
Recommended: copy the script in `/usr/local/bin` to make it effortlessly
|
||||||
|
system wide.
|
||||||
|
|
||||||
|
### Add `qemush` modules in `~qemu/bin`
|
||||||
|
|
||||||
|
`qemush` needs reusable script modules like `diskpath` in its custom `bin`
|
||||||
|
folder located at `~qemu/bin`. You can add them directly via `qemush` from
|
||||||
|
this repo via the following command :
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
make
|
qemush do 'mkdir -p ~/bin && cp -v qemu/bin/* "$_"'
|
||||||
```
|
```
|
||||||
|
|
||||||
> And what if I don't want to bindly run this obscure `Makefile` ???
|
### Extra: add `first-free-port` in `PATH`
|
||||||
|
|
||||||
You'd be right. The next section is the exhaustive list of steps handled
|
`first-free-port` is a small C program designed accordingly to the Unix
|
||||||
by the `Makefile` for the installation process.
|
philosophy to show in `stdout` the first free (not listening) TCP port
|
||||||
|
after `argv[1]`, or `argv[1]` if it is free. You will need it to allocate
|
||||||
|
ports to protocols like SPICE in your launching scripts (example in
|
||||||
|
`qemu/bin/*-spice`).
|
||||||
|
|
||||||
### Manual installation (what does the `Makefile` do)
|
Example `qemush` command to add the program to a local `qemu` `bin` folder
|
||||||
|
:
|
||||||
|
|
||||||
- Create `images`, `launchers` and `bin` directories in `~qemu`
|
```sh
|
||||||
- Copy `qemush` scripts parts from `qemu/bin` in `~qemu/bin` with mode
|
qemush do 'mkdir ~/bin && cc -o "${_}/first-free-port" src/first-free-port.c'
|
||||||
`740`
|
```
|
||||||
- Compile C programs from `src` in `~qemu/bin` with mode `740`
|
|
||||||
- Copy `bin/qemush` to `/usr/local/bin/qemush` with mode `755`
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue