Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/build without root #74

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -401,5 +401,10 @@ FodyWeavers.xsd

## Distrod

# Old
rootfs
rootfs.tar.gz

# Updated 2022-09-24
opt_distrod.tar.gz
distrod_root.tar.gz
26 changes: 26 additions & 0 deletions .help.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Adapted from https://gist.github.com/prwhite/8168133

# COLORS
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)


TARGET_MAX_CHAR_NUM=20
## Show help
help:
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
OUTPUT_ROOTFS_PATH ?= distrod/distrod_wsl_launcher/resources/distrod_root.tar.gz

build: distrod-release
## Make program and Linux opt_distrod.tar.gz release
distrod: distrod-release

distrod-release: distrod-bins distrod/target/release/portproxy.exe
./distrod_packer/distrod_packer ./distrod opt_distrod.tar.gz --pack-distrod-opt-dir

## Make rootfs for installation from Windows
rootfs: distrod-bins distrod/target/release/portproxy.exe
./distrod_packer/distrod_packer ./distrod $(OUTPUT_ROOTFS_PATH)

distrod-release: distrod-bins distrod/target/release/portproxy.exe
./distrod_packer/distrod_packer ./distrod opt_distrod.tar.gz --pack-distrod-opt-dir
## Make distrod and rootfs
all: distrod rootfs

distrod-bins:
cd distrod; cargo build --release -p distrod -p distrod-exec -p portproxy
Expand All @@ -28,11 +33,13 @@ integration-test-linux-all-distros:
DISTRO_TO_TEST=$${distro} ./test_runner.sh run; \
done

## Run tests on Linux
test-linux: lint unit-test-linux integration-test-linux

lint:
shellcheck install.sh

## Remove build files
clean:
cd distrod; cargo clean; cargo.exe clean

Expand All @@ -46,5 +53,8 @@ include windows.mk
.PHONY: $(ROOTFS_PATH)
endif

.PHONY: build rootfs distrod-release distrod-bins lint clean\
.PHONY: all distrod rootfs distrod-release distrod-bins lint clean\
unit-test-linux enter-integration-test-linux integration-test-linux integration-test-linux-all-distros test-linux

.DEFAULT_GOAL := help
include .help.mk
11 changes: 5 additions & 6 deletions distrod_packer/distrod_packer
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,13 @@ def make_distrod_distribution_dirs(work_dir: Path):
def set_permissions(work_dir: Path):
dir_to_back = os.getcwd()
os.chdir(work_dir)
os.system("sudo chmod 755 .")
os.system("sudo chown -R root:root .")
os.system("chmod 755 .")
os.chdir(dir_to_back)


def set_suid(bin_path: Path):
os.system(f"sudo chmod u+s {bin_path}")
os.system(f"sudo chmod g+s {bin_path}")
os.system(f"chmod u+s {bin_path}")
os.system(f"chmod g+s {bin_path}")


def copy_distrod_distribution_resources(work_dir: Path):
Expand Down Expand Up @@ -281,7 +280,7 @@ def run_cargo_about(workspace_path: Path, out_path: Path):
def compress_entire_tree(tree: Path, output_path: Path):
dir_to_back = os.getcwd()
os.chdir(tree)
os.system("sudo tar czf compressed.tar.gz *")
os.system("tar --owner=root --group=root -czf compressed.tar.gz *")
shutil.copy(tree.joinpath("compressed.tar.gz"), output_path)
os.chdir(dir_to_back)

Expand All @@ -290,7 +289,7 @@ def make_dir_deletable(tree: Path):
dir_to_back = os.getcwd()
os.chdir(tree)
# Let the directory able to be deleted
os.system("sudo chown -R $(whoami):$(whoami) .")
os.system("chown -R $(whoami):$(whoami) .")
os.chdir(dir_to_back)


Expand Down