From a4cb4f7c9621df850827c7b48133c2162af16a14 Mon Sep 17 00:00:00 2001 From: Mark Wong Date: Fri, 11 Jun 2021 13:11:28 -0700 Subject: Add Docker file and script to build AppImage --- CMakeLists.txt | 32 ++++++++++++++++++++++++++++++++ Dockerfile.appimage | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ HISTORY.rst | 5 +++++ Makefile | 7 ++++++- docker/README | 4 ++++ docker/appimage-build | 26 ++++++++++++++++++++++++++ docker/appimage-prepare | 14 ++++++++++++++ 7 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 Dockerfile.appimage create mode 100644 docker/README create mode 100755 docker/appimage-build create mode 100755 docker/appimage-prepare diff --git a/CMakeLists.txt b/CMakeLists.txt index b4cf66e..508d020 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -395,3 +395,35 @@ add_custom_target(appimage `ldd pg_top | grep libselinux.so | cut -d \" \" -f 3` AppDir/usr/lib COMMAND VERSION=${PROJECT_VERSION} appimagetool-${ARCH}.AppImage AppDir ) + +add_custom_target(appimage-docker + COMMAND cp -aL ${CMAKE_SOURCE_DIR}/AppRun AppDir + COMMAND cp -aL ${CMAKE_SOURCE_DIR}/pg_top.desktop AppDir + COMMAND cp -aL ${CMAKE_SOURCE_DIR}/pg_top.png AppDir + COMMAND mkdir -p AppDir/usr/share/metainfo + COMMAND cp -aL ${CMAKE_SOURCE_DIR}/pg_top.appdata.xml AppDir/usr/share/metainfo + COMMAND mkdir -p AppDir/usr/lib + COMMAND cp -aL + `ldd pg_top | grep libpq.so | cut -d \" \" -f 3` AppDir/usr/lib + COMMAND cp -aL + `ldd pg_top | grep libtinfo.so | cut -d \" \" -f 3` AppDir/usr/lib + COMMAND cp -aL + `ldd pg_top | grep libbsd.so | cut -d \" \" -f 3` AppDir/usr/lib + COMMAND cp -aL + `ldd pg_top | grep libssl.so | cut -d \" \" -f 3` AppDir/usr/lib + COMMAND cp -aL + `ldd pg_top | grep libcrypto.so | cut -d \" \" -f 3` AppDir/usr/lib + COMMAND cp -aL + `ldd pg_top | grep libgssapi_krb5.so | cut -d \" \" -f 3` AppDir/usr/lib + COMMAND cp -aL + `ldd pg_top | grep libkrb5.so | cut -d \" \" -f 3` AppDir/usr/lib + COMMAND cp -aL + `ldd pg_top | grep libk5crypto.so | cut -d \" \" -f 3` AppDir/usr/lib + COMMAND cp -aL + `ldd pg_top | grep libkrb5support.so | cut -d \" \" -f 3` AppDir/usr/lib + COMMAND cp -aL + `ldd pg_top | grep libkeyutils.so | cut -d \" \" -f 3` AppDir/usr/lib + COMMAND cp -aL + `ldd pg_top | grep libselinux.so | cut -d \" \" -f 3` AppDir/usr/lib + COMMAND VERSION=${PROJECT_VERSION} /usr/local/squashfs-root/AppRun --comp=xz AppDir +) diff --git a/Dockerfile.appimage b/Dockerfile.appimage new file mode 100644 index 0000000..dd7a460 --- /dev/null +++ b/Dockerfile.appimage @@ -0,0 +1,48 @@ +# Build an environment for creating an AppImage. + +# Use a distro with an old libc to maximize support on as many linux distros as +# possible. +FROM centos:6 + +# CentOS 6 is EOL so update the repo config to use the CentOS vault. 6.10 is +# the final version. +RUN sed -i 's/enabled=1/enabled=0/' /etc/yum/pluginconf.d/fastestmirror.conf +RUN sed -i 's/mirrorlist/#mirrorlist/' /etc/yum.repos.d/*.repo +RUN sed -i 's|#baseurl=http://mirror.centos.org/centos/$releasever|baseurl=https://vault.centos.org/6.10|' /etc/yum.repos.d/*.repo + +RUN yum -y update +RUN yum -y install epel-release +RUN yum -y update +RUN yum -y install cmake \ + bison \ + flex \ + gcc \ + libbsd-devel \ + make \ + ncurses-devel \ + openssl-devel \ + xz + +WORKDIR /usr/local +# Release 12 is the latest that will run on CentOS 6. +RUN curl -OL https://github.com/AppImage/AppImageKit/releases/download/12/appimagetool-x86_64.AppImage +RUN chmod +x appimagetool-x86_64.AppImage +RUN ./appimagetool-x86_64.AppImage --appimage-extract +RUN chmod 0755 squashfs-root +RUN chmod 0755 squashfs-root/usr +RUN chmod 0755 squashfs-root/usr/bin +RUN chmod 0755 squashfs-root/usr/lib +RUN chmod 0755 squashfs-root/usr/lib/appimagekit +RUN chmod 0755 squashfs-root/usr/share + +WORKDIR /usr/local/src + +# PostgreSQL 10 is the first release supporting multiple hosts in the +# connection string. +RUN curl -OL https://ftp.postgresql.org/pub/source/v10.17/postgresql-10.17.tar.bz2 +RUN tar xvf postgresql-10.17.tar.bz2 +WORKDIR /usr/local/src/postgresql-10.17 +RUN ./configure --without-ldap --without-readline --without-zlib \ + --without-gssapi --with-openssl --prefix=/usr +RUN make install +RUN ldconfig diff --git a/HISTORY.rst b/HISTORY.rst index e46db03..a6ff715 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,11 @@ Release Notes ============= +YYYY-MM-DD v4.0.1 +----------------- + +* Add Docker files for creating an AppImage + 2020-08-05 v4.0.0 ----------------- diff --git a/Makefile b/Makefile index 2ba1495..07a7811 100644 --- a/Makefile +++ b/Makefile @@ -3,13 +3,18 @@ default: UNAME_S := $(shell uname -s) -appimage: +appimage-prep: cmake -H. -Bbuild/appimage -DCMAKE_INSTALL_PREFIX=/usr cd build/appimage && make cd build/appimage && sed -i -e 's#/usr#././#g' pg_top cd build/appimage && make install DESTDIR=AppDir + +appimage: appimage-prep cd build/appimage && make appimage +appimage-docker: appimage-prep + cd build/appimage && make appimage-docker + clean: -rm -rf build diff --git a/docker/README b/docker/README new file mode 100644 index 0000000..3f6947e --- /dev/null +++ b/docker/README @@ -0,0 +1,4 @@ +This is a collection of scripts to use Docker for specific tasks: + +* appimage-prepare - Build a Docker image to use for creating an AppImage. +* appimage-build - Create an AppImage for pg_top. diff --git a/docker/appimage-build b/docker/appimage-build new file mode 100755 index 0000000..e094692 --- /dev/null +++ b/docker/appimage-build @@ -0,0 +1,26 @@ +#!/bin/sh + +which docker > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "docker is not in your path" + exit 1 +fi + +DOCKER_DIR=`dirname $0` +DOCKER_DIR=`readlink -f $DOCKER_DIR` + +DOCKER_TAG="pg_top-appimage" + +# Use the return code from `docker inspect` to determine if the docker image +# needs to be created. +docker inspect $DOCKER_TAG > /dev/null +if [ $? -ne 0 ]; then + ${DOCKER_DIR}/appimage-prepare || exit 1 +fi + +UID=`id -u` +GID=`id -g` + +docker run --rm -v ${DOCKER_DIR}/..:/usr/local/src/pg_top:rw \ + -w /usr/local/src/pg_top -u ${UID}:${GID} $DOCKER_TAG \ + make appimage-docker diff --git a/docker/appimage-prepare b/docker/appimage-prepare new file mode 100755 index 0000000..8e1ae76 --- /dev/null +++ b/docker/appimage-prepare @@ -0,0 +1,14 @@ +#!/bin/sh + +which docker > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo "docker is not in your path" + exit 1 +fi + +DOCKER_DIR=`dirname $0` +DOCKER_DIR=`readlink -f $DOCKER_DIR` + +DOCKER_TAG="pg_top-appimage" + +(cd $DOCKER_DIR/.. && docker build -t $DOCKER_TAG -f Dockerfile.appimage .) -- cgit v1.2.3