Browse Source

Switch to pkgconf. Add make and dnsutils to deb-based distro install. Move the build process from (docker commands in) lmk.devuan-chimaera.sh to a script inside the container: build-lmk.rc. Include a local copy of the dependencies script (install-minetest-build-deps.sh) in the container instead of the web copy.

master
poikilos 3 years ago
parent
commit
48df2468d5
  1. 1
      .gitignore
  2. 150
      containers/lmk.devuan-chimaera.sh
  3. 6
      containers/lmk.devuan-chimaera/Dockerfile
  4. 106
      containers/lmk.devuan-chimaera/build-lmk.sh
  5. 23
      containers/lmk.devuan-chimaera/lmk.rc
  6. 20
      install-minetest-build-deps.sh

1
.gitignore

@ -14,3 +14,4 @@ nohup.out
err.txt err.txt
*.continuified.tmp *.continuified.tmp
linux-minetest-kit.zip linux-minetest-kit.zip
/containers/lmk.devuan-chimaera/install-minetest-build-deps.sh

150
containers/lmk.devuan-chimaera.sh

@ -1,8 +1,7 @@
#!/bin/bash #!/bin/bash
# See https://nextbreakpoint.com/posts/article-compile-code-with-docker.html # See https://nextbreakpoint.com/posts/article-compile-code-with-docker.html
# sudo docker build -t lmk-devuan-chimaera-img dyne/devuan:chimaera # sudo docker build -t lmk-devuan-chimaera-img dyne/devuan:chimaera
me=lmk.devuan-chimera.sh docker_path="`sudo bash -c 'command -v docker'`"
docker_path="`sudo command -v docker`"
if [ ! -f "$docker_path" ]; then if [ ! -f "$docker_path" ]; then
cat <<END cat <<END
This script requires docker. For help, see This script requires docker. For help, see
@ -13,11 +12,30 @@ END
fi fi
container_name="lmk-devuan-chimaera" container_name="lmk-devuan-chimaera"
image_name="lmk-devuan-chimaera-img" image_name="lmk-devuan-chimaera-img"
docker_image_dir="lmk.devuan-chimaera"
if [ ! -d "$docker_image_dir" ]; then
echo "* $me must run from the directory containing the container image directory: $docker_image_dir"
exit 1
fi
container_build_blob=$docker_image_dir/linux-minetest-kit.zip
# ^ docker_image_dir has to be in the same directory as Dockerfile or
# the COPY command in the Dockerfile won't work.
source $image_name/project.rc source $docker_image_dir/lmk.rc
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
exit 1 exit 1
fi fi
me=lmk.devuan-chimaera.sh
if [ "@$DL_SRC_PATH" = "@" ]; then
# DL_SRC_PATH="$HOME/Downloads/$DL_SRC_NAME"
DL_SRC_PATH="$docker_image_dir"
# ^ $DL_SRC_PATH has to be in the same directory as Dockerfile or
# the COPY command in the Dockerfile won't work.
# The file should be added to .gitignore for the reason that it
# is in the repo in the docker image directory.
fi
# sudo docker image inspect $image_name > /dev/null # sudo docker image inspect $image_name > /dev/null
sudo docker image inspect $image_name --format "* docker is looking for the image..." sudo docker image inspect $image_name --format "* docker is looking for the image..."
@ -25,8 +43,8 @@ sudo docker image inspect $image_name --format "* docker is looking for the imag
# ^ Get matching images as a JSON list (where each has "Id" and other # ^ Get matching images as a JSON list (where each has "Id" and other
# metadata). # metadata).
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
if [ ! -d "$local_img_dir" ]; then if [ ! -d "$docker_image_dir" ]; then
echo "Error: \"$local_img_dir\" (local_img_dir for storing $SRC_URL) doesn't exist." echo "Error: \"$docker_image_dir\" (docker_image_dir for storing $SRC_URL) doesn't exist in \"`pwd`\"."
exit 1 exit 1
fi fi
@ -43,6 +61,12 @@ if [ $? -ne 0 ]; then
else else
echo "* using existing \"$container_build_blob\" to build the container image" echo "* using existing \"$container_build_blob\" to build the container image"
fi fi
cp ../install-minetest-build-deps.sh $docker_image_dir/
# ^ This copy of it is in .gitignore.
if [ $? -ne 0 ]; then
echo "Error: 'cp ../install-minetest-build-deps.sh $docker_image_dir/' failed."
exit 1
fi
move_back="false" move_back="false"
prerelease_path=~/Downloads/minetest.org/insider-prerelease/linux-minetest-kit-220509.zip prerelease_path=~/Downloads/minetest.org/insider-prerelease/linux-minetest-kit-220509.zip
if [ ! -f $container_build_blob ]; then if [ ! -f $container_build_blob ]; then
@ -56,7 +80,7 @@ if [ $? -ne 0 ]; then
fi fi
fi fi
fi fi
sudo docker build -t $image_name $local_img_dir sudo docker build -t $image_name $docker_image_dir
code=$? code=$?
if [ "@move_back" = "@true" ]; then if [ "@move_back" = "@true" ]; then
echo "mv \"$prerelease_path\" \"$container_build_blob\"" echo "mv \"$prerelease_path\" \"$container_build_blob\""
@ -97,8 +121,10 @@ How to use the image:
# ^ "run" is merely a combination of "create" and "start" # ^ "run" is merely a combination of "create" and "start"
sudo docker -w $contained_repo exec $container_name ls -l $contained_repos sudo docker -w $contained_repo exec $container_name ls -l $contained_repos
sudo docker -w $contained_repo exec $container_name $run_all_build_commands_script
# ^ Execute a command in a running container (exec shows an error if the container isn't running). # ^ Execute a command in a running container (exec shows an error if the container isn't running).
# This will not work if the run/start command that started the container isn't a command that keeps it open (runs indefinitely)! # This will not work if the run/start command that started the container isn't a command that keeps it open (runs indefinitely)!
# If you need a container that has changes after $run_all_build_commands_script runs, you must use the "commit" subcommand.
# w: working directory # w: working directory
sudo docker stop $container_name sudo docker stop $container_name
@ -142,113 +168,39 @@ fi
echo "container_Id=$container_Id" echo "container_Id=$container_Id"
END END
printf "starting the docker image..." echo "building within the container..."
# sudo docker start $container_name # sudo docker start $container_name
# ^ NOTE: start is useless here since it won't stay open unless the # ^ NOTE: start is useless here since it won't stay open unless the
# command is set to "bash" or something, which isn't desirable. # command is set to "bash" or something, which isn't desirable.
# Therefore, use run instead of exec below. # Therefore, use run instead of exec below.
# ^ output is $container_name # ^ output is $container_name
sudo docker run --name $container_name $image_name /opt/build-lmk.sh sudo docker run --name $container_name $image_name $run_all_build_commands_script
if [ $? -ne 0 ]; then
echo "FAILED"
exit 1
else
echo "OK"
fi
# ^ NOTE: start is useless here since it won't stay open unless the
# command is set to "bash" or something, which isn't desirable.
# Therefore, use run instead of exec below.
if [ "@$contained_repo" = "@" ]; then
echo "Error: contained_repo can't be blank or checking for its files in the container won't work."
exit 1
fi
contained_good_repo_flag_path="$contained_repo/$good_repo_flag_name"
# sudo docker exec $container_name ls $contained_repo
echo "* checking for $contained_good_repo_flag_path on the destination..."
sudo docker exec $container_name ls $contained_good_repo_flag_path > /dev/null
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
printf "NO...checking for unzip..." cat <<END
container_unzip="`sudo docker exec $container_name which unzip`" * building within the container FAILED
if [ "@$container_unzip" = "@" ]; then
echo "NO. Installing..."
# This should never happen if the Dockerfile was used.
sudo docker exec $container_name apt-get update
if [ $? -ne 0 ]; then exit 1; fi
sudo docker exec $container_name apt-get install -y unzip
if [ $? -ne 0 ]; then exit 1; fi
container_unzip="`sudo docker exec $container_name which unzip`"
if [ "@$container_unzip" = "@" ]; then
echo "Error: Installing unzip in the container did not succeed. Install unzip inside the container manually then try again, or extract linux-minetest-kit such that $contained_good_repo_flag_path exists."
exit 1
fi
else
echo "FOUND"
fi
# sudo docker container run $image_name unzip xvf $contained_arc -d $contained_repos
echo "* extracting $contained_arc"
sudo docker exec $container_name unzip $contained_arc -d $contained_repos
# -d: is destination, like -C or --directory for tar.
# -v: verbose (prevents extraction)
if [ $? -ne 0 ]; then
echo "Error: unzip failed within the container. Install unzip inside the container manually then try again, or extract linux-minetest-kit such that $contained_good_repo_flag_path exists."
exit 1
fi
else
echo "FOUND (already extracted)"
fi
# sudo docker exec $container_name ls $contained_repo > /dev/null
sudo docker exec $container_name ls $contained_good_repo_flag_path > /dev/null
if [ $? -ne 0 ]; then
echo "Error: extracting linux-minetest-kit.zip in the container didn't work. Extract linux-minetest-kit.zip to $contained_repos such that $contained_good_repo_flag_path exists in the container and try again."
exit 1
else
echo "* detected $contained_good_repo_flag_path (So the source directory is assumed to be ok)"
fi
- Update the image as follows:
sudo docker rm --force $container_name
sudo docker rmi $image_name
sudo docker image prune --force
# --force: Don't prompt for confirmation.
if [ "@$contained_user" = "@" ]; then - Then try again:
echo "Error: contained_user can't be blank, or checking for the user within the container will not work." $0
exit 1
fi
sudo docker exec $container_name id -u $contained_user END
if [ $? -ne 0 ]; then
printf "* creating $contained_user in container $container_name..."
sudo docker exec $container_name adduser --disabled-password --gecos "" $contained_user --home $contained_home
if [ $? -ne 0 ]; then
echo "FAILED"
exit 1 exit 1
else else
echo "OK" echo "* building within the container completed OK"
fi fi
else # ^ NOTE: start is useless here since it won't stay open unless the
echo "* using the $container_name container's existing contained_user: $contained_user" # command is set to "bash" or something, which isn't desirable.
fi # Therefore, use run instead of exec below.
# sudo docker container run --name $container_name $image_name ls $contained_repos
# sudo docker exec $container_name chown -R $contained_user $contained_repos
# ^ Usually you could do this, but run as root since this script is used to test the safety of linux-minetest-kit:
# sudo docker exec $container_name curl https://raw.githubusercontent.com/poikilos/EnlivenMinetest/master/install-minetest-build-deps.sh --output /opt/install-minetest-build-deps.sh
# sudo docker exec $container_name chmod +x $repo_build_assumptions_cmd
# sudo docker exec $container_name $repo_build_assumptions_cmd
# ^ moved to Dockerfile
echo "* building libraries using $repo_build_libs_cmd..." # - Run again as follows:
sudo docker exec -w $contained_src $container_name $repo_build_libs_cmd # sudo docker start $container_name
if [ $? -ne 0 ]; then exit 1; fi # ^ doesn't work (The script specified by "run" earlier doesn't run).
# echo "* building program using $repo_build_cmd..."
# sudo docker exec -w $contained_src $container_name $repo_build_cmd
if [ $? -ne 0 ]; then exit 1; fi
# -w: working directory
# How to use docker-compose (See <https://docs.docker.com/compose/>): # How to use docker-compose (See <https://docs.docker.com/compose/>):

