diff --git a/Makefile b/Makefile index b3b788031..019a671d8 100644 --- a/Makefile +++ b/Makefile @@ -28,26 +28,44 @@ rebuild: rm -rf $(BUILD)/repo.tag $(BUILD)/harddrive.img $(BUILD)/redox-live.iso $(MAKE) all -clean: $(CONTAINER_TAG) +# To tell that it's not safe +# to execute the cookbook binary +NOT_ON_PODMAN?=0 + +clean: ifeq ($(PODMAN_BUILD),1) +ifneq ("$(wildcard $(CONTAINER_TAG))","") $(PODMAN_RUN) make $@ else + $(info will not run cookbook clean as container is not built) + $(MAKE) clean PODMAN_BUILD=0 NOT_ON_PODMAN=1 +endif # CONTAINER_TAG +else +ifneq ($(NOT_ON_PODMAN),1) $(MAKE) c.--all - -rm -rf cookbook/repo - $(MAKE) fstools_clean - $(HOST_CARGO) clean --manifest-path relibc/Cargo.toml -endif -$(FUMOUNT) $(BUILD)/filesystem/ || true -$(FUMOUNT) /tmp/redox_installer/ || true +endif # NOT_ON_PODMAN + rm -rf cookbook/repo + rm -rf relibc/target rm -rf $(BUILD) $(PREFIX) + $(MAKE) fstools_clean +endif # PODMAN_BUILD -distclean: $(CONTAINER_TAG) +distclean: ifeq ($(PODMAN_BUILD),1) +ifneq ("$(wildcard $(CONTAINER_TAG))","") $(PODMAN_RUN) make $@ else + $(info will not run cookbook unfetch as container is not built) + $(MAKE) distclean PODMAN_BUILD=0 NOT_ON_PODMAN=1 +endif # CONTAINER_TAG +else +ifneq ($(NOT_ON_PODMAN),1) $(MAKE) u.--all - $(MAKE) clean -endif +endif # NOT_ON_PODMAN + $(MAKE) clean NOT_ON_PODMAN=1 +endif # PODMAN_BUILD pull: git pull diff --git a/mk/config.mk b/mk/config.mk index 8cc578d4b..44c20a484 100644 --- a/mk/config.mk +++ b/mk/config.mk @@ -46,6 +46,7 @@ CONTAINERFILE?=podman/redox-base-containerfile export NPROC=nproc export REDOX_MAKE=make +ifneq ($(PODMAN_BUILD),1) HOST_TARGET := $(shell env -u RUSTUP_TOOLCHAIN rustc -vV | grep host | cut -d: -f2 | tr -d " ") # x86_64 linux hosts have all toolchains ifneq ($(HOST_TARGET),x86_64-unknown-linux-gnu) @@ -60,6 +61,7 @@ ifneq ($(HOST_TARGET),x86_64-unknown-linux-gnu) PREFIX_BINARY=0 endif endif +endif ifeq ($(SCCACHE_BUILD),1) ifeq (,$(shell command -v sccache)) @@ -132,13 +134,13 @@ else endif BUILD=build/$(ARCH)/$(CONFIG_NAME) MOUNT_DIR=$(BUILD)/filesystem -HOST_FSTOOLS=build/fstools -INSTALLER=$(HOST_FSTOOLS)/bin/redox_installer +FSTOOLS=build/fstools +INSTALLER=$(FSTOOLS)/bin/redox_installer +REDOXFS=$(FSTOOLS)/bin/redoxfs +REDOXFS_MKFS=$(FSTOOLS)/bin/redoxfs-mkfs INSTALLER_OPTS= LIST_PACKAGES=installer/target/release/list_packages LIST_PACKAGES_OPTS= -REDOXFS=$(HOST_FSTOOLS)/bin/redoxfs -REDOXFS_MKFS=$(HOST_FSTOOLS)/bin/redoxfs-mkfs ifeq ($(REPO_BINARY),0) INSTALLER_OPTS+=--cookbook=cookbook else diff --git a/mk/disk.mk b/mk/disk.mk index 7cbae0d9e..092862d57 100644 --- a/mk/disk.mk +++ b/mk/disk.mk @@ -1,6 +1,9 @@ # Configuration file with the commands configuration of the Redox image $(BUILD)/harddrive.img: $(HOST_FSTOOLS) $(REPO_TAG) +ifeq ($(PODMAN_BUILD),1) + $(PODMAN_RUN) make $@ +else mkdir -p $(BUILD) rm -rf $@ $@.partial -$(FUMOUNT) /tmp/redox_installer || true @@ -11,8 +14,12 @@ $(BUILD)/harddrive.img: $(HOST_FSTOOLS) $(REPO_TAG) truncate -s "$$FILESYSTEM_SIZE"m $@.partial umask 002 && $(INSTALLER) $(INSTALLER_OPTS) -c $(FILESYSTEM_CONFIG) $@.partial mv $@.partial $@ +endif $(BUILD)/redox-live.iso: $(HOST_FSTOOLS) $(REPO_TAG) redox.ipxe +ifeq ($(PODMAN_BUILD),1) + $(PODMAN_RUN) make $@ +else mkdir -p $(BUILD) rm -rf $@ $@.partial -$(FUMOUNT) /tmp/redox_installer || true @@ -24,8 +31,12 @@ $(BUILD)/redox-live.iso: $(HOST_FSTOOLS) $(REPO_TAG) redox.ipxe umask 002 && $(INSTALLER) $(INSTALLER_OPTS) -c $(FILESYSTEM_CONFIG) --write-bootloader="$(BUILD)/bootloader-live.efi" --live $@.partial mv $@.partial $@ cp redox.ipxe $(BUILD)/redox.ipxe +endif $(BUILD)/filesystem.img: $(HOST_FSTOOLS) $(REPO_TAG) +ifeq ($(PODMAN_BUILD),1) + $(PODMAN_RUN) make $@ +else mkdir -p $(BUILD) -$(FUMOUNT) $(MOUNT_DIR) || true rm -rf $@ $@.partial $(MOUNT_DIR) @@ -45,27 +56,44 @@ $(BUILD)/filesystem.img: $(HOST_FSTOOLS) $(REPO_TAG) -$(FUMOUNT) $(MOUNT_DIR) || true rm -rf $(MOUNT_DIR) mv $@.partial $@ +endif mount: $(HOST_FSTOOLS) FORCE +ifeq ($(PODMAN_BUILD),1) + $(PODMAN_RUN) make $@ +else mkdir -p $(MOUNT_DIR) $(REDOXFS) $(BUILD)/harddrive.img $(MOUNT_DIR) sleep 2 pgrep redoxfs +endif mount_extra: $(HOST_FSTOOLS) FORCE +ifeq ($(PODMAN_BUILD),1) + $(PODMAN_RUN) make $@ +else mkdir -p $(MOUNT_DIR) $(REDOXFS) $(BUILD)/extra.img $(MOUNT_DIR) sleep 2 pgrep redoxfs +endif mount_live: $(HOST_FSTOOLS) FORCE +ifeq ($(PODMAN_BUILD),1) + $(PODMAN_RUN) make $@ +else mkdir -p $(MOUNT_DIR) $(REDOXFS) $(BUILD)/redox-live.iso $(MOUNT_DIR) sleep 2 pgrep redoxfs +endif unmount: FORCE +ifeq ($(PODMAN_BUILD),1) + $(PODMAN_RUN) make $@ +else sync -$(FUMOUNT) $(MOUNT_DIR) || true rm -rf $(MOUNT_DIR) -$(FUMOUNT) /tmp/redox_installer || true +endif diff --git a/mk/fstools.mk b/mk/fstools.mk index 325c3a863..b7c231fc4 100644 --- a/mk/fstools.mk +++ b/mk/fstools.mk @@ -3,34 +3,32 @@ fstools: $(FSTOOLS_TAG) $(HOST_FSTOOLS) # These tools run inside Podman if it is used, or on the host if Podman is not used -$(FSTOOLS_TAG): cookbook installer $(CONTAINER_TAG) +$(FSTOOLS): cookbook installer $(CONTAINER_TAG) ifeq ($(PODMAN_BUILD),1) $(PODMAN_RUN) make $@ else - $(HOST_CARGO) build --manifest-path cookbook/Cargo.toml --release - $(HOST_CARGO) build --manifest-path cookbook/pkgar/Cargo.toml --release - $(HOST_CARGO) build --manifest-path installer/Cargo.toml --bin list_packages --release - mkdir -p build - touch $@ -endif - -## The installer and redoxfs run on the host, even when using Podman build -$(HOST_FSTOOLS): installer redoxfs rm -rf $@ $@.partial mkdir -p $@.partial + $(HOST_CARGO) build --manifest-path cookbook/Cargo.toml --release + $(HOST_CARGO) build --manifest-path cookbook/pkgar/Cargo.toml --release $(HOST_CARGO) install --root $@.partial --path installer --bin redox_installer $(HOST_CARGO) install --root $@.partial --path redoxfs --bin redoxfs --bin redoxfs-mkfs --bin redoxfs-resize mv $@.partial $@ touch $@ +endif -fstools_clean: FORCE $(CONTAINER_TAG) +## TODO: remove this +$(FSTOOLS_TAG): $(FSTOOLS) ifeq ($(PODMAN_BUILD),1) $(PODMAN_RUN) make $@ else - $(HOST_CARGO) clean --manifest-path cookbook/Cargo.toml - $(HOST_CARGO) clean --manifest-path cookbook/pkgar/Cargo.toml - $(HOST_CARGO) clean --manifest-path installer/Cargo.toml - $(HOST_CARGO) clean --manifest-path redoxfs/Cargo.toml - rm -rf $(HOST_FSTOOLS) - rm -f $(FSTOOLS_TAG) + touch $@ endif + +fstools_clean: FORCE + rm -rf cookbook/target + rm -rf cookbook/pkgar/target + rm -rf installer/target + rm -rf redoxfs/target + rm -rf $(FSTOOLS) + rm -f $(FSTOOLS_TAG) diff --git a/mk/podman.mk b/mk/podman.mk index 74364d5ee..1b50024d0 100644 --- a/mk/podman.mk +++ b/mk/podman.mk @@ -17,10 +17,10 @@ endif ## Podman Home Directory PODMAN_HOME?=$(ROOT)/build/podman ## Podman command with its many arguments -PODMAN_VOLUMES?=--volume $(ROOT):$(CONTAINER_WORKDIR)$(PODMAN_VOLUME_FLAG) --volume $(PODMAN_HOME):/home$(PODMAN_VOLUME_FLAG) -PODMAN_ENV?=--env PATH=/home/poduser/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin --env PODMAN_BUILD=0 +PODMAN_VOLUMES?=--volume $(ROOT):$(CONTAINER_WORKDIR)$(PODMAN_VOLUME_FLAG) --volume $(PODMAN_HOME):/root$(PODMAN_VOLUME_FLAG) +PODMAN_ENV?=--env PATH=/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin --env PODMAN_BUILD=0 PODMAN_CONFIG?=--env ARCH=$(ARCH) --env BOARD=$(BOARD) --env CONFIG_NAME=$(CONFIG_NAME) --env FILESYSTEM_CONFIG=$(FILESYSTEM_CONFIG) --env REPO_APPSTREAM=$(REPO_APPSTREAM) --env REPO_NONSTOP=$(REPO_NONSTOP) --env REPO_OFFLINE=$(REPO_OFFLINE) --env CI=$(CI) -PODMAN_OPTIONS?=--rm --workdir $(CONTAINER_WORKDIR) --userns keep-id --user `id -u` --interactive --tty --env TERM=$(TERM) +PODMAN_OPTIONS?=--rm --workdir $(CONTAINER_WORKDIR) --interactive --tty --cap-add SYS_ADMIN --device /dev/fuse --network=host --env TERM=$(TERM) PODMAN_RUN?=podman run $(PODMAN_OPTIONS) $(PODMAN_VOLUMES) $(PODMAN_ENV) $(PODMAN_CONFIG) $(IMAGE_TAG) container_shell: build/container.tag @@ -56,12 +56,12 @@ container_kill: FORCE build/container.tag: $(CONTAINERFILE) ifeq ($(PODMAN_BUILD),1) rm -f build/container.tag - @echo "If podman_home dir cannot be removed, remove with \"sudo rm\"." + -chmod -R 0700 $(PODMAN_HOME) || true -rm -rf $(PODMAN_HOME) || true -podman image rm --force $(IMAGE_TAG) || true mkdir -p $(PODMAN_HOME) @echo "Building Podman image. This may take some time." - sed s/_UID_/`id -u`/ $(CONTAINERFILE) | podman build --file - $(PODMAN_VOLUMES) --tag $(IMAGE_TAG) + cat $(CONTAINERFILE) | podman build --file - $(PODMAN_VOLUMES) --tag $(IMAGE_TAG) @echo "Mapping Podman user space. Please wait." $(PODMAN_RUN) bash -e podman/rustinstall.sh mkdir -p build diff --git a/mk/prefix.mk b/mk/prefix.mk index 561572113..f4e3860ab 100644 --- a/mk/prefix.mk +++ b/mk/prefix.mk @@ -70,7 +70,10 @@ $(PREFIX)/relibc-install.tar.gz: $(PREFIX)/relibc-install --directory="$<" \ . -$(PREFIX)/libtool: +$(PREFIX)/libtool: | $(CONTAINER_TAG) +ifeq ($(PODMAN_BUILD),1) + $(PODMAN_RUN) make $@ +else rm -rf "$@.partial" "$@" mkdir -p "$@.partial" @@ -85,8 +88,9 @@ $(PREFIX)/libtool: touch "$@.partial" echo $(LIBTOOL_VERSION) > $@.partial/.tarball-version mv "$@.partial" "$@" +endif -$(PREFIX)/libtool-build: $(PREFIX)/libtool $(PREFIX)/rust-install +$(PREFIX)/libtool-build: $(PREFIX)/libtool $(PREFIX)/rust-install $(CONTAINER_TAG) ifeq ($(PODMAN_BUILD),1) $(PODMAN_RUN) make $@ else @@ -100,7 +104,7 @@ else --gnulib-srcdir=./gnulib PATH="$(ROOT)/$(PREFIX)/rust-install/bin:$$PATH" && \ cd "$@.partial" && \ - cp -rp $(abspath $<)/. ./ && \ + cp -r $(abspath $<)/. ./ && \ "$(ROOT)/$> ~/.bashrc - # source the variables so that we can execute rustup commands in the current shell - source ~/.cargo/env - else - echo "Rustup will not be installed!" - fi - fi - if [ -z "$(which rustc)" ]; then - echo "Rust is not installed" - echo "Please either run the script again, accepting rustup install" - echo "or install rustc stable manually (not recommended) via:" - echo "\#curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --channel=stable" - exit 1 - else - echo "Your Rust install looks good!" - fi -} - -#################################################################### -# This function gets the current build status from travis and prints -# a message to the user -#################################################################### -statusCheck() -{ - for i in $(echo "$(curl -sf https://api.travis-ci.org/repositories/redox-os/redox.json)" | tr "," "\n") - do - if echo "$i" | grep -iq "last_build_status" ;then - if echo "$i" | grep -iq "0" ;then - echo - echo "********************************************" - echo "Travis reports that the last build succeeded!" - echo "Looks like you are good to go!" - echo "********************************************" - elif echo "$i" | grep -iq "null" ;then - echo - echo "******************************************************************" - echo "The Travis build did not finish, this is an error with its config." - echo "I cannot reliably determine whether the build is succeeding or not." - echo "Consider checking for and maybe opening an issue on gitlab" - echo "******************************************************************" - else - echo - echo "**************************************************" - echo "Travis reports that the last build *FAILED* :(" - echo "Might want to check out the issues before building" - echo "**************************************************" - fi - fi - done -} - ########################################################################### # This function is the main logic for the bootstrap; it clones the git repo # then it installs the dependent packages @@ -618,22 +508,19 @@ boot() echo "---------------------------------------" echo "Well it looks like you are ready to go!" echo "---------------------------------------" - statusCheck echo "The file redox/.config was created with PODMAN_BUILD=1." + echo "If you need a much quicker installation, run: " + echo " echo REPO_BINARY=1 >> redox/.config" echo - echo "** Be sure to update your path to include Rust - run the following command: **" - echo 'source $HOME/.cargo/env' - echo - echo "Run the following commands to build redox using Podman:" + echo "Run the following commands to build Redox using Podman:" echo echo "cd redox" MAKE="make" if [[ "$(uname)" == "FreeBSD" ]]; then MAKE="gmake" - echo "kldload fuse.ko # This loads the kernel module for FUSE" fi echo "$MAKE all" - echo "$MAKE virtualbox or qemu" + echo "$MAKE $emulator" echo echo " Good luck!" @@ -645,10 +532,6 @@ if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then elif [ "$1" == "-u" ]; then git pull upstream master git submodule update --recursive --init - rustup update nightly - exit -elif [ "$1" == "-s" ]; then - statusCheck exit fi @@ -664,15 +547,12 @@ do d) dependenciesonly=true;; u) update=true;; h) usage;; - s) statusCheck && exit;; \?) echo "I don't know what to do with that option, try -h for help"; exit 1;; esac done banner -rustInstall "$noninteractive" - if [ "$update" == "true" ]; then git pull upstream master git submodule update --recursive --init