Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c99c657c authored by Romain Hunault's avatar Romain Hunault 🚴🏻
Browse files

Merge branch '10-return-only-updates-from-the-same-android-version' into 'master'

Resolve "Return only updates from the same Android version"

Closes #10

See merge request e/os/LineageOTA!9
parents a56c22f4 3f09c4ec
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
.git
Dockerfile
builds/delta/*/*/*.zip
builds/full/*/*/*.zip
+3 −2
Original line number Diff line number Diff line
image: docker:stable
image: docker:19.03.1

# When using dind, it's wise to use the overlayfs driver for
# improved performance.
@@ -7,9 +7,10 @@ variables:
  CONTAINER_IMAGE: registry.gitlab.e.foundation:5000/e/os/lineageota
  PUBLISH_USER: root
  PUBLISH_URL: ota.ecloud.global
  DOCKER_TLS_CERTDIR: "/certs"

services:
- docker:dind
- docker:19.03.1-dind

before_script:
- 'which ssh-agent || ( apk --update add openssh-client )'
+23 −0
Original line number Diff line number Diff line
@@ -14,6 +14,29 @@ Got a question? Not sure where it should be made? See [CONTRIBUTING](CONTRIBUTIN

## How to use

### Test

```
$ sudo docker build -t e/lineageota . \
    && sudo docker run \
        -d \
        -p 80:80 \
        --rm \
        -v "${PWD}/builds/full:/var/www/html/builds/full" \
        --name lineageota \
        e/lineageota
```

Access to API via http://localhost/api/v1/\<device\>/\<channel\>

Get logs with

```
$ sudo docker exec -ti lineageota tail -f LineageOTA.log
```

You can also use this server with a device connected to the same network, specifying the correct IP (see below).

### Composer

```shell
+43 −27
Original line number Diff line number Diff line
@@ -31,9 +31,9 @@

      // This will contain the build list based on the current request
    	private $builds = array();

      private $postData = array();
      private $logger = null;
      private $currentBuild = null;

      /**
       * Constructor of the Builds class.
@@ -60,6 +60,14 @@
    		$ret = array();

            foreach ( $this->builds as $build ) {

                if (!is_null($this->currentBuild) && strcmp($this->currentBuild->getAndroidVersion(), $build->getAndroidVersion()) != 0) {
                  $this->logger->info($build->getIncremental().' ignored as Android version is not the same');
                  continue;
                }

                $this->logger->info($build->getIncremental().' is a new update');

                array_push( $ret, array(
                    // CyanogenMod
                    'incremental' => $build->getIncremental(),
@@ -171,10 +179,18 @@

                            if ( $build->isValid( $this->postData['params'] ) ) {
                                array_push( $this->builds , $build );

                                if (strcmp($this->postData['params']['source_incremental'], $build->getIncremental()) == 0) {
                                  $this->currentBuild = $build;
                                  $this->logger->info($build->getIncremental().' is the current build');
                                }
                            }
                        }
                    }
                }
            }

            if (!empty($this->postData['params']['source_incremental']) && is_null($this->currentBuild))
              $this->currentBuild = $this->builds[1];
    	}
    }