6
containers/lmk.devuan-chimaera/Dockerfile

@ -3,10 +3,12 @@ FROM dyne/devuan:chimaera
COPY linux-minetest-kit.zip /opt COPY linux-minetest-kit.zip /opt
COPY lmk.rc /opt COPY lmk.rc /opt
COPY build-lmk.sh /opt COPY build-lmk.sh /opt
COPY install-minetest-build-deps.sh /opt
RUN apt-get update RUN apt-get update
RUN apt-get install -y unzip RUN apt-get install -y unzip
RUN apt-get install -y perl
RUN unzip /opt/linux-minetest-kit.zip -d /opt RUN unzip /opt/linux-minetest-kit.zip -d /opt
# RUN apt-get install -y sudo # RUN apt-get install -y sudo
RUN curl https://raw.githubusercontent.com/poikilos/EnlivenMinetest/master/install-minetest-build-deps.sh --output /opt/install-minetest-build-deps.sh # RUN curl https://raw.githubusercontent.com/poikilos/EnlivenMinetest/master/install-minetest-build-deps.sh --output /opt/install-minetest-build-deps.sh
RUN chmod +x /opt/install-minetest-build-deps.sh # RUN chmod +x /opt/install-minetest-build-deps.sh
RUN /opt/install-minetest-build-deps.sh RUN /opt/install-minetest-build-deps.sh

