Compare commits
9 Commits
238dab70fe
...
main
Author | SHA1 | Date | |
---|---|---|---|
6b2118b53f | |||
a09647cbaf | |||
9b3302dcf3 | |||
fb5b9864d9 | |||
f72a33148d | |||
5bdda0259a | |||
0b5eb36b5a | |||
2921f5a76f | |||
1f3209f55e |
@ -3,7 +3,7 @@ name: default
|
|||||||
|
|
||||||
workspace:
|
workspace:
|
||||||
base: /go
|
base: /go
|
||||||
path: src/deadbeef.codes/steven/lineageos-ota-server
|
path: src/code.stevenpolley.net/steven/lineageos-ota-server
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
@ -22,4 +22,4 @@ steps:
|
|||||||
- name: package in docker container
|
- name: package in docker container
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
repo: registry.deadbeef.codes/lineageos-ota-server
|
repo: registry.stevenpolley.net/lineageos-ota-server
|
||||||
|
20
README.md
20
README.md
@ -24,7 +24,7 @@ version: '3.8'
|
|||||||
- "8080"
|
- "8080"
|
||||||
volumes:
|
volumes:
|
||||||
- /data/android/lineage/out/target/product/sunfish:/out
|
- /data/android/lineage/out/target/product/sunfish:/out
|
||||||
- /data/android/public:/public
|
- /data/android/public/sunfish:/public
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -34,21 +34,17 @@ The recommended way is to include the configuration inside your build of the ROM
|
|||||||
|
|
||||||
Create new file /data/android/lineage/vendor/lineage/build/core/deadbeef-ota.mk
|
Create new file /data/android/lineage/vendor/lineage/build/core/deadbeef-ota.mk
|
||||||
|
|
||||||
```makefile
|
|
||||||
# deadbeef.codes LineageOS OTA update server - replace with your own URL
|
|
||||||
ADDITIONAL_SYSTEM_PROPERTIES += \
|
|
||||||
lineage.updater.uri=https://lineageos-ota.deadbeef.codes
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Edit /data/android/lineage/vendor/lineage/build/core/main.mk to include deadbeef-ota.mk
|
Edit (create if not exist) /data/android/lineage/vendor/extra/product.mk
|
||||||
|
|
||||||
```makefile
|
```makefile
|
||||||
|
|
||||||
# Include LineageOS versions
|
|
||||||
include $(TOPDIR)vendor/lineage/build/core/main_version.mk
|
|
||||||
|
|
||||||
# Include deadbeef.codes OTA server
|
# Include deadbeef.codes OTA server
|
||||||
include $(TOPDIR)vendor/lineage/build/core/deadbeef-ota.mk
|
PRODUCT_SYSTEM_DEFAULT_PROPERTIES += \
|
||||||
|
lineage.updater.uri=https://lineageos-ota-{device}.stevenpolley.net
|
||||||
|
|
||||||
|
# Default ADB shell
|
||||||
|
PRODUCT_SYSTEM_DEFAULT_PROPERTIES += \
|
||||||
|
persist.sys.adb.shell=/system_ext/bin/bash
|
||||||
|
|
||||||
```
|
```
|
2
go.mod
2
go.mod
@ -1,3 +1,3 @@
|
|||||||
module deadbeef.codes/steven/lineageos-ota-server
|
module deadbeef.codes/steven/lineageos-ota-server
|
||||||
|
|
||||||
go 1.20
|
go 1.22
|
||||||
|
9
main.go
9
main.go
@ -39,13 +39,18 @@ const (
|
|||||||
cacheFile = "public/romcache.json" // persistence between server restarts so we don't have to rehash all the ROM files each time the program starts
|
cacheFile = "public/romcache.json" // persistence between server restarts so we don't have to rehash all the ROM files each time the program starts
|
||||||
)
|
)
|
||||||
|
|
||||||
var ( // evil global variable
|
var ( // evil global variables
|
||||||
romCache ROMCache
|
romCache ROMCache
|
||||||
|
baseURL string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// intialize and load ROMCache from file - so we don't have to rehash all the big files again
|
// intialize and load ROMCache from file - so we don't have to rehash all the big files again
|
||||||
romCache = ROMCache{}
|
romCache = ROMCache{}
|
||||||
|
baseURL = os.Getenv("baseurl")
|
||||||
|
if len(baseURL) < 1 {
|
||||||
|
log.Fatalf("required environment variable 'baseurl' is not set.")
|
||||||
|
}
|
||||||
|
|
||||||
romCacheJson, err := os.ReadFile(cacheFile)
|
romCacheJson, err := os.ReadFile(cacheFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -140,7 +145,7 @@ func updateROMCache() {
|
|||||||
ID: fileHash,
|
ID: fileHash,
|
||||||
Romtype: splitName[3], // UNOFFICIAL
|
Romtype: splitName[3], // UNOFFICIAL
|
||||||
Size: int(fInfo.Size()),
|
Size: int(fInfo.Size()),
|
||||||
URL: fmt.Sprintf("https://lineageos-ota.deadbeef.codes/public/%s", v.Name()),
|
URL: fmt.Sprintf("%s/public/%s", baseURL, v.Name()),
|
||||||
Version: splitName[1],
|
Version: splitName[1],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ func hashFile(filename string) (string, error) {
|
|||||||
return "", fmt.Errorf("failed to copy data from file to hash function: %v", err)
|
return "", fmt.Errorf("failed to copy data from file to hash function: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return string(h.Sum(nil)), nil
|
return fmt.Sprintf("%x", h.Sum(nil)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// false if a file is not a LineageOS ROM .zip file
|
// false if a file is not a LineageOS ROM .zip file
|
||||||
|
Reference in New Issue
Block a user