From cde5a39a91706fca367a080c70a29373182c1375 Mon Sep 17 00:00:00 2001 From: Cameron Cross Date: Thu, 2 Feb 2023 06:24:47 +1100 Subject: [PATCH 1/7] Add docker scripts to simplify setting up idevicerestore --- README.md | 11 ++++++++ docker/Dockerfile | 71 +++++++++++++++++++++++++++++++++++++++++++++++ docker/run.sh | 5 ++++ 3 files changed, 87 insertions(+) create mode 100644 docker/Dockerfile create mode 100755 docker/run.sh diff --git a/README.md b/README.md index 1af2d935..c65d4efa 100644 --- a/README.md +++ b/README.md @@ -260,6 +260,17 @@ idevicerestore --help man idevicerestore ``` +### Docker + +Execute `run.sh` in the docker folder, +which will build a docker container with the latest source versions of all required libraries, +and then will execute `idevicerestore --latest` + +After running the script once, the container can be reused with: +```shell +docker run -it --privileged -v "$(pwd):/tmp" idevicerestore-docker idevicerestore [optional commandline args] +``` + ## Contributing We welcome contributions from anyone and are grateful for every pull request! diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..19b25155 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,71 @@ +FROM ubuntu:18.04 +RUN apt-get update && apt-get install -y \ + build-essential \ + pkg-config \ + checkinstall \ + git \ + autoconf \ + automake \ + libtool-bin \ + libreadline-dev \ + libusb-1.0-0-dev \ + libcurl4-openssl-dev \ + libssl-dev \ + libzip-dev \ + zlib1g-dev \ + python3 \ + cython + +RUN git clone https://github.com/libimobiledevice/libplist.git && \ + cd libplist && \ + ./autogen.sh && \ + make && \ + make install && \ + cd .. && \ + rm libplist -rf + +RUN git clone https://github.com/libimobiledevice/libimobiledevice-glue.git && \ + cd libimobiledevice-glue && \ + ./autogen.sh && \ + make && \ + make install && \ + cd .. && \ + rm libimobiledevice-glue -rf + +RUN git clone https://github.com/libimobiledevice/libusbmuxd.git && \ + cd libusbmuxd && \ + ./autogen.sh && \ + make && \ + make install && \ + cd .. && \ + rm libusbmuxd -rf + +RUN git clone https://github.com/libimobiledevice/libimobiledevice.git && \ + cd libimobiledevice && \ + ./autogen.sh && \ + make && \ + make install && \ + cd .. && \ + rm libimobiledevice -rf + + + +RUN git clone https://github.com/libimobiledevice/libirecovery.git && \ + cd libirecovery && \ + ./autogen.sh && \ + make && \ + make install && \ + cd .. && \ + rm libirecovery -rf + +RUN git clone https://github.com/libimobiledevice/idevicerestore.git && \ + cd idevicerestore && \ + ./autogen.sh && \ + make && \ + make install && \ + cd .. && \ + rm idevicerestore -rf + +RUN ldconfig +WORKDIR /tmp +CMD idevicerestore \ No newline at end of file diff --git a/docker/run.sh b/docker/run.sh new file mode 100755 index 00000000..c652ede5 --- /dev/null +++ b/docker/run.sh @@ -0,0 +1,5 @@ +#!/bin/bash +cd "$(dirname "$0")" + +docker build . -t idevicerestore-docker +docker run -it --privileged -v "$(pwd):/tmp" idevicerestore-docker idevicerestore --latest \ No newline at end of file From aa54c3e8504ad4f5e85b93c4979d4aed71f04fc4 Mon Sep 17 00:00:00 2001 From: Cameron Cross Date: Tue, 24 Sep 2024 08:00:51 +1000 Subject: [PATCH 2/7] Update to include libtatsu, and a newer version of Ubuntu --- docker/Dockerfile | 17 +++++++++++++---- docker/run.sh | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 19b25155..97bd9dc7 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,6 @@ -FROM ubuntu:18.04 +FROM ubuntu:22.04 + +ENV DEBIAN_FRONTEND="noninteractive" RUN apt-get update && apt-get install -y \ build-essential \ pkg-config \ @@ -13,8 +15,7 @@ RUN apt-get update && apt-get install -y \ libssl-dev \ libzip-dev \ zlib1g-dev \ - python3 \ - cython + python3 RUN git clone https://github.com/libimobiledevice/libplist.git && \ cd libplist && \ @@ -24,6 +25,14 @@ RUN git clone https://github.com/libimobiledevice/libplist.git && \ cd .. && \ rm libplist -rf +RUN git clone https://github.com/libimobiledevice/libtatsu.git && \ + cd libtatsu && \ + ./autogen.sh && \ + make && \ + make install && \ + cd .. && \ + rm libtatsu -rf + RUN git clone https://github.com/libimobiledevice/libimobiledevice-glue.git && \ cd libimobiledevice-glue && \ ./autogen.sh && \ @@ -68,4 +77,4 @@ RUN git clone https://github.com/libimobiledevice/idevicerestore.git && \ RUN ldconfig WORKDIR /tmp -CMD idevicerestore \ No newline at end of file +CMD idevicerestore diff --git a/docker/run.sh b/docker/run.sh index c652ede5..16996c43 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -1,5 +1,6 @@ #!/bin/bash +set -e cd "$(dirname "$0")" docker build . -t idevicerestore-docker -docker run -it --privileged -v "$(pwd):/tmp" idevicerestore-docker idevicerestore --latest \ No newline at end of file +docker run -it --privileged -v "$(pwd):/tmp" idevicerestore-docker idevicerestore --latest From 4f25af8c40786673bb57b4c365c3754afce6fb6f Mon Sep 17 00:00:00 2001 From: Cameron Cross Date: Tue, 22 Oct 2024 20:04:52 +1100 Subject: [PATCH 3/7] Update command used to restore, seems to work better. # Conflicts: # docker/run.sh --- README.md | 2 +- docker/run.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c65d4efa..bd6cadad 100644 --- a/README.md +++ b/README.md @@ -268,7 +268,7 @@ and then will execute `idevicerestore --latest` After running the script once, the container can be reused with: ```shell -docker run -it --privileged -v "$(pwd):/tmp" idevicerestore-docker idevicerestore [optional commandline args] +docker run -it --privileged --net=host -v /run/udev/control:/run/udev/control -v "$(pwd):/tmp" idevicerestore-docker idevicerestore [optional commandline args] ``` ## Contributing diff --git a/docker/run.sh b/docker/run.sh index 16996c43..9a8aec84 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -3,4 +3,4 @@ set -e cd "$(dirname "$0")" docker build . -t idevicerestore-docker -docker run -it --privileged -v "$(pwd):/tmp" idevicerestore-docker idevicerestore --latest +docker run -it --privileged --net=host -v /run/udev/control:/run/udev/control -v "$(pwd):/tmp" idevicerestore-docker idevicerestore --latest From d76ddc7cc6bc3d51e83a3479a67a51b6a2f3f360 Mon Sep 17 00:00:00 2001 From: Cameron Cross Date: Tue, 22 Oct 2024 23:07:39 +1100 Subject: [PATCH 4/7] Add usbmuxd, which was the final link. Cleaned up run script. --- README.md | 9 ++------- docker/Dockerfile | 43 ++++++++++++++++++++++++---------------- docker/idevicerestore.sh | 7 +++++++ docker/run.sh | 5 ++++- 4 files changed, 39 insertions(+), 25 deletions(-) create mode 100755 docker/idevicerestore.sh diff --git a/README.md b/README.md index bd6cadad..8d9bc00b 100644 --- a/README.md +++ b/README.md @@ -262,14 +262,9 @@ man idevicerestore ### Docker -Execute `run.sh` in the docker folder, +Execute `run.sh --latest` in the docker folder, which will build a docker container with the latest source versions of all required libraries, -and then will execute `idevicerestore --latest` - -After running the script once, the container can be reused with: -```shell -docker run -it --privileged --net=host -v /run/udev/control:/run/udev/control -v "$(pwd):/tmp" idevicerestore-docker idevicerestore [optional commandline args] -``` +and then will execute `usbmuxd` in the background, and then start `idevicerestore --latest`. ## Contributing diff --git a/docker/Dockerfile b/docker/Dockerfile index 97bd9dc7..37f23066 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,20 +2,21 @@ FROM ubuntu:22.04 ENV DEBIAN_FRONTEND="noninteractive" RUN apt-get update && apt-get install -y \ - build-essential \ - pkg-config \ - checkinstall \ - git \ - autoconf \ - automake \ - libtool-bin \ - libreadline-dev \ - libusb-1.0-0-dev \ - libcurl4-openssl-dev \ - libssl-dev \ - libzip-dev \ - zlib1g-dev \ - python3 + build-essential \ + pkg-config \ + checkinstall \ + git \ + autoconf \ + automake \ + libtool-bin \ + libreadline-dev \ + libusb-1.0-0-dev \ + libcurl4-openssl-dev \ + libssl-dev \ + libzip-dev \ + zlib1g-dev \ + python3 \ + udev RUN git clone https://github.com/libimobiledevice/libplist.git && \ cd libplist && \ @@ -57,8 +58,6 @@ RUN git clone https://github.com/libimobiledevice/libimobiledevice.git && \ cd .. && \ rm libimobiledevice -rf - - RUN git clone https://github.com/libimobiledevice/libirecovery.git && \ cd libirecovery && \ ./autogen.sh && \ @@ -67,6 +66,14 @@ RUN git clone https://github.com/libimobiledevice/libirecovery.git && \ cd .. && \ rm libirecovery -rf +RUN git clone https://github.com/libimobiledevice/usbmuxd.git && \ + cd usbmuxd && \ + ./autogen.sh && \ + make && \ + make install && \ + cd .. && \ + rm usbmuxd -rf + RUN git clone https://github.com/libimobiledevice/idevicerestore.git && \ cd idevicerestore && \ ./autogen.sh && \ @@ -77,4 +84,6 @@ RUN git clone https://github.com/libimobiledevice/idevicerestore.git && \ RUN ldconfig WORKDIR /tmp -CMD idevicerestore +COPY idevicerestore.sh /usr/sbin/idevicerestore.sh +CMD idevicerestore.sh + diff --git a/docker/idevicerestore.sh b/docker/idevicerestore.sh new file mode 100755 index 00000000..cc80fbf5 --- /dev/null +++ b/docker/idevicerestore.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +usbmuxd & + +idevicerestore "$@" + diff --git a/docker/run.sh b/docker/run.sh index 9a8aec84..6c03171a 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -3,4 +3,7 @@ set -e cd "$(dirname "$0")" docker build . -t idevicerestore-docker -docker run -it --privileged --net=host -v /run/udev/control:/run/udev/control -v "$(pwd):/tmp" idevicerestore-docker idevicerestore --latest +docker rm --force idevicerestore || true + +docker run --name idevicerestore -it --privileged --net=host -v /dev:/dev -v /run/udev/control:/run/udev/control -v "$(pwd):/tmp" idevicerestore-docker idevicerestore.sh "$@" + From 3a229ed78cf89a59d9c8f8a9cc307836477886cf Mon Sep 17 00:00:00 2001 From: Cameron Cross Date: Wed, 23 Oct 2024 06:11:16 +1100 Subject: [PATCH 5/7] Separate build and run stages. --- README.md | 9 ++++++--- docker/build.sh | 8 ++++++++ docker/run.sh | 6 +++++- 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100755 docker/build.sh diff --git a/README.md b/README.md index 8d9bc00b..58f9bbb5 100644 --- a/README.md +++ b/README.md @@ -262,9 +262,12 @@ man idevicerestore ### Docker -Execute `run.sh --latest` in the docker folder, -which will build a docker container with the latest source versions of all required libraries, -and then will execute `usbmuxd` in the background, and then start `idevicerestore --latest`. +Build the container with `build.sh` in the docker folder, which will build a +docker container with the latest source versions of all the required libraries. + +Run the container with `run.sh --latest` in the docker folder, +which will execute `usbmuxd` in the background, and then start `idevicerestore --latest`. +Any arguments passed to `run.sh` will be passed in to `idevicerestore`. ## Contributing diff --git a/docker/build.sh b/docker/build.sh new file mode 100755 index 00000000..dc415661 --- /dev/null +++ b/docker/build.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e +cd "$(dirname "$0")" + +docker build . -t idevicerestore-docker --no-cache + +echo "You can now use 'run.sh --latest' to run the restore." + diff --git a/docker/run.sh b/docker/run.sh index 6c03171a..0078309d 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -2,7 +2,11 @@ set -e cd "$(dirname "$0")" -docker build . -t idevicerestore-docker +if [[ -z $(docker images | grep idevicerestore-docker) ]]; then + echo "Container not built, you will need to build it with 'build.sh'" + exit -1 +fi + docker rm --force idevicerestore || true docker run --name idevicerestore -it --privileged --net=host -v /dev:/dev -v /run/udev/control:/run/udev/control -v "$(pwd):/tmp" idevicerestore-docker idevicerestore.sh "$@" From 4d915d72fd0fd18269a1952c8f7e4ec505e7ec1d Mon Sep 17 00:00:00 2001 From: Cameron Cross Date: Wed, 23 Oct 2024 10:43:51 +1100 Subject: [PATCH 6/7] Add CI to build and archive docker image --- .github/workflows/build.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bd2bdd58..f1750510 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -304,3 +304,16 @@ jobs: with: name: idevicerestore-latest_${{ matrix.arch }}-${{ env.dest }} path: idevicerestore.tar + build-docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: build + run: | + pushd docker && ./build.sh; popd + docker image save -o idevicerestore-docker.tar idevicerestore-docker + - name: publish artifact + uses: actions/upload-artifact@v4 + with: + name: idevicerestore-latest_docker + path: idevicerestore-docker.tar From 8d7c306e8614b411c32b1a63b07df9c20e996dcf Mon Sep 17 00:00:00 2001 From: Cameron Cross Date: Wed, 23 Oct 2024 10:54:22 +1100 Subject: [PATCH 7/7] Upgrade docker image base to 24.04 --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 37f23066..8da9bd40 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:22.04 +FROM ubuntu:24.04 ENV DEBIAN_FRONTEND="noninteractive" RUN apt-get update && apt-get install -y \