Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
556f9ee3
Commit
556f9ee3
authored
Nov 20, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
{android,win32}/build.py: move common code to python/build/
parent
7dad662d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
104 deletions
+66
-104
.gitignore
.gitignore
+2
-0
build.py
android/build.py
+6
-49
download.py
python/build/download.py
+40
-0
tar.py
python/build/tar.py
+11
-0
build.py
win32/build.py
+7
-55
No files found.
.gitignore
View file @
556f9ee3
...
...
@@ -83,3 +83,5 @@ tags
/*.tar.bz2
/*.tar.xz
/mpd-*/
__pycache__/
android/build.py
View file @
556f9ee3
...
...
@@ -2,8 +2,6 @@
import
os
,
os
.
path
import
sys
,
shutil
,
subprocess
import
urllib.request
import
hashlib
import
re
if
len
(
sys
.
argv
)
<
3
:
...
...
@@ -27,6 +25,7 @@ arch = 'arm-linux-androideabi'
# the path to the MPD sources
mpd_path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
sys
.
argv
[
0
])
or
'.'
,
'..'
))
sys
.
path
[
0
]
=
os
.
path
.
join
(
mpd_path
,
'python'
)
# output directories
lib_path
=
os
.
path
.
abspath
(
'lib'
)
...
...
@@ -106,43 +105,8 @@ class AndroidNdkToolchain:
# default one on the build host
self
.
env
[
'PKG_CONFIG_LIBDIR'
]
=
os
.
path
.
join
(
install_prefix
,
'lib/pkgconfig'
)
def
file_md5
(
path
):
"""Calculate the MD5 checksum of a file and return it in hexadecimal notation."""
with
open
(
path
,
'rb'
)
as
f
:
m
=
hashlib
.
md5
()
while
True
:
data
=
f
.
read
(
65536
)
if
len
(
data
)
==
0
:
# end of file
return
m
.
hexdigest
()
m
.
update
(
data
)
def
download_tarball
(
url
,
md5
):
"""Download a tarball, verify its MD5 checksum and return the local path."""
global
tarball_path
os
.
makedirs
(
tarball_path
,
exist_ok
=
True
)
path
=
os
.
path
.
join
(
tarball_path
,
os
.
path
.
basename
(
url
))
try
:
calculated_md5
=
file_md5
(
path
)
if
md5
==
calculated_md5
:
return
path
os
.
unlink
(
path
)
except
FileNotFoundError
:
pass
tmp_path
=
path
+
'.tmp'
print
(
"download"
,
url
)
urllib
.
request
.
urlretrieve
(
url
,
tmp_path
)
calculated_md5
=
file_md5
(
tmp_path
)
if
calculated_md5
!=
md5
:
os
.
unlink
(
tmp_path
)
raise
"MD5 mismatch"
os
.
rename
(
tmp_path
,
path
)
return
path
from
build.download
import
download_and_verify
from
build.tar
import
untar
class
Project
:
def
__init__
(
self
,
url
,
md5
,
installed
,
name
=
None
,
version
=
None
,
...
...
@@ -172,7 +136,8 @@ class Project:
self
.
use_clang
=
use_clang
def
download
(
self
):
return
download_tarball
(
self
.
url
,
self
.
md5
)
global
tarball_path
return
download_and_verify
(
self
.
url
,
self
.
md5
,
tarball_path
)
def
is_installed
(
self
,
toolchain
):
tarball
=
self
.
download
()
...
...
@@ -185,15 +150,7 @@ class Project:
def
unpack
(
self
):
global
src_path
tarball
=
self
.
download
()
path
=
os
.
path
.
join
(
src_path
,
self
.
base
)
try
:
shutil
.
rmtree
(
path
)
except
FileNotFoundError
:
pass
os
.
makedirs
(
src_path
,
exist_ok
=
True
)
subprocess
.
check_call
([
'/bin/tar'
,
'xfC'
,
tarball
,
src_path
])
return
path
return
untar
(
self
.
download
(),
src_path
,
self
.
base
)
def
make_build_path
(
self
):
path
=
os
.
path
.
join
(
build_path
,
self
.
base
)
...
...
python/build/download.py
0 → 100644
View file @
556f9ee3
import
os
import
hashlib
import
urllib.request
def
file_md5
(
path
):
"""Calculate the MD5 checksum of a file and return it in hexadecimal notation."""
with
open
(
path
,
'rb'
)
as
f
:
m
=
hashlib
.
md5
()
while
True
:
data
=
f
.
read
(
65536
)
if
len
(
data
)
==
0
:
# end of file
return
m
.
hexdigest
()
m
.
update
(
data
)
def
download_and_verify
(
url
,
md5
,
parent_path
):
"""Download a file, verify its MD5 checksum and return the local path."""
os
.
makedirs
(
parent_path
,
exist_ok
=
True
)
path
=
os
.
path
.
join
(
parent_path
,
os
.
path
.
basename
(
url
))
try
:
calculated_md5
=
file_md5
(
path
)
if
md5
==
calculated_md5
:
return
path
os
.
unlink
(
path
)
except
FileNotFoundError
:
pass
tmp_path
=
path
+
'.tmp'
print
(
"download"
,
url
)
urllib
.
request
.
urlretrieve
(
url
,
tmp_path
)
calculated_md5
=
file_md5
(
tmp_path
)
if
calculated_md5
!=
md5
:
os
.
unlink
(
tmp_path
)
raise
"MD5 mismatch"
os
.
rename
(
tmp_path
,
path
)
return
path
python/build/tar.py
0 → 100644
View file @
556f9ee3
import
os
,
shutil
,
subprocess
def
untar
(
tarball_path
,
parent_path
,
base
):
path
=
os
.
path
.
join
(
parent_path
,
base
)
try
:
shutil
.
rmtree
(
path
)
except
FileNotFoundError
:
pass
os
.
makedirs
(
parent_path
,
exist_ok
=
True
)
subprocess
.
check_call
([
'/bin/tar'
,
'xfC'
,
tarball_path
,
parent_path
])
return
path
win32/build.py
View file @
556f9ee3
...
...
@@ -2,8 +2,6 @@
import
os
,
os
.
path
import
sys
,
shutil
,
subprocess
import
urllib.request
import
hashlib
import
re
configure_args
=
sys
.
argv
[
1
:]
...
...
@@ -16,6 +14,7 @@ if len(configure_args) > 0 and configure_args[0] == '--64':
# the path to the MPD sources
mpd_path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
sys
.
argv
[
0
])
or
'.'
,
'..'
))
sys
.
path
[
0
]
=
os
.
path
.
join
(
mpd_path
,
'python'
)
# output directories
lib_path
=
os
.
path
.
abspath
(
'lib'
)
...
...
@@ -55,43 +54,8 @@ class CrossGccToolchain:
# default one on the build host
self
.
env
[
'PKG_CONFIG_LIBDIR'
]
=
os
.
path
.
join
(
install_prefix
,
'lib/pkgconfig'
)
def
file_md5
(
path
):
"""Calculate the MD5 checksum of a file and return it in hexadecimal notation."""
with
open
(
path
,
'rb'
)
as
f
:
m
=
hashlib
.
md5
()
while
True
:
data
=
f
.
read
(
65536
)
if
len
(
data
)
==
0
:
# end of file
return
m
.
hexdigest
()
m
.
update
(
data
)
def
download_tarball
(
url
,
md5
):
"""Download a tarball, verify its MD5 checksum and return the local path."""
global
tarball_path
os
.
makedirs
(
tarball_path
,
exist_ok
=
True
)
path
=
os
.
path
.
join
(
tarball_path
,
os
.
path
.
basename
(
url
))
try
:
calculated_md5
=
file_md5
(
path
)
if
md5
==
calculated_md5
:
return
path
os
.
unlink
(
path
)
except
FileNotFoundError
:
pass
tmp_path
=
path
+
'.tmp'
print
(
"download"
,
url
)
urllib
.
request
.
urlretrieve
(
url
,
tmp_path
)
calculated_md5
=
file_md5
(
tmp_path
)
if
calculated_md5
!=
md5
:
os
.
unlink
(
tmp_path
)
raise
"MD5 mismatch"
os
.
rename
(
tmp_path
,
path
)
return
path
from
build.download
import
download_and_verify
from
build.tar
import
untar
class
Project
:
def
__init__
(
self
,
url
,
md5
,
installed
,
name
=
None
,
version
=
None
,
...
...
@@ -117,7 +81,7 @@ class Project:
self
.
installed
=
installed
def
download
(
self
):
return
download_
tarball
(
self
.
url
,
self
.
md5
)
return
download_
and_verify
(
self
.
url
,
self
.
md5
,
tarball_path
)
def
is_installed
(
self
,
toolchain
):
tarball
=
self
.
download
()
...
...
@@ -128,21 +92,9 @@ class Project:
except
FileNotFoundError
:
return
False
def
unpack
(
self
,
out_of_tree
=
True
):
global
src_path
,
build_path
tarball
=
self
.
download
()
if
out_of_tree
:
parent_path
=
src_path
else
:
parent_path
=
build_path
path
=
os
.
path
.
join
(
parent_path
,
self
.
base
)
try
:
shutil
.
rmtree
(
path
)
except
FileNotFoundError
:
pass
os
.
makedirs
(
parent_path
,
exist_ok
=
True
)
subprocess
.
check_call
([
'/bin/tar'
,
'xfC'
,
tarball
,
parent_path
])
return
path
def
unpack
(
self
):
global
src_path
return
untar
(
self
.
download
(),
src_path
,
self
.
base
)
def
make_build_path
(
self
):
path
=
os
.
path
.
join
(
build_path
,
self
.
base
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment