re.S | re.M).group(1)
         src = os.path.join(bindir, src)
     elif omethod == 'raw':
-        globpath = os.path.join(root_dir, build.output)
+        output_path = common.replace_build_vars(build.output, build)
+        globpath = os.path.join(root_dir, output_path)
         apks = glob.glob(globpath)
         if len(apks) > 1:
             raise BuildException('Multiple apks match %s' % globpath, '\n'.join(apks))
 
             env[n] = build.ndk_path()
 
 
+def replace_build_vars(cmd, build):
+    cmd = cmd.replace('$$COMMIT$$', build.commit)
+    cmd = cmd.replace('$$VERSION$$', build.versionName)
+    cmd = cmd.replace('$$VERCODE$$', build.versionCode)
+    return cmd
+
+
 def replace_config_vars(cmd, build):
     cmd = cmd.replace('$$SDK$$', config['sdk_path'])
     cmd = cmd.replace('$$NDK$$', build.ndk_path())
     cmd = cmd.replace('$$MVN3$$', config['mvn3'])
     cmd = cmd.replace('$$QT$$', config['qt_sdk_path'] or '')
     if build is not None:
-        cmd = cmd.replace('$$COMMIT$$', build.commit)
-        cmd = cmd.replace('$$VERSION$$', build.versionName)
-        cmd = cmd.replace('$$VERCODE$$', build.versionCode)
+        cmd = replace_build_vars(cmd, build)
     return cmd
 
 
 
 
 Build:0.2.1,2000
     commit=0.2.1
-    output=app/build/distributions/FDroidPrivilegedExtensionFromBinaries-0.2.1.zip
+    output=app/build/distributions/FDroidPrivilegedExtensionFromBinaries-$$VERSION$$.zip
     build=gradle assembleUpdateZipFromBinariesDebug
 
 Auto Update Mode:Version %v