106
containers/lmk.devuan-chimaera/build-lmk.sh

@ -4,6 +4,112 @@ if [ $? -ne 0 ]; then
exit 1 exit 1
fi fi
source lmk.rc source lmk.rc
me=build-lmk.sh
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
exit 1 exit 1
fi fi
if [ "@$contained_repo" = "@" ]; then
echo "Error: contained_repo can't be blank or checking for its files in the container won't work."
exit 1
fi
# ls $contained_repo
echo "* checking for $contained_good_repo_flag_path on the destination..."
ls $contained_good_repo_flag_path > /dev/null
if [ $? -ne 0 ]; then
echo "NOT FOUND"
printf "Warning: the Docker image isn't up to date. Unzipping manually..."
printf "checking for unzip..."
container_unzip="`which unzip`"
if [ "@$container_unzip" = "@" ]; then
echo "NOT FOUND. Installing..."
# This should never happen if the Dockerfile was used.
apt-get update
if [ $? -ne 0 ]; then exit 1; fi
apt-get install -y unzip
if [ $? -ne 0 ]; then exit 1; fi
container_unzip="`which unzip`"
if [ "@$container_unzip" = "@" ]; then
echo "Error: Installing unzip in the container did not succeed. Install unzip inside the container manually then try again, or extract linux-minetest-kit such that $contained_good_repo_flag_path exists."
exit 1
fi
else
echo "FOUND"
fi
# sudo docker container run $image_name unzip xvf $contained_arc -d $contained_repos
echo "* extracting $contained_arc"
unzip $contained_arc -d $contained_repos
# -d: is destination, like -C or --directory for tar.
# -v: verbose (prevents extraction)
if [ $? -ne 0 ]; then
echo "Error: unzip failed within the container. Install unzip inside the container manually then try again, or extract linux-minetest-kit such that $contained_good_repo_flag_path exists."
exit 1
fi
else
echo "FOUND (already extracted)"
fi
# ls $contained_repo > /dev/null
ls $contained_good_repo_flag_path > /dev/null
if [ $? -ne 0 ]; then
echo "Error: extracting linux-minetest-kit.zip in the container didn't work. Extract linux-minetest-kit.zip to $contained_repos such that $contained_good_repo_flag_path exists in the container and try again."
exit 1
else
echo "* detected $contained_good_repo_flag_path (So the source directory is assumed to be ok)"
fi
if [ "@$contained_user" = "@" ]; then
echo "Error: contained_user can't be blank, or checking for the user within the container will not work."
exit 1
fi
id -u $contained_user
if [ $? -ne 0 ]; then
printf "* creating $contained_user in container $container_name..."
adduser --disabled-password --gecos "" $contained_user --home $contained_home
if [ $? -ne 0 ]; then
echo "FAILED"
exit 1
else
echo "OK"
fi
else
echo "* using the $container_name container's existing contained_user: $contained_user"
fi
# sudo docker container run --name $container_name $image_name ls $contained_repos
# chown -R $contained_user $contained_repos
# ^ Usually you could do this, but run as root since this script is used to test the safety of linux-minetest-kit:
# curl https://raw.githubusercontent.com/poikilos/EnlivenMinetest/master/install-minetest-build-deps.sh --output /opt/install-minetest-build-deps.sh
# chmod +x $repo_build_assumptions_cmd
# $repo_build_assumptions_cmd
# ^ moved to Dockerfile
if [ ! -d "$contained_repo" ]; then
echo "Error: \"$contained_repo\" doesn't exist."
exit 1
fi
echo "* building libraries using $repo_build_libs_cmd..."
cd "$contained_repo"
if [ $? -ne 0 ]; then exit 1; fi
$repo_build_libs_cmd
if [ $? -ne 0 ]; then exit 1; fi
echo
echo
echo
echo
echo
echo
echo "* building program using $repo_build_cmd..."
$repo_build_cmd
code=$?
if [ $code -ne 0 ]; then
echo "$repo_build_cmd FAILED (code $code)"
exit $code
fi

