@ -20,6 +20,42 @@ local BLACKLIST = {
' ^usr/share/ ' ,
}
local COMMON_FILES = {
[ ' gcc-isl ' ] = {
' ^usr/include/isl/ ' ,
' ^usr/lib/libisl%. ' ,
' ^usr/lib/pkgconfig/isl.pc$ ' ,
} ,
[ ' gcc-mpc ' ] = {
' ^usr/include/mpc.h$ ' ,
' ^usr/lib/libmpc%. ' ,
} ,
[ ' gcc-gmp ' ] = {
' ^usr/include/gmp.h$ ' ,
' ^usr/lib/libgmp%. ' ,
} ,
[ ' gcc-mpfr ' ] = {
' ^usr/include/mpf2mpfr.h$ ' ,
' ^usr/include/mpfr.h$ ' ,
' ^usr/lib/libmpfr%. ' ,
} ,
[ ' gcc ' ] = {
' ^usr/lib/libcc1%. ' ,
} ,
[ ' yasm ' ] = {
' ^usr/include/libyasm ' ,
' ^usr/lib/libyasm.a$ ' ,
} ,
[ ' ncurses ' ] = {
' ^usr/lib/pkgconfig/ ' ,
} ,
[ ' pkgconf ' ] = {
' ^usr/bin/config.guess$ ' ,
} ,
}
local ARCH_FOR_COMMON = ' i686-w64-mingw32.static '
local target -- used by many functions
local function log ( ... )
@ -135,8 +171,8 @@ local function sortForBuild(pkgs, pkg2deps)
return build_list
end
local function is Blacklisted( file )
for _ , pattern in ipairs ( BLACKLIST ) do
local function is Listed( file , list )
for _ , pattern in ipairs ( list ) do
if file : match ( pattern ) then
return true
end
@ -144,6 +180,10 @@ local function isBlacklisted(file)
return false
end
local function isBlacklisted ( file )
return isListed ( file , BLACKLIST )
end
-- return set of all filepaths under ./usr/
local function findFiles ( )
local files = { }
@ -173,9 +213,9 @@ local function buildPackage(pkg)
return new_files
end
local function nameToDebian ( pkg )
local function nameToDebian ( pkg , t )
local name = ' mxe-%s-%s '
name = name : format ( t arget, pkg )
name = name : format ( t or t arget, pkg )
name = name : gsub ( ' _ ' , ' - ' )
return name
end
@ -206,7 +246,7 @@ Description: MXE package %s for %s
This package contains the files for MXE package % s .
] ]
local function makeDeb ( pkg , list_path , deps , ver )
local function makeDeb ( pkg , list_path , deps , ver , add_common )
local deb_pkg = nameToDebian ( pkg )
local dirname = ( ' %s_%s ' ) : format ( deb_pkg ,
protectVersion ( ver ) )
@ -225,6 +265,9 @@ local function makeDeb(pkg, list_path, deps, ver)
for _ , dep in ipairs ( deps ) do
table.insert ( deb_deps , nameToDebian ( dep ) )
end
if add_common then
table.insert ( deb_deps , nameToDebian ( pkg , ' common ' ) )
end
local deb_deps_str = table.concat ( deb_deps , ' , ' )
-- make DEBIAN/control file
os.execute ( ( ' mkdir -p %s/DEBIAN ' ) : format ( dirname ) )
@ -240,8 +283,15 @@ local function makeDeb(pkg, list_path, deps, ver)
os.execute ( ( ' rm -fr %s deb.fakeroot ' ) : format ( dirname ) )
end
local function saveFileList ( pkg , list )
local list_file = pkg .. ' .list '
local function readFileList ( list_file )
local list = { }
for installed_file in io.lines ( list_file ) do
table.insert ( list , installed_file )
end
return list
end
local function saveFileList ( list_file , list )
local file = io.open ( list_file , ' w ' )
for _ , installed_file in ipairs ( list ) do
file : write ( installed_file .. ' \n ' )
@ -265,7 +315,7 @@ local function buildPackages(pkgs, pkg2deps)
if not brokenDep ( pkg ) then
local files = buildPackage ( pkg )
if # files > 0 then
saveFileList ( pkg , files )
saveFileList ( pkg .. ' .list ' , files )
table.insert ( unbroken , pkg )
else
-- broken package
@ -280,11 +330,48 @@ local function buildPackages(pkgs, pkg2deps)
return unbroken
end
local function filterFiles ( pkg , filter_common )
local list = readFileList ( pkg .. ' .list ' )
local list2 = { }
local common_list = COMMON_FILES [ pkg ]
for _ , installed_file in ipairs ( list ) do
local listed = isListed ( installed_file , common_list )
if listed == filter_common then
table.insert ( list2 , installed_file )
end
end
return list2
end
local function excludeCommon ( pkg )
local noncommon_files = filterFiles ( pkg , false )
saveFileList ( pkg .. ' .list ' , noncommon_files )
end
local function makeCommonDeb ( pkg , ver )
local common_files = filterFiles ( pkg , true )
local list_path = pkg .. ' .common-list '
saveFileList ( list_path , common_files )
local orig_target = target
target = ' common '
makeDeb ( pkg , list_path , { } , ver )
target = orig_target
end
local function makeDebs ( pkgs , pkg2deps , pkg2ver )
for _ , pkg in ipairs ( pkgs ) do
local deps = assert ( pkg2deps [ pkg ] , pkg )
local ver = assert ( pkg2ver [ pkg ] , pkg )
makeDeb ( pkg , pkg .. ' .list ' , deps , ver )
local list_path = pkg .. ' .list '
local add_common = false
if COMMON_FILES [ pkg ] then
if target == ARCH_FOR_COMMON then
makeCommonDeb ( pkg , ver )
end
add_common = true
excludeCommon ( pkg )
end
makeDeb ( pkg , list_path , deps , ver , add_common )
end
end