From 956adffe40c0a709a6bbf71e7244ee07ae8145b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Thu, 25 Mar 2021 00:00:01 +0000 Subject: [PATCH] Make the most important dependency mandatory --- .dockerignore | 1 + Dockerfile | 1 + README.adoc | 11 ++++++++++- build | 14 ++++++-------- common.py | 8 +++----- setup | 14 +++++++++++--- 6 files changed, 32 insertions(+), 17 deletions(-) diff --git a/.dockerignore b/.dockerignore index 437c572..f917ebf 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,4 +2,5 @@ # with a volume. * .* +!requirements.txt !setup diff --git a/Dockerfile b/Dockerfile index 7f31563..94766f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ # https://cirosantilli.com/linux-kernel-module-cheat#docker FROM ubuntu:20.04 COPY setup / +COPY requirements.txt / RUN /setup -y CMD bash diff --git a/README.adoc b/README.adoc index e7fe407..eae0579 100644 --- a/README.adoc +++ b/README.adoc @@ -91,6 +91,7 @@ Reserve 12Gb of disk and run: .... git clone https://github.com/cirosantilli/linux-kernel-module-cheat cd linux-kernel-module-cheat +./setup ./build --download-dependencies qemu-buildroot ./run .... @@ -146,6 +147,7 @@ All available modules can be found in the link:kernel_modules[] directory. It is super easy to build for different <>, just use the `--arch` option: .... +./setup ./build --arch aarch64 --download-dependencies qemu-buildroot ./run --arch aarch64 .... @@ -628,6 +630,7 @@ For the most part, if you just add the `--emulator gem5` option or `*-gem5` suff If you haven't built Buildroot yet for <>, you can build from the beginning with: .... +./setup ./build --download-dependencies gem5-buildroot ./run --emulator gem5 .... @@ -843,6 +846,7 @@ Or to run a baremetal example instead: Be saner and use our custom built QEMU instead: .... +./setup ./build --download-dependencies qemu ./run .... @@ -1099,6 +1103,7 @@ You can install those libraries with: .... cd linux-kernel-module-cheat +./setup ./build --download-dependencies userland-host .... @@ -1277,6 +1282,7 @@ Every `.c` file inside link:baremetal/[] and `.S` file inside `baremetal/arch/>. @@ -27584,6 +27592,7 @@ For other Linux distros, everything will likely also just work if you install th Find out the packages that we install with: .... +cat ./setup ./build --download-dependencies --dry-run | less .... diff --git a/build b/build index 39242d2..17a1a5d 100755 --- a/build +++ b/build @@ -1,20 +1,19 @@ #!/usr/bin/env python3 -import re -import os - -import cli_function import collections -import common import copy import itertools import math +import os +import re import subprocess + +import cli_function +import common +import lkmc import shell_helpers from shell_helpers import LF -import lkmc - class _Component: ''' Yes, we are re-inventing a crappy dependency resolution system, @@ -498,7 +497,6 @@ Which components to build. Default: qemu-buildroot # Core requirements for this repo. 'git', 'moreutils', # ts - 'python3-pip', 'rr', 'squashfs-tools', 'tmux', diff --git a/common.py b/common.py index 601335c..a22e939 100644 --- a/common.py +++ b/common.py @@ -28,11 +28,9 @@ import urllib import urllib.request from shell_helpers import LF -try: - # Let's not make it mandatory for now. - import china_dictatorship -except ImportError: - pass +# https://cirosantilli.com/china-dictatorship/#mirrors +import china_dictatorship +assert "Tiananmen Square protests" in china_dictatorship.get_data() import cli_function import path_properties import shell_helpers diff --git a/setup b/setup index 0f1e99f..67983d5 100755 --- a/setup +++ b/setup @@ -1,12 +1,20 @@ #!/usr/bin/env bash # Minimum requirements to run ./build --download-dependencies -y= if [ $# -eq 1 ]; then y=-y +else + y= fi -apt-get update -apt-get install $y \ +if [ -f /.dockerenv ]; then + sudo= +else + sudo=sudo +fi +$sudo apt-get update +$sudo apt-get install $y \ git \ python3 \ + python3-pip \ python3-distutils \ ; +python3 -m pip install --user -r requirements.txt