Compare commits

...

2 Commits

Author SHA1 Message Date
Steven Polley 464f4d09e7 create isLineageROMZip function
continuous-integration/drone/push Build is passing Details
2023-06-04 15:41:01 -06:00
Steven Polley 623b8f74f1 Remove deprecated files 2023-06-04 15:22:53 -06:00
4 changed files with 21 additions and 32 deletions

View File

@ -1,7 +0,0 @@
These files need to be deployed into your Android source code directory to ensure build.prop file on the device contains the correct URL for receiving OTA updates. This is to point the updated app at the OTA server you're hosting.
1. Create the directory lineage/vendor/extra
2. Review and edit the contents of file product.prop to ensure the URL is what you want your device pointed to.
3. Place the product.mk and product.prop files in this directory
The files will then be automatically read by the build system and patch build.prop with the updated URL.

View File

@ -1 +0,0 @@
TARGET_PRODUCT_PROP += $(COMMON_PATH)/product.prop

View File

@ -1 +0,0 @@
lineage.updater.uri=https://lineage-ota.deadbeef.codes

44
main.go
View File

@ -81,13 +81,8 @@ func updateROMCache(romDirectory string) {
for i, v := range files {
// skip directories
if v.Type().IsDir() {
continue
}
// skip non .zip files
if !strings.HasSuffix(v.Name(), ".zip") {
isLineageROM, splitName := isLineageROMZip(v)
if !isLineageROM {
continue
}
@ -99,11 +94,6 @@ func updateROMCache(romDirectory string) {
}
romCache.Unlock()
// Parse filename and skip files that can't be parsed
splitName := strings.Split(v.Name(), "-")
if len(splitName) != 5 {
continue
}
go func(v fs.DirEntry) {
fInfo, err := v.Info()
if err != nil {
@ -157,19 +147,10 @@ func moveBuildArtifacts(outDirectory, romDirectory string) bool {
var newROMs bool
for _, v := range files {
// skip directories
if v.Type().IsDir() {
continue
}
// skip non .zip files
if !strings.HasSuffix(v.Name(), ".zip") {
continue
}
// Parse filename and skip files that can't be parsed
splitName := strings.Split(v.Name(), "-")
if len(splitName) != 5 {
if isLineageROM, _ := isLineageROMZip(v); !isLineageROM { // skip files that aren't LineageOS ROMs
continue
}
newROMs = true
log.Printf("new build found - moving file %s", v.Name())
err := moveBuildFile(fmt.Sprintf("%s/%s", outDirectory, v.Name()), fmt.Sprintf("%s/%s", romDirectory, v.Name()))
@ -182,6 +163,22 @@ func moveBuildArtifacts(outDirectory, romDirectory string) bool {
return newROMs
}
// false if a file is not a LineageOS ROM .zip file
// no formal validation is performed - only file naming convention is checked
// also returns a lineage ROM's filename sliced and delimited by -'s
// Example filename: lineage-20.0-20230604-UNOFFICIAL-sunfish.zip
func isLineageROMZip(v fs.DirEntry) (bool, []string) {
// skip directories, non .zip files and files that don't begin with lineage-
if v.Type().IsDir() || !strings.HasSuffix(v.Name(), ".zip") || !strings.HasPrefix(v.Name(), "lineage-") {
return false, nil
}
splitName := strings.Split(v.Name(), "-")
// expect 5 dashes
return len(splitName) == 5, splitName
}
// http - GET /
// Writes JSON response for the updater app to know what versions are available to download
func lineageOSROMListHandler(w http.ResponseWriter, r *http.Request) {
@ -208,6 +205,7 @@ func lineageOSROMListHandler(w http.ResponseWriter, r *http.Request) {
}()
}
// Returns a sha256 hash of a file located at the path provided
func hashFile(filename string) (string, error) {
f, err := os.Open(filename)
if err != nil {