[Droid RAZR M Android Development] DiamondJohn:
All the steps below are done at your OWN risk, and I take no responsibility blah blah blah

I will use explicit directory names and have referred to using Notepad++ and 7Zip. Both of which are free. But are not important to the actual process, just simplify the explanation for me. I will also be using Windows.

Both the above assumptions can be easily transferred to their UNIX or Mac equivalents.

1. Download the latest build from Lineage for the XT897

https://download.lineageos.org/xt897

2. Extract a copy of the file "/system/build.prop"

3. Open the build prop in a text editor

4. Do a global Find & Replace (case sensitive just to be sure)

xt897 to xt907

XT897 to XT907

5 Add and / or replace the following lines into the build prop (location in the file is not important, I personally add any new to the end and replace the values for existing)

ro.hdmi.enable=false
ro.cm.device=xt907
ro.product.device=RAZR M
ro.product.name=XT907
ro.build.product=scorpion_mini
ro.product.model=RAZR M
ro.boot.modelno=XT907

6. extract the attached vendor_motorola_xt907_proprietary.zip to C:\temp\xt907\

you should now have the directory structure of:

c:\temp\xt907\etc\firmware\
within the last directory should be two files
atmxt-r1.tdat
atmxt-r2.tdat

7. Add the etc\firmware directories at c:\temp\xt907\ to the zip, under the system directory.

you should now have within the zip

\system\
build.prop
\etc\firmware\
atmxt-r1.tdat
atmxt-r2.tdat

8. extract "\META-INF\com\google\android\updater-script" file from the zip to c:\temp\xt907\

9. Open the "c:\temp\xt907\updater-script" file in your text editor

NB: when editing this file, I would ensure that all line endings are "newline" not "CR-NL". In Notepad++ do a replace of "\r\n" with "\n"

10. Change the first line

FROM:

[COLOR="Red"][strike]assert(getprop("ro.product.device") == "xt897" || getprop("ro.build.product") == "xt897" || getprop("ro.product.device") == "asanti_c" || getprop("ro.build.product") == "asanti_c" || abort("This package is for device: xt897,asanti_c; this device is " + getprop("ro.product.device") + "."););[/strike][/COLOR]

TO:

[COLOR="SeaGreen"][B]assert(getprop("ro.product.device") == "moto_msm8960_jbbl" || getprop("ro.build.product") == "moto_msm8960_jbbl" || getprop("ro.product.device") == "xt907_jbbl" || getprop("ro.build.product") == "xt907_jbbl" || getprop("ro.product.device") == "xt901" || getprop("ro.build.product") == "xt901" || getprop("ro.product.device") == "solstice" || getprop("ro.build.product") == "solstice" || getprop("ro.product.device") == "xt905" || getprop("ro.build.product") == "xt905" || getprop("ro.product.device") == "smq_u" || getprop("ro.build.product") == "smq_u" || getprop("ro.product.device") == "scorpion_mini_u" || getprop("ro.build.product") == "scorpion_mini_u" || getprop("ro.product.device") == "XT907_JBBL" || getprop("ro.build.product") == "XT907_JBBL" ||getprop("ro.product.device") == "Moto Razr M" || getprop("ro.build.product") == "Moto Razr M" || getprop("ro.product.device") == "scorpion_mini" || getprop("ro.build.product") == "scorpion_mini" || abort("This package is for device: moto_msm8960_jbbl,xt901,solstice,xt905,smq_u,scorpion_mini_u,xt907_jbbl,scorpion_mini; this device is " + getprop("ro.product.device") + "."););[/B][/COLOR]

11. Add the following lines to the end of the updater-script file

ifelse(is_mounted("/system"), unmount("/system"));
mount("ext4", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/system", "/system", "");
package_extract_dir("system", "/system");
unmount("/system");

12. Save the file (take note of NL characters for line ending), & replace the one in the zip that you originally extracted it from ie "\META-INF\com\google\android\updater-script"

13. Rename the zip from something like "lineage-13.0-20170325-nightly-xt897-signed.zip" to "lineage-13.0-20170325-nightly-xt907-PORTED.zip"

14. reboot to TWRP

15. Make a backup!!!

16. Do a clean install and flash the appropriate GApps

17. Reboot & enjoy

Lineage do a weakly build for the XT897, and I think I previously use to dirty flash the ones I made. You can also see the change logs etc for the XT897 to know what to expect.

I have started to build my own XT905/XT907 ROMS from the source for the XT897, so it has been a while sionce I did the above, but I have modified the source to basically do the above steps. I actually still do the build prop file manually as its easier than modifying/maintaining the source. I also think you should be able to dirty flash it over an existing ZIP that was built using the above system.