aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2025-09-15 20:03:57 +0800
committerMistivia <i@mistivia.com>2025-09-15 20:03:57 +0800
commit99329b886e8790127600fbd8c6ea876ee8c2cda6 (patch)
treeb09807906573a16cb8d63a6f9062c43536a14074
parent390aa6e04717cb99d4456f72b196b6139564bd13 (diff)
add docker build script
-rw-r--r--Makefile7
-rw-r--r--build-docker.sh9
-rw-r--r--scripts/build-docker.sh10
-rwxr-xr-xscripts/create_rootfs.sh40
4 files changed, 56 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index e7c5cc3..95e41c2 100644
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,11 @@ TARGET := ezlive
all: $(TARGET)
+docker: ezlive-docker-image.tar.gz
+
+ezlive-docker-image.tar.gz: all
+ sh ./scripts/build-docker.sh
+
$(TARGET): $(C_OBJS) $(CPP_OBJS)
$(CXX) $(C_OBJS) $(CPP_OBJS) -o $@ $(LDFLAGS)
@@ -28,4 +33,4 @@ $(TARGET): $(C_OBJS) $(CPP_OBJS)
clean:
rm -f $(C_OBJS) $(CPP_OBJS) $(TARGET)
-.PHONY: all clean \ No newline at end of file
+.PHONY: all clean
diff --git a/build-docker.sh b/build-docker.sh
deleted file mode 100644
index af9bb31..0000000
--- a/build-docker.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-sudo rm -rf rootfs
-mkdir rootfs
-mkdir rootfs/etc
-mkdir rootfs/etc/ezlive/
-create_rootfs.sh ezlive rootfs/
-cp ezlive rootfs/
-cp -L -r /etc/ssl rootfs/etc/
-sudo podman build -t ezlive .
-sudo podman save ezlive | gzip > ezlive-docker-image.tar.gz
diff --git a/scripts/build-docker.sh b/scripts/build-docker.sh
new file mode 100644
index 0000000..2979dd6
--- /dev/null
+++ b/scripts/build-docker.sh
@@ -0,0 +1,10 @@
+sudo rm -rf rootfs
+mkdir rootfs
+mkdir rootfs/etc
+mkdir rootfs/etc/ezlive/
+sh ./scripts/create_rootfs.sh ezlive rootfs/
+cp ezlive rootfs/
+cp -L -r /etc/ssl rootfs/etc/
+sudo docker build -t ezlive .
+sudo docker save localhost/ezlive | gzip > ezlive-docker-image.tar.gz
+sudo docker rmi localhost/ezlive
diff --git a/scripts/create_rootfs.sh b/scripts/create_rootfs.sh
new file mode 100755
index 0000000..4cf1740
--- /dev/null
+++ b/scripts/create_rootfs.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+copy_with_path() {
+ if [ "$#" -ne 2 ]; then
+ echo "Usage: copy_with_path_creation <source_file> <destination_base_path>"
+ return 1
+ fi
+
+ local source_file="$1"
+ local destination_base_path="$2"
+
+ local source_dir=$(dirname "$source_file")
+
+ local destination_dir="${destination_base_path}${source_dir}"
+
+ if mkdir -p "$destination_dir"; then
+ echo "Created directory: $destination_dir"
+ if cp "$source_file" "$destination_dir/"; then
+ echo "Copied file: $source_file to $destination_dir/"
+ return 0
+ else
+ echo "Error: Failed to copy file $source_file to $destination_dir/"
+ return 1
+ fi
+ else
+ echo "Error: Failed to create directory $destination_dir"
+ return 1
+ fi
+}
+
+if [ "$#" -ne 2 ]; then
+ echo "Usage: copyldd <target_exec> <dest_dir>"
+ exit 1
+fi
+
+for f in $(ldd $1 | grep "=>" | awk '{print $3}') ; do
+ copy_with_path $f $2
+done
+
+cp -r $2/usr/lib64 $2/