23
containers/lmk.devuan-chimaera/lmk.rc

@ -1,3 +1,4 @@
#!/bin/bash
contained_repos=/opt contained_repos=/opt
contained_arc="$contained_repos/linux-minetest-kit.zip" contained_arc="$contained_repos/linux-minetest-kit.zip"
# ^ This must always be in sync with "COPY linux-minetest-kit.zip /opt" in Dockerfile # ^ This must always be in sync with "COPY linux-minetest-kit.zip /opt" in Dockerfile
@ -10,24 +11,12 @@ fi
#if [ "@$DL_SRC_NAME" = "@" ]; then #if [ "@$DL_SRC_NAME" = "@" ]; then
DL_SRC_NAME=linux-minetest-kit.zip DL_SRC_NAME=linux-minetest-kit.zip
#fi #fi
local_img_dir="lmk.devuan-chimaera"
if [ ! -d "$local_img_dir" ]; then
echo "* $me must run from the directory containing the container image directory: $local_img_dir"
exit 1
fi
container_build_blob=$local_img_dir/linux-minetest-kit.zip
# ^ local_img_dir has to be in the same directory as Dockerfile or
# the COPY command in the Dockerfile won't work.
if [ "@$DL_SRC_PATH" = "@" ]; then
# DL_SRC_PATH="$HOME/Downloads/$DL_SRC_NAME"
DL_SRC_PATH="$local_img_dir"
# ^ $DL_SRC_PATH has to be in the same directory as Dockerfile or
# the COPY command in the Dockerfile won't work.
# The file should be added to .gitignore for the reason that it
# is in the repo in the docker image directory.
fi
good_repo_flag_name="mtcompile-program.pl" good_repo_flag_name="mtcompile-program.pl"
repo_build_assumptions_cmd="/opt/install-minetest-build-deps.sh" repo_build_assumptions_cmd="/opt/install-minetest-build-deps.sh"
repo_build_libs_cmd="./mtcompile-libraries.sh" repo_build_libs_cmd="bash -e ./mtcompile-libraries.sh build"
repo_build_cmd="./mtcompile-program.pl --build --classic --client" repo_build_cmd="./mtcompile-program.pl --build --classic --client"
contained_good_repo_flag_path="$contained_repo/$good_repo_flag_name"
run_all_build_commands_script=/opt/build-lmk.sh
echo "lmk.rc finished loading."

