Skip to content

Commit

Permalink
Adjustments to android-store scripts (#990)
Browse files Browse the repository at this point in the history
* Fixing android store issues as we walked through creating some new keys
  • Loading branch information
alexcottner authored Sep 25, 2024
1 parent 10dc3b8 commit 30fa5be
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
25 changes: 15 additions & 10 deletions tools/android-store/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ MAKEFLAGS = --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules

RAM_DISK ?= /tmp/ramdisk
IN_CONTAINER := $(shell test "$$(cat /proc/self/cgroup | cut -d: -f3 | sort -u )" == "/" && echo false || echo true)
RD_PATH := $(shell $(IN_CONTAINER) && echo /secrets || echo $(RAM_DISK))
RD_PATH := /secrets

CONTAINER_VERSION ?= latest
# for testing, use 'autograph-app' for the locally build image from
Expand All @@ -30,6 +29,10 @@ PRIVATE_KEY ?= ../$(APP_NAME)-private-key.pem
PUBLIC_CERT ?= ../$(APP_NAME)-signing-cert.pem
WRAP_KEY ?= ../encryption_public_key.pem

# The user and group id for the app user, Magic numbers from our Dockerfile
DOCKER_USER_ID = 10001
DOCKER_GROUP_ID = 10001


##################################################################################
#
Expand All @@ -38,7 +41,6 @@ WRAP_KEY ?= ../encryption_public_key.pem
##################################################################################
.PHONY: status
status: _check-prerequisites _check-for-pepk ## Report on readiness to perform tasks
@echo "In container: $(IN_CONTAINER)"
@echo "Using ramdisk at $(RD_PATH)"

.PHONY: _check-for-pepk
Expand All @@ -51,8 +53,6 @@ _check-prerequisites: # Verify utilities available
@type -ap openssl &>/dev/null || { echo "ERROR: Missing openssl" ; false ; }
@type $(SCRIPT) &>/dev/null || { echo "ERROR: not available $(SCRIPT)" ; false ; }
@test -w $(RD_PATH)/t || { echo "ERROR: $(RD_PATH)/t is not writable (try: make setup-ramdisk)" ; false ; }
@{ ! $(IN_CONTAINER) && type -ap docker &>/dev/null ; } || { echo "ERROR: docker not available" ; false ; }
@$(IN_CONTAINER) || echo "Warning: not running in a container"

.PHONY: download-pepk
download-pepk: $(PEPK) ## Download pepk.jar
Expand All @@ -63,15 +63,20 @@ $(PEPK):
@echo Downloaded to $(PEPK)

.PHONY: setup-ramdisk
setup-ramdisk: $(RD_PATH)/t ## Create a container writeable directory
$(RD_PATH)/t:
@mkdir $@
@chmod a+w $@
setup-ramdisk: $(RD_PATH) ## Create a container writeable directory
$(RD_PATH):
mkdir -p $(RAM_DISK)
sudo mount -t ramfs -o size=10m myramdisk $(RAM_DISK)
sudo chown $(DOCKER_USER_ID):$(DOCKER_GROUP_ID) $(RAM_DISK)
@echo "Container writeable directory configured"

.PHONY: teardown-ramdisk
teardown-ramdisk: ## Destroy the container writeable directory
sudo umount $(RAM_DISK)
sudo rm -rf $(RAM_DISK)

.PHONY: docker-run
docker-run: ## Start docker container (from host)
@! $(IN_CONTAINER) || { echo "ERROR: already in container" ; false ; }
docker run -it --rm \
-v $(RAM_DISK):/secrets \
$(CONTAINER_IMAGE):$(CONTAINER_VERSION) \
Expand Down
5 changes: 1 addition & 4 deletions tools/android-store/start-container-shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ function make() {
command make --makefile="${makefile}" "$@"
}
export -f make
# and add completion for targets to our ~/.bashrc to make life easier
cat >>~/.bashrc <<EOF
complete -W "\`grep -oE '^[a-zA-Z0-9_-]+:([^=]|$)' "${makefile}" | sed 's/[^a-zA-Z0-9_-]*$//'\`" make
EOF

# and put that dir on the path
export PATH="${prog_dir}":$PATH
Expand All @@ -53,6 +49,7 @@ if test -d "${RAM_DISK}"; then
else
RAM_DISK=/secrets
fi
mkdir -p ${RAM_DISK}/t
cd "${RAM_DISK}/t"

# and give the user a shell
Expand Down

0 comments on commit 30fa5be

Please sign in to comment.