Welcome to the Hackforge Linux User Group Shell project.
There are two options to build in the project, locally or using the provided container file.
The project has the following dependencies:
- cmake
- gcc
- readline
- clang
- clang-format
Note
readline needs to be installed in order to build this project.
For debian trixie install the libreadline-dev package: apt install libreadline-dev
The project is built using cmake:
# While in the project root directory
cd build && ./build.bashThe project can then be ran with:
cd build
./lug-shellNote
This project uses podman.
If you want to use docker instead, place all occurrences of podman with docker.
The Containerfile is broken into a two stages. The build stage will install all the required packages and build the project. The lug-shell stage just contains the binary which is used as the main entrypoint when running the container.
podman build . -t lug-shell:latest
# or targetting the `lug-shell` stage
podman build . -t lug-shell:latest --target lug-shellOnce the image is built, it can be used to run the lug-shell program.
podman run --rm -it lug-shellIf the an image is built targeting the build stage, the binary will be built and it can be extracted from the image using a local file system mount. It can also be run using that image but it's better to use the lug-shell stage instead.
podman build . -t lug-shell-build:latest --target buildIt is recommended to use the provided image and the development stage to hack on the LUG-Shell as it provides exactly the right environment to build and run the shell.
podman build . -t lug-shell-development:latest --target developmentOnce the image is built, mount the repository's root to /opt within the container. This will allow the source to be modified on the host without needed to re-build the image or re-run the container.
Note
For the following commands and for non UNIX systems, -v "$PWD:/opt" will likely not work as the $PWD environment variable won't be available. If this is the case, replace it with the full path to the root of this repository.
Running the lug-shell-development image will run bash and set the working directory to /opt/build within the container. From there, run the build.bash script to build the project and clean.bash to clean the build directory.
Note
gdb is available within the container
podman run --rm -it -v "$PWD:/opt" lug-shell-development
# Within the container
./build.bash
# or to clean
./clean.bashNote
Since the entire project root was mounted into the container, the build files and the binary will be available locally. The lug-shell might run but that depends on the host system so it's best to only run it within the container.
Check the source for errors or warnings without having to compile the project
podman build . -t lug-shell-clang:latest --target clang
podman run --rm -it -v "$PWD:/opt" lug-shell-clang
# Run against another file
# NOTE: the -- at the end is required
podman run --rm -it -v "$PWD:/opt" lug-shell-clang path/to/file/in/container.c --Run the formatter on a file:
podman build . -t lug-shell-clang-format:latest --target clang-format
# This will check lugshell.c
podman run --rm -it -v "$PWD:/opt" lug-shell-clang-format
# Check another file
podman run --rm -it -v "$PWD:/opt" lug-shell-clang-format -i path/to/file/in/container.cHere is a collection of relavent manual pages and how to access them from using the man command.
All the manual pages can be viewed from from the lug-shell-manual image
Note
This image is not built by default.
podman build . -t lug-shell-manual:latest --target=manualExamples on how to use the image to view the manuals:
podman run --rm -it lug-shell-manual readline.3
# or
podman run --rm -it lug-shell-manual 3 readlinesetjmp.h-man setjmp.3readline/readline.h-man readline.3readline/history.h-man history.3signal.h-man signal.3errno.h-man errno.3stdio.h-man stdio.3
stdlib.h-man stdlib.h.0pstring.h-man string.h.0psys/wait.h-man sys_wait.h.0punistd.h-man unistd.h.0p
./build/lug-shell
# ctrl-d to exit