20
install-minetest-build-deps.sh

@ -85,10 +85,11 @@ if [ ! -z "$this_apt" ]; then
libsqlite3-dev libssl-dev libtool \ libsqlite3-dev libssl-dev libtool \
libvorbis-dev libx11-dev libxxf86vm-dev lynx \ libvorbis-dev libx11-dev libxxf86vm-dev lynx \
nano nettle-dev p7zip-full patch \ nano nettle-dev p7zip-full patch \
perl pkg-config python3 python3-dev \ perl pkgconf python3 python3-dev \
python-dev rake ruby sed \ python-dev rake ruby sed \
tar tcl unzip util-linux \ tar tcl unzip util-linux \
wget xz-utils zip \ wget xz-utils zip perl \
dnsutils make \
\ \
libcurl4-openssl-dev \ libcurl4-openssl-dev \
libfreetype6-dev \ libfreetype6-dev \
@ -97,6 +98,17 @@ if [ ! -z "$this_apt" ]; then
libxml-parser-perl \ libxml-parser-perl \
xserver-xorg-dev \ xserver-xorg-dev \
; ;
# NOTE: installing pkgconf removes pkg-config:
# "pkgconf is a newer, actively maintained implementation of pkg-config that supports more aspects of the pkg-config file specification and provides a library interface that applications can use to incorporate intelligent handling of pkg-config files into themselves (such as build file generators, IDEs, and compilers)."
# -<https://fedoraproject.org/wiki/Changes/pkgconf_as_system_pkg-config_implementation#:~:text=pkgconf%20is%20a%20newer%2C%20actively,%2C%20IDEs%2C%20and%20compilers).>
# NOTE: build-essentials installs the following according to <https://www.cyberciti.biz/faq/debian-linux-install-gnu-gcc-compiler/>:
cat > /dev/null <<END
build-essential dpkg-dev fakeroot g++ g++-4.7 gcc gcc-4.7
libalgorithm-diff-perl libalgorithm-diff-xs-perl
libalgorithm-merge-perl libc-dev-bin libc6-dev libdpkg-perl
libfile-fcntllock-perl libitm1 libstdc++6-4.7-dev libtimedate-perl
linux-libc-dev make manpages-dev
END
if [ $? -ne 0 ]; then exit 1; fi if [ $? -ne 0 ]; then exit 1; fi
if [ ! -f "`command -v libtool`" ]; then if [ ! -f "`command -v libtool`" ]; then
. /etc/os-release . /etc/os-release
@ -112,7 +124,9 @@ if [ ! -z "$this_apt" ]; then
echo "* WARNING: The bc command isn't present, so the libtool-bin package will be skipped (it is only in Ubuntu >14.04 [not known in 15.x])" echo "* WARNING: The bc command isn't present, so the libtool-bin package will be skipped (it is only in Ubuntu >14.04 [not known in 15.x])"
fi fi
else else
echo "* WARNING: VERSION_ID is not in /etc/os-release, so the libtool-bin package will be skipped (it is only in Ubuntu >14.04 [not known in 15.x])" echo "* WARNING: VERSION_ID is not in /etc/os-release, so the libtool-bin package name is unknown (it is only in Ubuntu >14.04 [not known in 15.x])"
echo " * trying libtool-bin..."
$this_apt -y install libtool-bin
fi fi
fi fi
#libcurl4-openssl-dev: for announce to work #libcurl4-openssl-dev: for announce to work

Loading…
Cancel
Save