Copy files from older repository

This commit is contained in:
Jakub Szymański 2018-09-14 15:56:49 +02:00
parent 63ed1ec636
commit 97fb68b04f
64 changed files with 11376 additions and 2 deletions

5
.gitattributes vendored Normal file
View File

@ -0,0 +1,5 @@
configure.ac filter=version
debian/changelog filter=version
src/woeusb filter=version
src/woeusb.1 filter=version
src/woeusbgui.1 filter=version

5
.gitconfig Normal file
View File

@ -0,0 +1,5 @@
# Project-specific Git Configuration
# DOC: man: git-config
[filter "version"]
clean = filters/clean-version.bash
smudge = filters/smudge-version.bash

View File

@ -0,0 +1 @@
This is a dummy file for package uploaders to resolve the undenyable GitHub Release source code archives.

36
.github/issue_template.md vendored Normal file
View File

@ -0,0 +1,36 @@
## Good Habit Checklist for Issue Reporting
Checkout [Mastering Markdown · GitHub Guides](https://guides.github.com/features/mastering-markdown/#GitHub-flavored-markdown) if you needs help on the GitHub-flavored Markdown syntax. You may remove sections and contents that don't apply.
* [ ] I've searched the issue tracker and is pretty sure that there's no duplicate issue already filed
* [ ] I've built the latest development snapshot using the instructions in README and verified that the issue can still be reproduced (for bug reports)
## Issue Reproduce Instructions
> 1. Launch WoeUSB by running `<command>`
> 2. Do blablabla...
## Expected Behavior
> No error
## Current Behavior
> WoeUSB errors with message "blablabla"
## Info of My Environment
### WoeUSB Version
> For source code build, run `git describe --tags --always --dirty` under the source tree, for prebuilt releases refer the source that provides WoeUSB
### WoeUSB Source
> Built from source code, commit abcdefg
> Installed from Ubuntu 16.04 software archive
> Installed from WebUpd8 PPA
### GNU Bash Version
> WoeUSB exploits several advanced features of the Bash scripting language and requires a relatively-recent Bash intepreter. Run `bash --version` in a terminal to acquire this information.
### Information about the Operating System
> Different OS distributions provides different characteristics and may influence the result of running WoeUSB. Run `lsb_release --description` or `lsb_release -d` in a terminal to acquire this information.
### Information about the Source Media
> "Windows 9 Professional Edition" downloaded from <https://microsoft.com/download/windows-9>
### Information about the Target Device
> Transcend JetFlash® 790K 64GB (USB 3.1 variant)

42
.gitignore vendored Normal file
View File

@ -0,0 +1,42 @@
# Git Tracking Ignore Rules
## Debian package build generated files
/debian/woeusb*
/debian/files
/src/stamp-h1
/debian/.debhelper/
/debian/autoreconf.*
/debian/debhelper-build-stamp
## Files generated by Autoconf
*Makefile
Makefile.in
/config.*
/libtool
/src/config.hpp
/build-stamp
/autom4te.cache/
/configure
/config.*
/aclocal.m4
/depcomp
/missing
/install-sh
/ltmain.sh
/compile
/m4/
/src/config.hpp.in
## Files generated by WxWidgets build
/src/.deps/
## Compiled object code
*.o
*.pyc
## Gettext compiled message catalogs
*.mo
\.idea/
doc/_build
venv/

45
.travis.yml Normal file
View File

@ -0,0 +1,45 @@
# Travis CI Configuration
# https://docs.travis-ci.com
## Lesser history
git:
depth: 30
## Use container-based infrastructure for quicker build start-up
sudo: false
## We only support Ubuntu 14.04 and newer
dist: trusty
addons:
apt:
packages:
- realpath # Not required least after 16.04
- autotools-dev
- libwxgtk2.8-dev
- devscripts # For mk-build-deps
- equivs # mk-build-deps requires this to be installed
language: cpp
compiler:
- gcc
script:
# For triggering smudge-version
- ./setup-development-environment.bash
- mk-build-deps && mv woeusb-build-deps*.deb ..
- autoreconf --force --install
- ./configure
- make
deploy:
provider: releases
api_key:
secure: RJHRp/Ou83QtkZXdS/UXiOIf1hfsUzg1ZPVZNi18oNTQcMwcHut9IqsaJEb5ZmwdC9/0TIqkoXaPTXUatVS5G+OaPXhFh0FPWFlzpIKIa4xiM7juhoettvK50r7B0+QyfIcMuZ+wTP6h3itXkeGm97xTqOnMmGn2BpefmAQ8nMKcw6ehD9F1LFPIiGJSw16Sli5b4s9hkyJtslyxjriWsLypuIFA+z7/PAPFj4UmbAqNCTQH3yHUHkNPHomf0S405uecgGlV4eYqc10nNP0Y/2gN1pDwSx7HNbCSR/ufhLXc2dH+JBho7lJRCCaJKZ2PX2JeCndWOLAmKkuz2snV/aMcDzaXb6G5MQ3UPKsbaMJHaiKzz48LBDVeOsbhL7FF4cs+JdiPQGaTzTTSg35j6MXM28WirJ7VxEpVRxjrILgbRXasJIRXaB0Ttimgu2L2fJr2GDT3EBfVj5mT+GpXgsqwXlGP/QBKrB1170g4ATPHKmzmXqCYo7DZw6qZ5T1G0ZiZm9TX82OlYuNNo7fkuquo6Q7z6kJRlwmI0PPnR54IUuI6wrcOvWc/PoEBhRQvGpzyBadiLeFoQrAgHofcnGPfIbqmY/2cZiZza/XvnxVwa1NEHCGXZEcRYHeAQyRGtikxUNuhlP93sDLvPg61QuQVV/y+yXVVtuFDrLuL+L4=
file_glob: true
file:
- ../woeusb-build-deps*.deb
- ".github/The source code archives provided here is NOT supported, please use git-clone instead"
on:
repo: slacka/WoeUSB
tags: true

1
AUTHORS Normal file
View File

@ -0,0 +1 @@
Colin GILLE / congelli501 <colingille@hotmail.com>

73
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,73 @@
# Contributing Guidelines
This document explains how to contribute to this project in many aspects. Please make sure to read this thoroughly before making any contributions.
## Reporting Issues
The so-called "issue" includes but is not limited to software bugs and suggestions
### Always Search for Duplicates Before Filing a New Issue
There is a possibility that your issue has already been filed, so please search the issue tracker before filing a new one
When searching, use keywords instead of full sentences. For example, search "crash unbounded variable" instead of "The program crashes with 'unbounded variable' message printed on screen".
### Report Software Bugs Effectively
How you report software bugs greatly affects how fast it can be processed and fixed, refer to [How to Report Bugs Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html) for more information
## Localize (Translate) the Software
If you are fluent in a language other than English, you may help this project by translating it to your language. This is called localization or L10N for short. This software has already been internationalized so that it is capable of displaying different languages.
Also, please consider translating our documentation to the language that you are fluent in.
## Improving Documentation
The documentation of this project may be outdated through time, and needs help to keep it up to date.
### Manual Pages (manpages)
Refer to the following articles for reference on writing manpages:
* [Linux Man Page Howto](http://www.schweikhardt.net/man_page_howto.html)
* [The GNU Troff Manual](https://www.gnu.org/software/groff/manual)
- [The GNU Troff Manual: Macro Packages » man » Usage](https://www.gnu.org/software/groff/manual/html_node/Man-usage.html#Man-usage)
- [The GNU Troff Manual: Escapes](https://www.gnu.org/software/groff/manual/html_node/Escapes.html#Escapes)
- [The GNU Troff Manual: Fonts and Symbols](https://www.gnu.org/software/groff/manual/html_node/Fonts-and-Symbols.html#Fonts-and-Symbols)
## Improving Code
There are so many aspects of the code that can be improved, however, please consider the following topics while doing so.
### Coding Style
It is required to mimic the coding style of the current code
#### Indentation
This project uses tab characters for indentation as it's width can be flexibly configured in many text editors
#### Padding Spaces
* Padding is required for operators
* Padding is avoided for the outer curly braces
#### Word Separating Method
NOTE: This currently only applies to the GNU Bash shell scripts.
* Underscore for variable names
* Underscore for function names
### Defensive Bash Programming
* All parameters that are assigned a value should be declared as read-only parameter to remain unchanged throughout the code
* All non-readonly parameters should be UNSET right after they are not used.
* Function parameters should be caught by `local` parameters instead of directly referenced using positional parameter syntax
* To increase code reusability, avoid referencing global variables from a function, alway pass it by function arguments
### Character Encoding of Files
We use UTF-8 encoding for all of our files
## Promote This Project to Others
It is appreciated if you share this project with others. Also, if you write an article about this project, plese share it with us, we'd love to hear about it!
## Design Artwork/Logos for This Software
All current artwork is stored under src/data. Please only use materials that are under a free license.
## Hints on Using the Git VCS
### Create commits based on minimal independent changes
Avoid creating commits that do multiple things at once as this will help other developers understand the change history.
### Write Comprehensible Commit Messages
Use concrete language on what the commit does in the commit message.
### Avoid Changing History That Has Been Pushed to Remote Repository

View File

@ -672,3 +672,4 @@ may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

3
ChangeLog Normal file
View File

@ -0,0 +1,3 @@
2017-06-13 林博仁 <Buo.Ren.Lin@gmail.com>
* We no longer use ChangeLog as we use Git as our VCS, please refer `git log` or refer Commits · slacka/WoeUSB <https://github.com/slacka/WoeUSB/commits/master> for changelog of WoeUSB.

16
Makefile.am Normal file
View File

@ -0,0 +1,16 @@
SUBDIRS = \
src\
innoSetup\
debian
# M4
## Pour fichier COPYING
pkgdocdir=$(prefix)
if IS_MINGW
pkgdoc_DATA = $(srcdir)/COPYING
endif
EXTRA_DIST = $(srcdir)/os

0
NEWS Normal file
View File

View File

@ -1,2 +1,80 @@
# WoeUSB-ng
WoeUSB is a simple tool that enable you to create your own usb stick windows installer from an iso image or a real DVD.
# WoeUSB
[![Latest Release](https://img.shields.io/github/release/slacka/WoeUSB.svg)](https://github.com/WaxyMocha/WoeUSB-ng/releases)
[![WoeUSB License](https://img.shields.io/badge/license-gpl-blue.svg)](https://github.com/WaxyMocha/WoeUSB-ng/blob/master/COPYING)
[![Build Status](https://travis-ci.org/slacka/WoeUSB.svg?branch=master)](https://travis-ci.org/slacka/WoeUSB)
![brand](src/data/woeusb-logo.png)[![thumbnail of GUI wrapper screenshot](dev/woeusbgui-screenshot.thumbnail.png)](dev/woeusbgui-screenshot.png)[![thumbnail of CLI application screenshot](dev/woeusb-screenshot.thumbnail.png)](dev/woeusb-screenshot.png)
_A Linux program to create a Windows USB stick installer from a real Windows DVD or image._
This package contains two programs:
* woeusb: A command-line utility that enables you to create your own bootable Windows installation USB storage device from an existing Windows Installation disc or disk image
* woeusbgui: A GUI wrapper of woeusb based on WxWidgets
Supported images:
Windows Vista, Windows 7, Window 8.x, Windows 10. All languages and any version (home, pro...) and Windows PE are supported.
Supported bootmodes:
* Legacy/MBR-style/IBM PC compatible bootmode
* Native UEFI booting is supported for Windows 7 and later images (limited to the FAT filesystem as the target)
This project is a fork of [Congelli501's WinUSB software](http://en.congelli.eu/prog_info_winusb.html), which has not been maintained since 2012, according to the official website.
## Installation
### Prebuilt Packages
Note that prebuilt packages are not necessarily the latest release and we are NOT responsible for the trustworthiness of these packages. Regarding any related issues contact its maintainer first.
#### Official Distribution Packages
* [Fedora](https://src.fedoraproject.org/rpms/WoeUSB) packages maintained by mprahl
#### Third-party Distribution Packages
* [Arch Linux](https://aur.archlinux.org/packages/woeusb-git/) packages maintained by darkfm
* [Ubuntu](https://launchpad.net/%7Enilarimogard/+archive/ubuntu/webupd8) packages maintained by [WebUpd8](http://www.webupd8.org/)
### Build from Source
The following are the instructions to install WoeUSB if prebuilt version is not available or too old.
#### Acquire WoeUSB's Source Code
Clone WoeUSB's Git repository to your local machine using `git clone https://github.com/slacka/WoeUSB.git`
NOTE: We no longer support building from source archives provided in the GitHub Releases page as the software version is not set.
#### Setting the Application Version String
This step is required for generating the proper version name based on the Git tags. This step should be repeated if the version is changed.
```shell
$ ./setup-development-environment.bash
```
#### Install WoeUSB's Build Dependencies
```shell
# For Debian-based distributions (NOTE: For your convenience, this package is already provided in the release page)
$ sudo apt-get install devscripts equivs gdebi-core
$ cd <WoeUSB source code directory>
$ mk-build-deps # NOTE: Currently, due to Debian Bug #679101, this command will fail if the source path contains spaces.
$ sudo gdebi woeusb-build-deps_<version>_all.deb
# For Fedora > 22
$ sudo dnf install wxGTK3-devel
# For Fedora 22
$ sudo dnf install wxGTK-devel dh-autoreconf.noarch
```
#### Build & Install WoeUSB
```shell
# For Debian-based distributions
$ dpkg-buildpackage -uc -b # NOTE: Currently, due to a bug in the build system, this command will fail if the source's path contains space or single quotes, refer to issue #84 for details
$ sudo gdebi ../woeusb_<version>_<architecture>.deb
# Generic method
$ autoreconf --force --install # Most non-Debian derived distros will need this
$ ./configure
$ make
$ sudo make install
```
## License
WoeUSB is distributed under the [GPL license](https://github.com/slacka/WoeUSB/blob/master/COPYING).

894
acinclude.m4 Normal file
View File

@ -0,0 +1,894 @@
dnl ---------------------------------------------------------------------------
dnl MY_FIND_SFML()
dnl Find SFML lib
dnl ---------------------------------------------------------------------------
AC_DEFUN([MY_FIND_SFML],
[
dnl OpenGL header
AM_CHECK_LIB_HEADER([GL], [gl], [GL/gl.h], [], [], AC_MSG_ERROR([ /!\ This programme requires OpenGL headers !]))
dnl SFML
if test "$IS_MAC" = 'true'; then
CHECK_FRAMEWORK_LIST([SFML], [SFML sfml-graphics sfml-window sfml-system sfml-audio])
else
AM_CHECK_LIB_HEADER([SFML], [sfml], [SFML/Graphics.hpp SFML/Window.hpp SFML/Audio.hpp SFML/System.hpp], [sfml-graphics sfml-window sfml-system sfml-audio], [], AC_MSG_ERROR([ /!\ This programme requires SFML !]))
fi
])
dnl ---------------------------------------------------------------------------
dnl MY_FIND_LIBNOTIFY()
dnl Find LIBNOTIFY lib
dnl ---------------------------------------------------------------------------
AC_DEFUN([MY_FIND_LIBNOTIFY],
[
dnl Pkg Config (cf man pkg-config => AUTOCONF MACROS)
PKG_PROG_PKG_CONFIG dnl Check is 'pkg-config' is installed
AH_TEMPLATE([USE_LIBNOTIFY], [Define if libnotify can be used.])
AH_TEMPLATE([USE_LIBNOTIFY_NEW], [Define if libnotify version is more than 0.7.3 because Gnome decided to change the API.])
if test "$IS_MINGW" = 'true'; then
AC_DEFINE([USE_LIBNOTIFY], [0])
else
PKG_CHECK_MODULES([LIBNOTIFY], [libnotify >= 0.4], AC_DEFINE([USE_LIBNOTIFY], [1]), AC_DEFINE([USE_LIBNOTIFY], [0]))
PKG_CHECK_MODULES([LIBNOTIFY_NEW], [libnotify >= 0.7.3], AC_DEFINE([USE_LIBNOTIFY_NEW], [1]), AC_DEFINE([USE_LIBNOTIFY_NEW], [0]))
LIBS_ALL="$LIBS_ALL ${LIBNOTIFY_LIBS}"
AC_SUBST([LIBS_ALL], [$LIBS_ALL])
CFLAGS_ALL="$CFLAGS_ALL ${LIBNOTIFY_CFLAGS}"
AC_SUBST([CFLAGS_ALL], [$CFLAGS_ALL])
fi
])
dnl ---------------------------------------------------------------------------
dnl MY_FIND_WXWIDGETS()
dnl Find WXWIDGETS lib
dnl ---------------------------------------------------------------------------
AC_DEFUN([MY_FIND_WXWIDGETS],
[
AM_OPTIONS_WXCONFIG
AM_PATH_WXCONFIG(2.8.4, wxWin=1, , [xrc,std])
if test "$wxWin" != 1; then
AC_MSG_ERROR([
wxWidgets must be installed on your system.
Please check that wx-config is in path, the directory
where wxWidgets libraries are installed (returned by
'wx-config --libs' or 'wx-config --static --libs' command)
is in LD_LIBRARY_PATH or equivalent variable and
wxWidgets version is 2.8.4 or above.
])
fi
dnl All lib options
LIBS_ALL="$LIBS_ALL ${WX_LIBS}"
AC_SUBST([LIBS_ALL], [$LIBS_ALL])
CFLAGS_ALL="$CFLAGS_ALL ${WX_CXXFLAGS}"
AC_SUBST([CFLAGS_ALL], [$CFLAGS_ALL])
if test "$IS_MINGW" = 'true'; then
EXTRA_WINDRES_ARG="$EXTRA_WINDRES_ARG $(echo "$WX_CXXFLAGS" | cut -d " " -f 1-2)" ## Pour n'avoir que les deux premiers chanps (inclue).'
AC_SUBST([EXTRA_WINDRES_ARG])
fi
])
dnl ---------------------------------------------------------------------------
dnl MY_FIND_BOOST()
dnl Find BOOST lib
dnl ---------------------------------------------------------------------------
AC_DEFUN([MY_FIND_BOOST],
[
dnl Boost
AM_CHECK_LIB_HEADER([BOOST], [boost], [boost/config.hpp], [], [], AC_MSG_ERROR([ /!\ This programme requires boost !]))
])
dnl ---------------------------------------------------------------------------
dnl MY_FIND_GTK2()
dnl Find BOOST lib
dnl ---------------------------------------------------------------------------
AC_DEFUN([MY_FIND_GTK2],
[
dnl gtk+2
if test "$IS_MINGW" = 'false'; then
AM_CHECK_LIB_HEADER([GTK2], [gtk+-2.0], [gdk/gdkx.h gtk/gtk.h], [gtk-x11-2.0], [], AC_MSG_ERROR([ /!\ This programme requires gtk+ 2 !]))
fi
])
dnl ---------------------------------------------------------------------------
dnl MY_FIND_LUA()
dnl Find LUA lib
dnl ---------------------------------------------------------------------------
AC_DEFUN([MY_FIND_LUA],
[
dnl LUA
LUA_VERSION="5.1" dnl Sous windows, la lib s'appelle lua, et pas lua5.1, Sous Ubunut, la lib s'appelle lua !
AM_CHECK_LIB_HEADER([LUA], [lua${LUA_VERSION}], [lua.hpp], [lua @ lua${LUA_VERSION}], [], [AC_MSG_ERROR([ /!\ This programme requires LUA !])])
])
dnl ---------------------------------------------------------------------------
dnl MY_FIND_OPENGL()
dnl Find OPENGL lib
dnl ---------------------------------------------------------------------------
AC_DEFUN([MY_FIND_OPENGL],
[
dnl OpenGL header
AM_CHECK_LIB_HEADER([GL], [gl], [GL/gl.h], [], [], AC_MSG_ERROR([ /!\ This programme requires OpenGL headers !]))
dnl OpenGL WIN32 & MAC
if test "$IS_MINGW" = 'true'; then
dnl intl (gettext)
AM_CHECK_LIB_HEADER([OGLWIN], [], [], [opengl32 glu32], [], [AC_MSG_ERROR([ /!\ This programme requires intl (gettext) !])])
elif test "$IS_MAC" = 'true'; then
CHECK_FRAMEWORK_LIST([SFML], [OpenGL GLUT])
fi
])
dnl ---------------------------------------------------------------------------
dnl MY_FIND_INTL()
dnl Find INTL lib
dnl ---------------------------------------------------------------------------
AC_DEFUN([MY_FIND_INTL],
[
dnl intl (gettext)
if test "$IS_LINUX" = 'false'; then
AM_CHECK_LIB_HEADER([INTL], [intl], [libintl.h locale.h], [intl], [], [AC_MSG_ERROR([ /!\ This programme requires intl (gettext) !])])
fi
])
dnl ---------------------------------------------------------------------------
dnl MY_FIND_STDCPP()
dnl Find stdc++ lib
dnl ---------------------------------------------------------------------------
AC_DEFUN([MY_FIND_STDCPP],
[
dnl STL, pas sous windows comme on passe en stdc++ static
if test "$IS_MINGW" = 'false'; then
AC_CHECK_LIB(stdc++, main,,AC_MSG_ERROR([ /!\ This programme requires libstdc++ !]))
fi
])
dnl ---------------------------------------------------------------------------
dnl MY_PACKAGE_INIT(package full name)
dnl
dnl Init the source package
dnl
dnl ---------------------------------------------------------------------------
AC_DEFUN([MY_PACKAGE_INIT],
[
AM_CONFIG_HEADER(src/config.hpp)
AC_SUBST(VERSION)
ISODATE=`date +%Y-%m-%d`
AC_SUBST([ISODATE])
PACKAGE_NAME="$1"
AC_SUBST([PACKAGE_NAME])
AC_DEFINE_UNQUOTED([PACKAGE_NAME], ["$PACKAGE_NAME"])
])
dnl ---------------------------------------------------------------------------
dnl MY_INIT_CPP_PROGS()
dnl
dnl Init programs for C++ sources
dnl
dnl ---------------------------------------------------------------------------
dnl AC_DEFUN([MY_INIT_CPP_PROGS],
dnl [
dnl dnl Checks for programs.
dnl AC_PROG_INSTALL
dnl #AC_PROG_CC
dnl AC_PROG_CXX
dnl AC_PROG_CPP
dnl AC_PROG_LN_S
dnl ])
dnl ---------------------------------------------------------------------------
dnl MY_ECHO_BUILD_INFO()
dnl
dnl Init programs for C++ sources
dnl
dnl ---------------------------------------------------------------------------
AC_DEFUN([MY_ECHO_BUILD_INFO],
[
# Autre
INFO_LINE="####################################"
# Recap
MSG="The package is now configured. You should type make !"
MSG="$MSG\n DEBUG MODE : "
if test "$DEBUG" = 1; then
debugModeStr="enable"
else
debugModeStr="disable"
fi
MSG="${MSG}${debugModeStr}."
MSG="$MSG\n TARGET PLATFORM : "
MSG="${MSG}${MY_TARGET_OS}."
MSG="$MSG\n INSTALLATION PREFIX : "
MSG="${MSG}${prefix}."
echo -e "\n${INFO_LINE}\n\n${MSG}\n\n${INFO_LINE}\n"
])
dnl ---------------------------------------------------------------------------
dnl MY_INIT_LIBTOOL
dnl
dnl Init libtool
dnl
dnl ---------------------------------------------------------------------------
dnl AC_DEFUN([MY_INIT_LIBTOOL],
dnl [
dnl dnl To compile libs
dnl AM_PROG_LIBTOOL dnl indique que l'on utilise Libtool pour la compilation
dnl AC_PROG_MAKE_SET dnl indique que l'on doit disposer de make qui est utilisé par Libtool
dnl ])
dnl ---------------------------------------------------------------------------
dnl MY_INIT_DEBUG_SWITCH([Force debug])
dnl
dnl Allow the user tu build the program in debug mode ; doesn't edit any cpp options !
dnl
dnl ---------------------------------------------------------------------------
AC_DEFUN([MY_INIT_DEBUG_SWITCH],
[
dnl debug
DEBUG=0
AC_ARG_ENABLE([debug], [ --enable-debug Chose if the package should be built in debug mode], [DEBUG=1])
dnl Force debug
if test "$1" = "true" || test "$1" = "1"; then
DEBUG=1
fi
AC_MSG_CHECKING([if debug is enabled])
AH_TEMPLATE([DEBUG], [Define is a debug version sould be build])
AM_CONDITIONAL([IS_DEBUG], [test "$DEBUG" -eq 1])
AC_DEFINE_UNQUOTED([DEBUG], [$DEBUG])
if test "$DEBUG" -eq 1; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
])
dnl ---------------------------------------------------------------------------
dnl MY_INIT_BUILD_OPTION(Debug option, no debug option)
dnl
dnl Init CXXFLAGS and CPPFLAGS
dnl
dnl ---------------------------------------------------------------------------
AC_DEFUN([MY_INIT_BUILD_OPTION],
[
dnl Basic
warningOptions=' -Wall -Wclobbered -Wempty-body -Wmissing-field-initializers -Wsign-compare -Wtype-limits -Wuninitialized' # -Wignored-qualifiers
if test "$IS_MAC" = 'true'; then
warningOptions=' -Wall'
fi
if test "$DEBUG" -eq 1; then
CXXFLAGS="$1 $warningOptions"
else
CXXFLAGS="$2 $warningOptions"
fi
CPPFLAGS=${CXXFLAGS}
AC_SUBST([CXXFLAGS])
AC_SUBST([CPPFLAGS])
dnl Extra LDFLAGS (for win32)
EXTRA_LDFLAGS=''
if test "$IS_MINGW" = "true"; then
true
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -static-libgcc -static-libstdc++" dnl Static stdc++
if test "$DEBUG" -eq 0; then
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -mwindows"
dnl -mwindows : Pour cacher la console sous windows.
fi
fi
AC_SUBST([EXTRA_LDFLAGS])
dnl EXTRA_WINDRES_ARG
EXTRA_WINDRES_ARG="$EXTRA_WINDRES_ARG"
AC_SUBST([EXTRA_WINDRES_ARG])
])
dnl ---------------------------------------------------------------------------
dnl MY_INIT_DATA_PATH
dnl
dnl Define data path for unix / win32 depending on the current target system
dnl
dnl ---------------------------------------------------------------------------
AC_DEFUN([MY_INIT_DATA_PATH],
[
if test "$IS_MINGW" = true; then
mypkgdatadir="$prefix"
bindir="$prefix"
AC_SUBST([mypkgdatadir])
AC_SUBST([prefix])
else
mypkgdatadir="$datadir/$PACKAGE"
AC_SUBST([mypkgdatadir])
fi
])
dnl ---------------------------------------------------------------------------
dnl AM_CHECK_LIB_HEADER(LIBNAME-MAJ, NAME, HEADERS, LIBS, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl
dnl My lib & header check
dnl
dnl Example use:
dnl AM_CHECK_LIB_HEADER([LUA], [lua], [lua.hpp], [lua5.1], [], [Error])
dnl ---------------------------------------------------------------------------
AC_DEFUN([AM_CHECK_LIB_HEADER],
[
declare $1_CFLAGS=''
declare $1_LIBS=''
dnl Headers
dnl We try with check-headers
headerOk=1
for headerName in $3; do
AC_CHECK_HEADERS([$headerName],[],[headerOk=0])
done
dnl Libs
backLibs="$LIBS"
libsOk=1
libsList=''
isLastField=0
fieldId=1
while test "$isLastField" -eq 0; do
toTestLibsList=''
if ! echo "$4" | grep '@' > '/dev/null'; then
dnl Only on field
isLastField=1
toTestLibsList="$4"
else
toTestLibsList="$(echo $4 | cut -d'@' -f$fieldId)"
fi
if test -n "$toTestLibsList"; then
libsList=''
libsOk=1
for libName in $toTestLibsList; do
AC_CHECK_LIB([$libName], [main], [], [libsOk=0])
libsList="$libsList -l$libName"
done
else
isLastField=1 dnl Fin
libsList=''
if test -n "$4"; then
dnl Liste se finie par "|" => pas ok !
libsOk=0
else
dnl Liste vide => ok !
libsOk=1
fi
fi
if test "$libsOk" -eq 1; then
dnl On a trouvé une liste qui marche => on arrète !
isLastField=1
fi
let fieldId=fieldId+1
done
AC_SUBST([LIBS], [$backLibs])
dnl pkg-config
if test "$headerOk" -eq 0 || test "$libsOk" -eq 0; then
if test -n "$2"; then
dnl We try with pkg-config
PKG_PROG_PKG_CONFIG
PKG_CHECK_MODULES([$1], [$2], [headerOk=1; libsOk=1], [])
if test "$headerOk" -eq 0 || test "$libsOk" -eq 0; then
dnl Still not found
$6
true # We need a command if $6 is empty
else
dnl All si Ok
$5
true # We need a command if $5 is empty
fi
else
dnl Not found
$6
true # We need a command if $6 is empty
fi
else
dnl All is Ok
AC_SUBST([$1_LIBS], [$libsList])
AC_SUBST([$1_CFLAGS], [''])
$5
fi
dnl All lib options
LIBS_ALL="$LIBS_ALL ${$1_LIBS}"
AC_SUBST([LIBS_ALL], [$LIBS_ALL])
CFLAGS_ALL="$CFLAGS_ALL ${$1_CFLAGS}"
AC_SUBST([CFLAGS_ALL], [$CFLAGS_ALL])
])
dnl ---------------------------------------------------------------------------
dnl CHECK_FRAMEWORK_LIST(libNameMaj, framework list)
dnl
dnl Check for windows ressources compiler (windres)
dnl
dnl Example use:
dnl CHECK_FRAMEWORK_LIST([SFML], [SFML sfml-graphics sfml-window sfml-system sfml-audio])
dnl ---------------------------------------------------------------------------
AC_DEFUN([CHECK_FRAMEWORK_LIST],
[
frameworkPathList="/System/Library/Frameworks /Library/Frameworks"
declare $1_CFLAGS=''
declare $1_LIBS=''
frameworksOk=1
frameworksList=''
isLastField=0
fieldId=1
while test "$isLastField" -eq 0; do
toTestframeworksList=''
if ! echo "$2" | grep '@' > '/dev/null'; then
dnl Only on field
isLastField=1
toTestframeworksList="$2"
else
toTestframeworksList="$(echo $2 | cut -d'@' -f$fieldId)"
fi
if test -n "$toTestframeworksList"; then
frameworksList=''
frameworksOk=1
for frameworkName in $toTestframeworksList; do
AC_MSG_CHECKING([for framework $frameworkName])
isThisFrameworkOk=0
for frameworkPath in $frameworkPathList; do
dir="$frameworkPath/$frameworkName.framework/Versions/Current"
if test -d "$dir"; then
isThisFrameworkOk=1
frameworksList="$frameworksList -framework $frameworkName"
AC_MSG_RESULT([yes : $dir])
break
fi
done
AC_MSG_RESULT([no])
done
else
isLastField=1 dnl Fin
frameworksList=''
if test -n "$2"; then
dnl Liste se finie par "|" => pas ok !
frameworksOk=0
else
dnl Liste vide => ok !
frameworksOk=1
fi
fi
if test "$frameworksOk" -eq 1; then
dnl On a trouvé une liste qui marche => on arrète !
isLastField=1
fi
let fieldId=fieldId+1
done
dnl Save
if test "$frameworksOk" -eq 1; then
AC_SUBST([$1_LIBS], [$frameworksList])
AC_SUBST([$1_CFLAGS], [$frameworksList])
dnl All lib options
LIBS_ALL="$LIBS_ALL ${$1_LIBS}"
AC_SUBST([LIBS_ALL], [$LIBS_ALL])
CFLAGS_ALL="$CFLAGS_ALL ${$1_CFLAGS}"
AC_SUBST([CFLAGS_ALL], [$CFLAGS_ALL])
else
AC_MSG_ERROR([ /!\ This programme requires the folowing frameworks : $2 !])
fi
])
dnl ---------------------------------------------------------------------------
dnl AM_FIND_WINDRES()
dnl
dnl Check for windows ressources compiler (windres)
dnl
dnl Example use:
dnl AM_FIND_WINDRES()
dnl ---------------------------------------------------------------------------
AC_DEFUN([AM_FIND_WINDRES],
[
WINDRES=''
if test "$IS_MINGW" = 'true'; then
AC_MSG_CHECKING([for windres])
for name in 'windres' 'i586-pc-mingw32msvc'; do
if which "$name" > /dev/null; then
WINDRES="$name"
AM_CONDITIONAL([IS_MINGW], [true])
AC_MSG_RESULT(["yes : $WINDRES"])
break
fi
done
if test -z "$WINDRES"; then
AC_MSG_RESULT(["no"])
fi
fi
AM_CONDITIONAL([HAVE_WINDRES], [test -n "$WINDRES"])
AC_SUBST([WINDRES])
])
dnl ---------------------------------------------------------------------------
dnl MY_DETECT_OS()
dnl
dnl Check for the target operation system
dnl
dnl Set: IS_MINGW (true or false)
dnl Set: IS_LINUX (true or false)
dnl Set: IS_MAC (true or false)
dnl Set: MY_TARGET_OS (mingw, linux or mac)
dnl Example use:
dnl AM_FIND_WINDRES()
dnl ---------------------------------------------------------------------------
AC_DEFUN([MY_DETECT_OS],
[
if echo $host | grep "linux" > /dev/null; then
MY_TARGET_OS="linux"
IS_MINGW="false"
IS_LINUX="true"
IS_MAC="false"
elif echo $host | grep "mingw" > /dev/null; then
MY_TARGET_OS="mingw"
IS_MINGW="true"
IS_LINUX="false"
IS_MAC="false"
elif echo $host | grep "darwin" > /dev/null; then
MY_TARGET_OS="darwin"
IS_MINGW="false"
IS_LINUX="false"
IS_MAC="true"
else
MY_TARGET_OS="unknown"
IS_MINGW="false"
IS_LINUX="false"
IS_MAC="false"
AC_MSG_ERROR([ /!\ Unknown OS !])
fi
AC_SUBST([MY_TARGET_OS])
AM_CONDITIONAL([IS_MINGW], [$IS_MINGW])
AM_CONDITIONAL([IS_LINUX], [$IS_LINUX])
AM_CONDITIONAL([IS_MAC], [$IS_MAC])
])
dnl ---------------------------------------------------------------------------
dnl Macros for wxWidgets detection. Typically used in configure.in as:
dnl
dnl AC_ARG_ENABLE(...)
dnl AC_ARG_WITH(...)
dnl ...
dnl AM_OPTIONS_WXCONFIG
dnl ...
dnl ...
dnl AM_PATH_WXCONFIG(2.6.0, wxWin=1)
dnl if test "$wxWin" != 1; then
dnl AC_MSG_ERROR([
dnl wxWidgets must be installed on your system
dnl but wx-config script couldn't be found.
dnl
dnl Please check that wx-config is in path, the directory
dnl where wxWidgets libraries are installed (returned by
dnl 'wx-config --libs' command) is in LD_LIBRARY_PATH or
dnl equivalent variable and wxWidgets version is 2.3.4 or above.
dnl ])
dnl fi
dnl CPPFLAGS="$CPPFLAGS $WX_CPPFLAGS"
dnl CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS_ONLY"
dnl CFLAGS="$CFLAGS $WX_CFLAGS_ONLY"
dnl
dnl LIBS="$LIBS $WX_LIBS"
dnl ---------------------------------------------------------------------------
dnl ---------------------------------------------------------------------------
dnl AM_OPTIONS_WXCONFIG
dnl
dnl adds support for --wx-prefix, --wx-exec-prefix, --with-wxdir and
dnl --wx-config command line options
dnl ---------------------------------------------------------------------------
AC_DEFUN([AM_OPTIONS_WXCONFIG],
[
AC_ARG_WITH(wxdir,
[ --with-wxdir=PATH Use uninstalled version of wxWidgets in PATH],
[ wx_config_name="$withval/wx-config"
wx_config_args="--inplace"])
AC_ARG_WITH(wx-config,
[ --with-wx-config=CONFIG wx-config script to use (optional)],
wx_config_name="$withval" )
AC_ARG_WITH(wx-prefix,
[ --with-wx-prefix=PREFIX Prefix where wxWidgets is installed (optional)],
wx_config_prefix="$withval", wx_config_prefix="")
AC_ARG_WITH(wx-exec-prefix,
[ --with-wx-exec-prefix=PREFIX
Exec prefix where wxWidgets is installed (optional)],
wx_config_exec_prefix="$withval", wx_config_exec_prefix="")
])
dnl Helper macro for checking if wx version is at least $1.$2.$3, set's
dnl wx_ver_ok=yes if it is:
AC_DEFUN([_WX_PRIVATE_CHECK_VERSION],
[
wx_ver_ok=""
if test "x$WX_VERSION" != x ; then
if test $wx_config_major_version -gt $1; then
wx_ver_ok=yes
else
if test $wx_config_major_version -eq $1; then
if test $wx_config_minor_version -gt $2; then
wx_ver_ok=yes
else
if test $wx_config_minor_version -eq $2; then
if test $wx_config_micro_version -ge $3; then
wx_ver_ok=yes
fi
fi
fi
fi
fi
fi
])
dnl ---------------------------------------------------------------------------
dnl AM_PATH_WXCONFIG(VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
dnl [, WX-LIBS [, ADDITIONAL-WX-CONFIG-FLAGS]]]])
dnl
dnl Test for wxWidgets, and define WX_C*FLAGS, WX_LIBS and WX_LIBS_STATIC
dnl (the latter is for static linking against wxWidgets). Set WX_CONFIG_NAME
dnl environment variable to override the default name of the wx-config script
dnl to use. Set WX_CONFIG_PATH to specify the full path to wx-config - in this
dnl case the macro won't even waste time on tests for its existence.
dnl
dnl Optional WX-LIBS argument contains comma- or space-separated list of
dnl wxWidgets libraries to link against (it may include contrib libraries). If
dnl it is not specified then WX_LIBS and WX_LIBS_STATIC will contain flags to
dnl link with all of the core wxWidgets libraries.
dnl
dnl Optional ADDITIONAL-WX-CONFIG-FLAGS argument is appended to wx-config
dnl invocation command in present. It can be used to fine-tune lookup of
dnl best wxWidgets build available.
dnl
dnl Example use:
dnl AM_PATH_WXCONFIG([2.6.0], [wxWin=1], [wxWin=0], [html,core,net]
dnl [--unicode --debug])
dnl ---------------------------------------------------------------------------
dnl
dnl Get the cflags and libraries from the wx-config script
dnl
AC_DEFUN([AM_PATH_WXCONFIG],
[
dnl do we have wx-config name: it can be wx-config or wxd-config or ...
if test x${WX_CONFIG_NAME+set} != xset ; then
WX_CONFIG_NAME=wx-config
fi
if test "x$wx_config_name" != x ; then
WX_CONFIG_NAME="$wx_config_name"
fi
dnl deal with optional prefixes
if test x$wx_config_exec_prefix != x ; then
wx_config_args="$wx_config_args --exec-prefix=$wx_config_exec_prefix"
WX_LOOKUP_PATH="$wx_config_exec_prefix/bin"
fi
if test x$wx_config_prefix != x ; then
wx_config_args="$wx_config_args --prefix=$wx_config_prefix"
WX_LOOKUP_PATH="$WX_LOOKUP_PATH:$wx_config_prefix/bin"
fi
if test "$cross_compiling" = "yes"; then
wx_config_args="$wx_config_args --host=$host_alias"
fi
dnl don't search the PATH if WX_CONFIG_NAME is absolute filename
if test -x "$WX_CONFIG_NAME" ; then
AC_MSG_CHECKING(for wx-config)
WX_CONFIG_PATH="$WX_CONFIG_NAME"
AC_MSG_RESULT($WX_CONFIG_PATH)
else
AC_PATH_PROG(WX_CONFIG_PATH, $WX_CONFIG_NAME, no, "$WX_LOOKUP_PATH:$PATH")
fi
if test "$WX_CONFIG_PATH" != "no" ; then
WX_VERSION=""
min_wx_version=ifelse([$1], ,2.2.1,$1)
if test -z "$5" ; then
AC_MSG_CHECKING([for wxWidgets version >= $min_wx_version])
else
AC_MSG_CHECKING([for wxWidgets version >= $min_wx_version ($5)])
fi
WX_CONFIG_WITH_ARGS="$WX_CONFIG_PATH $wx_config_args $5 $4"
WX_VERSION=`$WX_CONFIG_WITH_ARGS --version 2>/dev/null`
wx_config_major_version=`echo $WX_VERSION | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
wx_config_minor_version=`echo $WX_VERSION | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
wx_config_micro_version=`echo $WX_VERSION | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
wx_requested_major_version=`echo $min_wx_version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
wx_requested_minor_version=`echo $min_wx_version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
wx_requested_micro_version=`echo $min_wx_version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
_WX_PRIVATE_CHECK_VERSION([$wx_requested_major_version],
[$wx_requested_minor_version],
[$wx_requested_micro_version])
if test -n "$wx_ver_ok"; then
AC_MSG_RESULT(yes (version $WX_VERSION))
WX_LIBS=`$WX_CONFIG_WITH_ARGS --libs`
dnl is this even still appropriate? --static is a real option now
dnl and WX_CONFIG_WITH_ARGS is likely to contain it if that is
dnl what the user actually wants, making this redundant at best.
dnl For now keep it in case anyone actually used it in the past.
AC_MSG_CHECKING([for wxWidgets static library])
WX_LIBS_STATIC=`$WX_CONFIG_WITH_ARGS --static --libs 2>/dev/null`
if test "x$WX_LIBS_STATIC" = "x"; then
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(yes)
fi
dnl starting with version 2.2.6 wx-config has --cppflags argument
wx_has_cppflags=""
if test $wx_config_major_version -gt 2; then
wx_has_cppflags=yes
else
if test $wx_config_major_version -eq 2; then
if test $wx_config_minor_version -gt 2; then
wx_has_cppflags=yes
else
if test $wx_config_minor_version -eq 2; then
if test $wx_config_micro_version -ge 6; then
wx_has_cppflags=yes
fi
fi
fi
fi
fi
dnl starting with version 2.7.0 wx-config has --rescomp option
wx_has_rescomp=""
if test $wx_config_major_version -gt 2; then
wx_has_rescomp=yes
else
if test $wx_config_major_version -eq 2; then
if test $wx_config_minor_version -ge 7; then
wx_has_rescomp=yes
fi
fi
fi
if test "x$wx_has_rescomp" = x ; then
dnl cannot give any useful info for resource compiler
WX_RESCOMP=
else
WX_RESCOMP=`$WX_CONFIG_WITH_ARGS --rescomp`
fi
if test "x$wx_has_cppflags" = x ; then
dnl no choice but to define all flags like CFLAGS
WX_CFLAGS=`$WX_CONFIG_WITH_ARGS --cflags`
WX_CPPFLAGS=$WX_CFLAGS
WX_CXXFLAGS=$WX_CFLAGS
WX_CFLAGS_ONLY=$WX_CFLAGS
WX_CXXFLAGS_ONLY=$WX_CFLAGS
else
dnl we have CPPFLAGS included in CFLAGS included in CXXFLAGS
WX_CPPFLAGS=`$WX_CONFIG_WITH_ARGS --cppflags`
WX_CXXFLAGS=`$WX_CONFIG_WITH_ARGS --cxxflags`
WX_CFLAGS=`$WX_CONFIG_WITH_ARGS --cflags`
WX_CFLAGS_ONLY=`echo $WX_CFLAGS | sed "s@^$WX_CPPFLAGS *@@"`
WX_CXXFLAGS_ONLY=`echo $WX_CXXFLAGS | sed "s@^$WX_CFLAGS *@@"`
fi
ifelse([$2], , :, [$2])
else
if test "x$WX_VERSION" = x; then
dnl no wx-config at all
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(no (version $WX_VERSION is not new enough))
fi
WX_CFLAGS=""
WX_CPPFLAGS=""
WX_CXXFLAGS=""
WX_LIBS=""
WX_LIBS_STATIC=""
WX_RESCOMP=""
ifelse([$3], , :, [$3])
fi
else
WX_CFLAGS=""
WX_CPPFLAGS=""
WX_CXXFLAGS=""
WX_LIBS=""
WX_LIBS_STATIC=""
WX_RESCOMP=""
ifelse([$3], , :, [$3])
fi
AC_SUBST(WX_CPPFLAGS)
AC_SUBST(WX_CFLAGS)
AC_SUBST(WX_CXXFLAGS)
AC_SUBST(WX_CFLAGS_ONLY)
AC_SUBST(WX_CXXFLAGS_ONLY)
AC_SUBST(WX_LIBS)
AC_SUBST(WX_LIBS_STATIC)
AC_SUBST(WX_VERSION)
AC_SUBST(WX_RESCOMP)
])

44
configure.ac Normal file
View File

@ -0,0 +1,44 @@
AC_INIT(woeusb, @@WOEUSB_VERSION@@)
AC_CONFIG_SRCDIR([src])
AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_MACRO_DIR([m4])
MY_PACKAGE_INIT([WoeUSB])
dnl Checks for programs (must be here).
AC_LANG([C++])
AC_PROG_INSTALL
AC_PROG_CXX
AC_PROG_CPP
AC_PROG_LN_S
dnl To compile libs
LT_INIT
AM_PROG_LIBTOOL dnl indique que l'on utilise Libtool pour la compilation
AC_PROG_MAKE_SET dnl indique que l'on doit disposer de make qui est utilisé par Libtool
MY_DETECT_OS dnl Detect OS
MY_INIT_DATA_PATH dnl Define data path for unix / win32 depending on the current target system
AM_FIND_WINDRES dnl Find windres is needed
MY_INIT_DEBUG_SWITCH([false]) dnl Allow the user tu build the program in debug mode ; doesn't edit any cpp options ; true to force debug
dnl Libs
MY_FIND_STDCPP
MY_FIND_WXWIDGETS
AC_OUTPUT([Makefile
src/Makefile
src/data/Makefile
src/linux-menu/Makefile
src/win32/Makefile
src/locale/Makefile
src/locale/fr/Makefile
src/locale/zh_TW/Makefile
src/locale/fr/LC_MESSAGES/Makefile
src/locale/zh_TW/LC_MESSAGES/Makefile
debian/Makefile
innoSetup/Makefile])
MY_ECHO_BUILD_INFO # Recap

8
debian/Makefile.am vendored Normal file
View File

@ -0,0 +1,8 @@
EXTRA_DIST = \
$(srcdir)/changelog\
$(srcdir)/compat\
$(srcdir)/control\
$(srcdir)/copyright\
$(srcdir)/dirs\
$(srcdir)/docs\
$(srcdir)/rules

7
debian/changelog vendored Normal file
View File

@ -0,0 +1,7 @@
woeusb (@@WOEUSB_VERSION@@) unstable; urgency=low
* This is a fake changelog for packaging purpose, for the actual changelog pl-
ease refer Commits · slacka/WoeUSB
<https://github.com/slacka/WoeUSB/commits>
-- 林博仁 (Buo-Ren, Lin) <Buo.Ren.Lin@gmail.com> Wed, 15 Nov 2017 09:04:00 +0100

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
9

42
debian/control vendored Normal file
View File

@ -0,0 +1,42 @@
Source: woeusb
Homepage: https://github.com/slacka/WoeUSB
Section: utils
Priority: optional
Maintainer: 林博仁 (Buo-Ren, Lin) <Buo.Ren.Lin@gmail.com>
Build-Depends: debhelper (>= 9),
dh-autoreconf,
git-core,
libwxgtk2.8-dev | libwxgtk3.0-dev,
realpath | coreutils (>= 8.23)
Standards-Version: 4.1.1
Vcs-Browser: https://github.com/slacka/WoeUSB/
Vcs-Git: https://github.com/slacka/WoeUSB.git
Package: woeusb
Architecture: any
Depends: bash (>=4.3),
dosfstools,
gettext,
grub2-common,
grub-pc-bin,
ntfsprogs | ntfs-3g,
p7zip-full,
parted,
policykit-1,
realpath | coreutils (>= 8.23),
wget,
${misc:Depends},
${shlibs:Depends}
Description: Bootable Windows installation/PE USB storage creator
This package contains two programs:
.
- woeusb: An command-line utility that enables you to create your own bootable
Windows installation USB storage device from an existing Windows Installation
DVD or its ISO image.
- woeusbgui: A woeusb's GUI wrapper program based on WxWidgets GUI library.
.
Supported images: Windows Vista~10+ installation media for any language and
edition(Home/Professional...) and Windows PE-based media.
.
WoeUSB is a fork of Colin GILLE / congelli501's WinUSB software.
http://en.congelli.eu/prog_info_winusb.html

20
debian/copyright vendored Normal file
View File

@ -0,0 +1,20 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: WoeUSB
Upstream-Contact: WoeUSB Issue Tracker <https://github.com/Lin-Buo-Ren/Hello-Debian-Packaging/issues>
Source: https://github.com/slacka/WoeUSB
License: GPL-3.0+
Files: *
Copyright: Copyright 2013 Colin GILLE / congelli501 <colingille@hotmail.com>
Copyright 2017 slacka et. al.
License: GPL-3.0+
License: GPL-3.0+
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
.
On Debian systems, the full text of the GNU General Public License version 3 can be found in the file
`/usr/share/common-licenses/GPL-3'.

3
debian/docs vendored Normal file
View File

@ -0,0 +1,3 @@
NEWS
README.md
README.upstream

8
debian/rules vendored Normal file
View File

@ -0,0 +1,8 @@
#!/usr/bin/make -f
export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
%:
dh $@ --with autoreconf

104
debian/rules.old vendored Normal file
View File

@ -0,0 +1,104 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
CROSS= --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
else
CROSS= --build $(DEB_BUILD_GNU_TYPE)
endif
config.status: configure
dh_testdir
# Add here commands to configure the package.
ifneq "$(wildcard /usr/share/misc/config.sub)" ""
cp -f /usr/share/misc/config.sub config.sub
endif
ifneq "$(wildcard /usr/share/misc/config.guess)" ""
cp -f /usr/share/misc/config.guess config.guess
endif
./configure $(CROSS) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs"
build: build-stamp
build-stamp: config.status
dh_testdir
# Add here commands to compile the package.
$(MAKE)
touch $@
clean:
dh_testdir
dh_testroot
rm -f build-stamp
# Add here commands to clean up after the build process.
[ ! -f Makefile ] || $(MAKE) distclean
rm -f config.sub config.guess
dh_clean
install: build
dh_testdir
dh_testroot
dh_prep
dh_installdirs
# Add here commands to install the package into debian/woeusb.
$(MAKE) DESTDIR="$(CURDIR)/debian/woeusb" install
# Build architecture-independent files here.
binary-indep: install
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: install
dh_testdir
dh_testroot
dh_installchangelogs ChangeLog
dh_installdocs
dh_installexamples
# dh_install
# dh_installmenu
# dh_installdebconf
# dh_installlogrotate
# dh_installemacsen
# dh_installpam
# dh_installmime
# dh_python
# dh_installinit
# dh_installcron
# dh_installinfo
dh_installman
dh_link
dh_strip
dh_compress
dh_fixperms
# dh_perl
# dh_makeshlibs
dh_installdeb
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install

1
debian/source/format vendored Normal file
View File

@ -0,0 +1 @@
3.0 (native)

2
dev/README.markdown Normal file
View File

@ -0,0 +1,2 @@
# dev: Stuffs That Are Specific to WoeUSB's Development Only
These files should not be included into software build.

BIN
dev/woeusb-screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

168
doc/conf.py Normal file
View File

@ -0,0 +1,168 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath('../src'))
# -- Project information -----------------------------------------------------
project = 'WoeUSB'
copyright = '2018, congelli501, slacka and WaxyMocha et. al.'
author = 'congelli501, slacka and WaxyMocha et. al.'
# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = '1.0.0'
# -- General configuration ---------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.todo',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The master toctree document.
master_doc = 'index'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}
# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'WoeUSBdoc'
# -- Options for LaTeX output ------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'WoeUSB.tex', 'WoeUSB Documentation',
'congelli501, slacka and WaxyMocha et. al.', 'manual'),
]
# -- Options for manual page output ------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'woeusb', 'WoeUSB Documentation',
[author], 1)
]
# -- Options for Texinfo output ----------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'WoeUSB', 'WoeUSB Documentation',
author, 'WoeUSB', 'One line description of project.',
'Miscellaneous'),
]
# -- Extension configuration -------------------------------------------------
# -- Options for todo extension ----------------------------------------------
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
html_logo = "../src/data/woeusb-logo.png"
html_favicon = "../src/data/icon.png"

6
doc/gui.rst Normal file
View File

@ -0,0 +1,6 @@
GUI for WoeUSB
**************************
.. automodule:: gui
:members:
:undoc-members:

21
doc/index.rst Normal file
View File

@ -0,0 +1,21 @@
.. WoeUSB documentation master file, created by
sphinx-quickstart on Sun Jun 3 09:37:45 2018.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to WoeUSB's documentation!
==================================
.. toctree::
:caption: Contents:
woeusb.rst
gui.rst
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

6
doc/utils.rst Normal file
View File

@ -0,0 +1,6 @@
utils.py
**************************
.. automodule:: utils
:members:
:undoc-members:

12
doc/woeusb.rst Normal file
View File

@ -0,0 +1,12 @@
WoeUSB
**************************
.. toctree::
:maxdepth: 2
:caption: Imported modules:
utils.rst
workaround.rst
.. automodule:: woeusb
:members:
:undoc-members:

5
doc/workaround.rst Normal file
View File

@ -0,0 +1,5 @@
workaround.py
**************************
.. automodule:: workaround
:members:
:undoc-members:

1
os Normal file
View File

@ -0,0 +1 @@
deb;

View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD polkit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/software/polkit/policyconfig-1.dtd">
<!--
DOC: https://www.freedesktop.org/software/polkit/docs/latest/polkit.8.html
-->
<policyconfig>
<vendor>The WoeUSB Project</vendor>
<vendor_url>https://github.com/slacka/WoeUSB</vendor_url>
<icon_name>woeusbgui-icon</icon_name>
<action id="com.github.slacka.woeusb.run-cli-using-pkexec">
<description>Run `woeusb` as SuperUser</description>
<description xml:lang="zh_TW">以超級使用者(SuperUser)身份執行 `woeusb`</description>
<description xml:lang="pl_PL">Uruchom `woeusb` jako root</description>
<message>Authentication is required to run `woeusb` as SuperUser.</message>
<message xml:lang="zh_TW">以超級使用者(SuperUser)身份執行 `woeusb` 需要通過身份驗證。</message>
<message xml:lang="pl_PL">Wymagana jest autoryzacja do uruchomienia `woeusb` jako root</message>
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/woeusb</annotate>
</action>
<action id="com.github.slacka.woeusb.run-gui-using-pkexec">
<description>Run `woeusb` as SuperUser</description>
<description xml:lang="zh_TW">以超級使用者(SuperUser)身份執行 `woeusb`</description>
<description xml:lang="pl_PL">Uruchom `woeusb` jako root</description>
<message>Authentication is required to run `woeusb` as SuperUser.</message>
<message xml:lang="zh_TW">以超級使用者(SuperUser)身份執行 `woeusb` 需要通過身份驗證。</message>
<message xml:lang="pl_PL">Wymagana jest autoryzacja do uruchomienia `woeusb` jako root</message>
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/woeusbgui</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
<action id="com.github.slacka.woeusb.run-cli-using-pkexec-usr-local">
<description>Run `woeusb` as SuperUser</description>
<description xml:lang="zh_TW">以超級使用者(SuperUser)身份執行 `woeusb`</description>
<description xml:lang="pl_PL">Uruchom `woeusb` jako root</description>
<message>Authentication is required to run `woeusb` as SuperUser.</message>
<message xml:lang="zh_TW">以超級使用者(SuperUser)身份執行 `woeusb` 需要通過身份驗證。</message>
<message xml:lang="pl_PL">Wymagana jest autoryzacja do uruchomienia `woeusb` jako root</message>
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/local/bin/woeusb</annotate>
</action>
<action id="com.github.slacka.woeusb.format-mode">
<description>WoeUSB running in --format mode.</description>
<description xml:lang="zh_TW">WoeUSB 以 --format 模式運行</description>
<message>Superuser privilege is required for WoeUSB to modify your target device's partition table, create target partiton, format target filesystem, mount and unmount target filesystem, install bootloader and etc.</message>
<message xml:lang="zh_TW">WoeUSB 需要「超級使用者(SuperUser)」權限以修改您目標裝置的分區表、建立目標分區、格式化目標檔案系統、掛載與解除掛載目標檔案系統、安裝開機載入器以及其他操作。</message>
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
</defaults>
</action>
<action id="com.github.slacka.woeusb.install-mode">
<description>WoeUSB running in --install mode.</description>
<description xml:lang="zh_TW">WoeUSB 以 --install 模式運行</description>
<message>Superuser privilege is required for WoeUSB to mount and unmount target filesystem, install bootloader and etc.</message>
<message xml:lang="zh_TW">WoeUSB 需要「超級使用者(SuperUser)」權限以掛載與解除掛載目標檔案系統、安裝開機載入器以及其他操作。</message>
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
</defaults>
</action>
</policyconfig>

View File

@ -0,0 +1,170 @@
#!/usr/bin/env bash
#shellcheck disable=SC2034
## Makes debuggers' life easier - Unofficial Bash Strict Mode
## BASHDOC: Shell Builtin Commands - Modifying Shell Behavior - The Set Builtin
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail
for required_command in \
realpath\
basename\
dirname\
git\
rm
do
if ! command -v "${required_command}" >/dev/null; then
printf\
"Error: This program requires \"%s\" command in your \$PATH.\n"\
"${required_command}"\
1>&2
exit 1
fi
done
## Non-overridable Primitive Variables
## BASHDOC: Shell Variables » Bash Variables
## BASHDOC: Basic Shell Features » Shell Parameters » Special Parameters
if [ -v "BASH_SOURCE[0]" ]; then
RUNTIME_EXECUTABLE_PATH="$(realpath --strip "${BASH_SOURCE[0]}")"
RUNTIME_EXECUTABLE_FILENAME="$(basename "${RUNTIME_EXECUTABLE_PATH}")"
RUNTIME_EXECUTABLE_NAME="${RUNTIME_EXECUTABLE_FILENAME%.*}"
RUNTIME_EXECUTABLE_DIRECTORY="$(dirname "${RUNTIME_EXECUTABLE_PATH}")"
RUNTIME_COMMANDLINE_BASECOMMAND="${0}"
declare -r\
RUNTIME_EXECUTABLE_FILENAME\
RUNTIME_EXECUTABLE_DIRECTORY\
RUNTIME_EXECUTABLE_NAME\
RUNTIME_EXECUTABLE_PATHABSOLUTE\
RUNTIME_COMMANDLINE_BASECOMMAND
fi
declare -ar RUNTIME_COMMANDLINE_PARAMETERS=("${@}")
## init function: entrypoint of main program
## This function is called near the end of the file,
## with the script's command-line parameters as arguments
init(){
if ! process_commandline_parameters; then
printf\
"Error: %s: Invalid command-line parameters.\n"\
"${FUNCNAME[0]}"\
1>&2
print_help
exit 1
fi
export GIT_DIR="${RUNTIME_EXECUTABLE_DIRECTORY}/.git"
export GIT_WORK_TREE="${RUNTIME_EXECUTABLE_DIRECTORY}"
printf "Setting Project-specific Git configuration..."
git config include.path ../.gitconfig\
&& printf "done\n"
printf "Activating Git smudge filter...\n"
# git - How do I programmatically determine if there are uncommitted changes? - Stack Overflow
# https://stackoverflow.com/questions/3878624/how-do-i-programmatically-determine-if-there-are-uncommitted-changes
# DOC: git-diff-index(1) manpage: OPTIONS: --quiet, --exit-code
local stash_is_needed=false
if ! git diff-index --quiet HEAD --; then
stash_is_needed=true
fi
if test "${stash_is_needed}" = 'true'; then
git stash save &>/dev/null
fi
rm .git/index
git checkout HEAD -- "$(git rev-parse --show-toplevel)" >/dev/null
if test "${stash_is_needed}" = 'true'; then
git stash pop &>/dev/null
fi; unset stash_is_needed
printf "done.\n"
exit 0
}; declare -fr init
## Traps: Functions that are triggered when certain condition occurred
## Shell Builtin Commands » Bourne Shell Builtins » trap
trap_errexit(){
local line_number="${1}"
printf\
"An error occurred at line number %s and the script is prematurely aborted\n"\
"${line_number}"\
1>&2
return 0
}; declare -fr trap_errexit; trap 'trap_errexit ${LINENO}' ERR
trap_exit(){
return 0
}; declare -fr trap_exit; trap trap_exit EXIT
trap_return(){
local returning_function="${1}"
printf "DEBUG: %s: returning from %s\n" "${FUNCNAME[0]}" "${returning_function}" 1>&2
}; declare -fr trap_return
trap_interrupt(){
printf "Recieved SIGINT, script is interrupted.\n" 1>&2
return 0
}; declare -fr trap_interrupt; trap trap_interrupt INT
print_help(){
printf "Currently no help messages are available for this program\n" 1>&2
return 0
}; declare -fr print_help;
process_commandline_parameters() {
if [ "${#RUNTIME_COMMANDLINE_PARAMETERS[@]}" -eq 0 ]; then
return 0
fi
# modifyable parameters for parsing by consuming
local -a parameters=("${RUNTIME_COMMANDLINE_PARAMETERS[@]}")
# Normally we won't want debug traces to appear during parameter parsing, so we add this flag and defer it activation till returning(Y: Do debug)
local enable_debug=N
while true; do
if [ "${#parameters[@]}" -eq 0 ]; then
break
else
case "${parameters[0]}" in
"--help"\
|"-h")
print_help;
exit 0
;;
"--debug"\
|"-d")
enable_debug="Y"
;;
*)
printf "ERROR: Unknown command-line argument \"%s\"\n" "${parameters[0]}" >&2
return 1
;;
esac
# shift array by 1 = unset 1st then repack
unset "parameters[0]"
if [ "${#parameters[@]}" -ne 0 ]; then
parameters=("${parameters[@]}")
fi
fi
done
if [ "${enable_debug}" = "Y" ]; then
trap 'trap_return "${FUNCNAME[0]}"' RETURN
set -o xtrace
fi
return 0
}; declare -fr process_commandline_parameters;
init "${@}"
## This script is based on the GNU Bash Shell Script Template project
## https://github.com/Lin-Buo-Ren/GNU-Bash-Shell-Script-Template
## and is based on the following version:
declare -r META_BASED_ON_GNU_BASH_SHELL_SCRIPT_TEMPLATE_VERSION="v1.26.0-32-g317af27-dirty"
## You may rebase your script to incorporate new features and fixes from the template

742
src/core.py Normal file
View File

@ -0,0 +1,742 @@
#!/usr/bin/env python
"""
A Linux program to create bootable Windows USB stick from a real Windows DVD or an image
Copyright © 2013 Colin GILLE / congelli501
Copyright © 2017 slacka et. al.
Python port - 2018 WaxyMocha
This file is part of WoeUSB.
WoeUSB is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
WoeUSB is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with WoeUSB If not, see <http://www.gnu.org/licenses/>.
"""
import os
import time
import shutil
import argparse
import tempfile
import traceback
import threading
import subprocess
import urllib.request
from datetime import datetime
import utils
import workaround
application_name = 'WoeUSB'
application_version = '@@WOEUSB_VERSION@@'
DEFAULT_NEW_FS_LABEL = 'Windows USB'
application_site_url = 'https://github.com/slacka/WoeUSB'
application_copyright_declaration = "Copyright © Colin GILLE / congelli501 2013\\nCopyright © slacka et.al. 2017"
application_copyright_notice = application_name + " is free software licensed under the GNU General Public License version 3(or any later version of your preference) that gives you THE 4 ESSENTIAL FREEDOMS\\nhttps://www.gnu.org/philosophy/"
#: Increase verboseness, provide more information when required
verbose = False
debug = False
#: used in cleanup()
target_device = ""
CopyFiles_handle = threading.Thread()
#: Execution state for cleanup functions to determine if clean up is required
current_state = 'pre-init'
gui = None
def init(from_cli=True, install_mode=None, source_media=None, target_media=None, workaround_bios_boot_flag=False,
target_filesystem_type="FAT", filesystem_label=DEFAULT_NEW_FS_LABEL):
"""
:param from_cli:
:type from_cli: bool
:param install_mode:
:param source_media:
:param target_media:
:param workaround_bios_boot_flag:
:param target_filesystem_type:
:param filesystem_label:
:return: List
"""
source_fs_mountpoint = "/media/woeusb_source_" + str(
round((datetime.today() - datetime.fromtimestamp(0)).total_seconds())) + "_" + str(os.getpid())
target_fs_mountpoint = "/media/woeusb_target_" + str(
round((datetime.today() - datetime.fromtimestamp(0)).total_seconds())) + "_" + str(os.getpid())
temp_directory = tempfile.mkdtemp(prefix="WoeUSB.")
verbose = False
no_color = True
debug = False
parser = None
if from_cli:
parser = setup_arguments()
args = parser.parse_args()
if args.about:
print_application_info()
return 0
if args.device:
install_mode = "device"
elif args.partition:
install_mode = "partition"
else:
utils.print_with_color("You need to specify instalation type (--device or --partition")
return 1
#: source_media may be a optical disk drive or a disk image
source_media = args.source
#: target_media may be an entire usb storage device or just a partition
target_media = args.target
workaround_bios_boot_flag = args.workaround_bios_boot_flag
target_filesystem_type = args.target_filesystem
filesystem_label = args.label
verbose = args.verbose
no_color = args.no_color
debug = args.debug
utils.no_color = no_color
utils.verbose = verbose
utils.gui = gui
return [source_fs_mountpoint, target_fs_mountpoint, temp_directory, install_mode, source_media, target_media,
workaround_bios_boot_flag, target_filesystem_type, filesystem_label, verbose, debug, parser]
def main(source_fs_mountpoint, target_fs_mountpoint, source_media, target_media, install_mode, temp_directory,
target_filesystem_type, workaround_bios_boot_flag, parser):
"""
:param parser:
:param source_fs_mountpoint:
:param target_fs_mountpoint:
:param source_media:
:param target_media:
:param install_mode:
:param temp_directory:
:param target_filesystem_type:
:param workaround_bios_boot_flag:
:return: 0 - succes; 1 - failure
"""
global debug
global verbose
global no_color
global current_state
global target_device
current_state = 'enter-init'
command_mkdosfs, command_mkntfs, command_grubinstall = utils.check_runtime_dependencies(application_name)
if command_grubinstall == "grub-install":
name_grub_prefix = "grub"
else:
name_grub_prefix = "grub2"
utils.print_with_color(application_name + " v" + application_version)
utils.print_with_color("==============================")
if os.getuid() != 0:
utils.print_with_color("Warning: You are not running " + application_name + " as root!", "yellow")
utils.print_with_color("Warning: This might be the reason of the following failure.", "yellow")
if utils.check_runtime_parameters(install_mode, source_media, target_media):
parser.print_help()
return 1
target_device, target_partition = utils.determine_target_parameters(install_mode, target_media)
if utils.check_source_and_target_not_busy(install_mode, source_media, target_device, target_partition):
return 1
current_state = "start-mounting"
if mount_source_filesystem(source_media, source_fs_mountpoint):
utils.print_with_color("Error: Unable to mount source filesystem", "red")
return 1
if target_filesystem_type == "FAT":
if utils.check_fat32_filesize_limitation(source_fs_mountpoint):
target_filesystem_type = "NTFS"
if install_mode == "device":
wipe_existing_partition_table_and_filesystem_signatures(target_device)
create_target_partition_table(target_device, "legacy")
create_target_partition(target_device, target_partition, target_filesystem_type, target_filesystem_type,
command_mkdosfs,
command_mkntfs)
if target_filesystem_type == "NTFS":
create_uefi_ntfs_support_partition(target_device)
install_uefi_ntfs_support_partition(target_device + "2", temp_directory)
if install_mode == "partition":
utils.check_target_partition(target_partition, target_device)
utils.check_target_partition(target_partition, target_device)
if mount_target_filesystem(target_partition, target_fs_mountpoint):
utils.print_with_color("Error: Unable to mount target filesystem", "red")
return 1
if utils.check_target_filesystem_free_space(target_fs_mountpoint, source_fs_mountpoint, target_partition):
return 1
current_state = "copying-filesystem"
workaround.linux_make_writeback_buffering_not_suck(True)
copy_filesystem_files(source_fs_mountpoint, target_fs_mountpoint)
workaround.support_windows_7_uefi_boot(source_fs_mountpoint, target_fs_mountpoint)
install_legacy_pc_bootloader_grub(target_fs_mountpoint, target_device, command_grubinstall)
install_legacy_pc_bootloader_grub_config(target_fs_mountpoint, target_device, command_grubinstall, name_grub_prefix)
if workaround_bios_boot_flag:
workaround.buggy_motherboards_that_ignore_disks_without_boot_flag_toggled(target_device)
current_state = "finished"
return 0
def print_application_info():
print(application_name + " " + application_version)
print(application_site_url)
print(application_copyright_declaration)
print(application_copyright_notice)
def wipe_existing_partition_table_and_filesystem_signatures(target_device):
"""
:param target_device:
:return: None
"""
utils.print_with_color("Wiping all existing partition table and filesystem signatures in " + target_device, "green")
subprocess.run(["wipefs", "--all", target_device])
check_if_the_drive_is_really_wiped(target_device)
def check_if_the_drive_is_really_wiped(target_device):
"""
Some broken locked-down flash drive will appears to be successfully wiped but actually nothing is written into it and will shown previous partition scheme afterwards. This is the detection of the case and will bail out if such things happened
:param target_device: The target device file to be checked
:return: 0 - success; 1 - failure
"""
utils.check_kill_signal()
utils.print_with_color("Ensure that " + target_device + " is really wiped...")
lsblk = subprocess.run(["lsblk", "--pairs", "--output", "NAME,TYPE", target_device], stdout=subprocess.PIPE).stdout
grep = subprocess.Popen(["grep", "--count", "TYPE=\"part\""], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
if grep.communicate(input=lsblk)[0].decode("utf-8").strip() != "0":
utils.print_with_color(
"Error: Partition is still detected after wiping all signatures, this indicates that the drive might be locked into readonly mode due to end of lifespan.")
return 1
return 0
def create_target_partition_table(target_device, partition_table_type):
"""
:param target_device:
:param partition_table_type:
:return: 0 - success; 1 - failure
"""
utils.check_kill_signal()
utils.print_with_color("Creating new partition table on " + target_device + "...", "green")
if partition_table_type in ["legacy", "msdos", "mbr", "pc"]:
parted_partiton_table_argument = "msdos"
elif partition_table_type in ["gpt", "guid"]:
utils.print_with_color("Error: Currently GUID partition table is not supported.", "red")
return 1
else:
utils.print_with_color("Error: Partition table not supported.", "red")
return 1
# Create partition table(and overwrite the old one, whatever it was)
subprocess.run(["parted", "--script", target_device, "mklabel", parted_partiton_table_argument])
return 0
def create_target_partition(target_device, target_partition, filesystem_type, filesystem_label, command_mkdosfs,
command_mkntfs):
"""
:param target_device:
:param target_partition:
:param filesystem_type:
:param filesystem_label:
:param command_mkdosfs:
:param command_mkntfs:
:return: 1,2 - failure
"""
utils.check_kill_signal()
if filesystem_type in ["FAT", "vfat"]:
parted_mkpart_fs_type = "fat32"
elif filesystem_type in ["NTFS", "ntfs"]:
parted_mkpart_fs_type = "ntfs"
else:
utils.print_with_color("Error: Filesystem not supported", "red")
return 2
utils.print_with_color("Creating target partition...", "green")
# Create target partition
# We start at 4MiB for grub (it needs a post-mbr gap for its code) and alignment of flash memery block erase segment in general, for details see http://www.gnu.org/software/grub/manual/grub.html#BIOS-installation and http://lwn.net/Articles/428584/
# If NTFS filesystem is used we leave a 512KiB partition at the end for installing UEFI:NTFS partition for NTFS support
if parted_mkpart_fs_type == "fat32":
subprocess.run(["parted",
"--script",
target_device,
"mkpart",
"primary",
parted_mkpart_fs_type,
"4MiB",
"100%"]) # last sector of the disk
elif parted_mkpart_fs_type == "ntfs":
# Major partition for storing user files
# NOTE: Microsoft Windows has a bug that only recognize the first partition for removable storage devices, that's why this partition should always be the first one
subprocess.run(["parted",
"--script",
target_device,
"mkpart",
"primary",
parted_mkpart_fs_type,
"4MiB",
"--",
"-1025s"]) # Leave 512KiB==1024sector in traditional 512bytes/sector disk, disks with sector with more than 512bytes only result in partition size greater than 512KiB and is intentionally let-it-be.
# FIXME: Leave exact 512KiB in all circumstances is better, but the algorithm to do so is quite brainkilling.
else:
utils.print_with_color("FATAL: Illegal parted_mkpart_fs_type, please report bug.", "green")
utils.check_kill_signal()
workaround.make_system_realize_partition_table_changed(target_device)
# Format target partition's filesystem
if filesystem_type in ["FAT", "vfat"]:
subprocess.run([command_mkdosfs, "-F", "32", target_partition])
elif filesystem_type in ["NTFS", "ntfs"]:
subprocess.run([command_mkntfs, "--quick", "--label", filesystem_label, target_partition])
else:
utils.print_with_color("FATAL: Shouldn't be here")
return 1
def create_uefi_ntfs_support_partition(target_device):
"""
:param target_device:
:return: None
"""
utils.check_kill_signal()
# FIXME: The partition type should be `fat12` but `fat12` isn't recognized by Parted...
# NOTE: The --align is set to none because this partition is indeed misaligned, but ignored due to it's small size
subprocess.run(["parted",
"--align", "none",
"--script",
target_device,
"mkpart",
"primary",
"fat16",
"--", "-1024s", "-1s"])
def install_uefi_ntfs_support_partition(uefi_ntfs_partition, download_directory):
"""
Install UEFI:NTFS partition by writing the partition image into the created partition
FIXME: Currently this requires internet access to download the image from GitHub directly, it should be replaced by including the image in our datadir
:param uefi_ntfs_partition: The previously allocated partition for installing UEFI:NTFS, requires at least 512KiB
:param download_directory: The temporary directory for downloading UEFI:NTFS image from GitHub
:return: 1 - failure
"""
utils.check_kill_signal()
try:
file = urllib.request.urlretrieve("https://github.com/pbatard/rufus/raw/master/res/uefi/", "uefi-ntfs.img")[0]
except urllib.request.ContentTooShortError:
utils.print_with_color(
"Warning: Unable to download UEFI:NTFS partition image from GitHub, installation skipped. Target device might not be bootable if the UEFI firmware doesn't support NTFS filesystem.")
return 1
shutil.move(file, download_directory + "/" + file) # move file to download_directory
shutil.copy2(download_directory + "/uefi-ntfs.img", uefi_ntfs_partition)
def mount_source_filesystem(source_media, source_fs_mountpoint):
"""
:param source_media:
:param source_fs_mountpoint:
:return: 1 - failure
"""
utils.check_kill_signal()
utils.print_with_color("Mounting source filesystem...", "green")
# os.makedirs(source_fs_mountpoint, exist_ok=True)
if subprocess.run(["mkdir", "--parents", source_fs_mountpoint]).returncode != 0:
utils.print_with_color("Error: Unable to create " + source_fs_mountpoint + " mountpoint directory", "red")
return 1
if os.path.isfile(source_media):
if subprocess.run(["mount",
"--options", "loop,ro",
"--types", "udf,iso9660",
source_media,
source_fs_mountpoint]).returncode != 0:
utils.print_with_color("Error: Unable to mount source media", "red")
return 1
else:
if subprocess.run(["mount",
"--options", "ro",
source_media,
source_fs_mountpoint]).returncode != 0:
utils.print_with_color("Error: Unable to mount source media", "red")
return 1
def mount_target_filesystem(target_partition, target_fs_mountpoint):
"""
Mount target filesystem to existing path as mountpoint
:param target_partition: The partition device file target filesystem resides, for example /dev/sdX1
:param target_fs_mountpoint: The existing directory used as the target filesystem's mountpoint, for example /mnt/target_filesystem
:return: 1 - failure
"""
utils.check_kill_signal()
utils.print_with_color("Mounting target filesystem...", "green")
# os.makedirs(target_fs_mountpoint, exist_ok=True)
if subprocess.run(["mkdir", "--parents", target_fs_mountpoint]).returncode != 0:
utils.print_with_color("Error: Unable to create " + target_fs_mountpoint + " mountpoint directory", "red")
return 1
if subprocess.run(["mount",
target_partition,
target_fs_mountpoint]).returncode != 0:
utils.print_with_color("Error: Unable to mount target media", "red")
return 1
def copy_filesystem_files(source_fs_mountpoint, target_fs_mountpoint):
"""
Copying all files from one filesystem to another, with progress reporting
:param source_fs_mountpoint:
:param target_fs_mountpoint:
:return: None
"""
global CopyFiles_handle
utils.check_kill_signal()
total_size = 0
for dirpath, dirnames, filenames in os.walk(source_fs_mountpoint):
for file in filenames:
path = os.path.join(dirpath, file)
total_size += os.path.getsize(path)
utils.print_with_color("Copying files from source media...", "green")
CopyFiles_handle = ReportCopyProgress(source_fs_mountpoint, target_fs_mountpoint)
CopyFiles_handle.start()
for dirpath, _, filenames in os.walk(source_fs_mountpoint):
utils.check_kill_signal()
if not os.path.isdir(target_fs_mountpoint + dirpath.replace(source_fs_mountpoint, "")):
os.mkdir(target_fs_mountpoint + dirpath.replace(source_fs_mountpoint, ""))
for file in filenames:
path = os.path.join(dirpath, file)
CopyFiles_handle.file = path
if os.path.getsize(path) > 5 * 1024 * 1024: # Files bigger than 5 MiB
copy_large_file(path, target_fs_mountpoint + path.replace(source_fs_mountpoint, ""))
else:
shutil.copy2(path, target_fs_mountpoint + path.replace(source_fs_mountpoint, ""))
CopyFiles_handle.stop = True
def copy_large_file(source, target):
"""
Because python's copy is atomic it is not possible to do anything during process.
It is not a big problem when using cli (user can just hit ctrl+c and throw exception),
but when using gui this part of script needs to "ping" gui for progress reporting
and check if user didn't click "cancel" (see utils.check_kill_signal())
:param source:
:param target:
:return: None
"""
source_file = open(source, "rb") # Open for reading in byte mode
target_file = open(target, "wb") # Open for writing in byte mode
while True:
utils.check_kill_signal()
data = source_file.read(5 * 1024 * 1024) # Read 5 MiB, speeds of shitty pendrives can be as low as 2 MiB/s
if data == b"":
break
target_file.write(data)
source_file.close()
target_file.close()
def install_legacy_pc_bootloader_grub(target_fs_mountpoint, target_device, command_grubinstall):
"""
:param target_fs_mountpoint:
:param target_device:
:param command_grubinstall:
:return: None
"""
utils.check_kill_signal()
utils.print_with_color("Installing GRUB bootloader for legacy PC booting support...", "green")
subprocess.run([command_grubinstall,
"--target=i386-pc",
"--boot-directory=" + target_fs_mountpoint,
"--force", target_device])
def install_legacy_pc_bootloader_grub_config(target_fs_mountpoint, target_device, command_grubinstall,
name_grub_prefix):
"""
Install a GRUB config file to chainload Microsoft Windows's bootloader in Legacy PC bootmode
:param target_fs_mountpoint: Target filesystem's mountpoint(where GRUB is installed)
:param target_device:
:param command_grubinstall:
:param name_grub_prefix: May be different between distributions, so need to be specified (grub/grub2)
:return: None
"""
utils.check_kill_signal()
utils.print_with_color("Installing custom GRUB config for legacy PC booting...", "green")
grub_cfg = target_fs_mountpoint + "/" + name_grub_prefix + "/grub.cfg"
os.makedirs(target_fs_mountpoint + "/" + name_grub_prefix, exist_ok=True)
with open(grub_cfg, "w") as cfg:
cfg.write("ntldr /bootmgr\n")
cfg.write("boot")
def cleanup_mountpoint(fs_mountpoint):
"""
Unmount mounted filesystems and clean-up mountpoints before exiting program
:param fs_mountpoint:
:return: unclean(2): Not fully clean, target device can be safely detach from host; unsafe(3): Target device cannot be safely detach from host
"""
if os.path.ismount(fs_mountpoint): # os.path.ismount() checks if path is a mount point
utils.print_with_color("Unmounting and removing " + fs_mountpoint + "...", "green")
if subprocess.run(["umount", fs_mountpoint]).returncode:
utils.print_with_color("Warning: Unable to unmount filesystem.", "yellow")
return 1
try:
os.rmdir(fs_mountpoint)
except OSError:
utils.print_with_color("Warning: Unable to remove source mountpoint", "yellow")
return 2
return 0
def cleanup(source_fs_mountpoint, target_fs_mountpoint, temp_directory):
"""
:param source_fs_mountpoint:
:param target_fs_mountpoint:
:param temp_directory:
:return: None
"""
if CopyFiles_handle.is_alive():
CopyFiles_handle.stop = True
if current_state in ["copying-filesystem", "finished"]:
workaround.linux_make_writeback_buffering_not_suck(False)
flag_unclean = False
flag_unsafe = False
cleanup_result = cleanup_mountpoint(source_fs_mountpoint)
if cleanup_result == 2:
flag_unclean = True
cleanup_result = cleanup_mountpoint(target_fs_mountpoint)
if cleanup_result == 1:
flag_unsafe = True
elif cleanup_result == 2:
flag_unclean = True
if flag_unclean:
utils.print_with_color("Some mountpoints are not unmount/cleaned successfully and must be done manually",
"yellow")
if flag_unsafe:
utils.print_with_color(
"We unable to unmount target filesystem for you, please make sure target filesystem is unmounted before detaching to prevent data corruption",
"yellow")
utils.print_with_color("Some mountpoints are not unmount/cleaned successfully and must be done manually",
"yellow")
if utils.check_is_target_device_busy(target_device):
utils.print_with_color(
"Target device is busy, please make sure you unmount all filesystems on target device or shutdown the computer before detaching it.",
"yellow")
else:
utils.print_with_color("You may now safely detach the target device", "green")
shutil.rmtree(temp_directory)
if current_state == "finished":
utils.print_with_color("Done :)", "green")
utils.print_with_color("The target device should be bootable now", "green")
def setup_arguments():
"""
:return: Setted up argparse.ArgumentParser object
"""
parser = argparse.ArgumentParser(
description="WoeUSB can create a bootable Microsoft Windows(R) USB storage device from an existing Windows optical disk or an ISO disk image.")
parser.add_argument("source", help="Source")
parser.add_argument("target", help="Target")
parser.add_argument("--device", "-d", action="store_true",
help="Completely WIPE the entire USB storage device, then build a bootable Windows USB device from scratch.")
parser.add_argument("--partition", "-p", action="store_true",
help="Copy Windows files to an existing partition of a USB storage device and make it bootable. This allows files to coexist as long as no filename conflict exists.")
parser.add_argument("--verbose", "-v", action="store_true", help="Verbose mode")
parser.add_argument("--version", "-V", action="version", version=application_version,
help="Print application version")
parser.add_argument("--about", "-ab", action="store_true", help="Show info about this application")
parser.add_argument("--no-color", action="store_true", help="Disable message coloring")
parser.add_argument("--debug", action="store_true", help="Enable script debugging")
parser.add_argument("--label", "-l", default="Windows USB",
help="Specify label for the newly created file system in --device creation method")
parser.add_argument("--workaround-bios-boot-flag", action="store_true",
help="Workaround BIOS bug that won't include the device in boot menu if non of the partition's boot flag is toggled")
parser.add_argument("--target-filesystem", "--tgt-fs", choices=["FAT", "NTFS"], default="FAT",
help="Specify the filesystem to use as the target partition's filesystem.")
parser.add_argument('--for-gui', action="store_true", help=argparse.SUPPRESS)
return parser
class ReportCopyProgress(threading.Thread):
"""
Classes for threading module
"""
file = ""
stop = False
def __init__(self, source, target):
threading.Thread.__init__(self)
self.source = source
self.target = target
def run(self):
source_size = utils.get_size(self.source)
len_ = 0
file_old = None
while not self.stop:
target_size = utils.get_size(self.target)
if len_ != 0 and gui is None:
print('\033[3A')
print(" " * len_)
print(" " * 4)
print('\033[3A')
# Prevent printing same filenames
if self.file != file_old:
file_old = self.file
utils.print_with_color(self.file.replace(self.source, ""))
string = "Copied " + utils.convert_to_human_readable_format(
target_size) + " from a total of " + utils.convert_to_human_readable_format(source_size)
len_ = len(string)
percentage = (target_size * 100) // source_size
if gui is not None:
gui.state = string
gui.progress = percentage
else:
print(string)
print(str(percentage) + "%")
time.sleep(0.05)
if gui is not None:
gui.progress = False
return 0
def run():
source_fs_mountpoint, target_fs_mountpoint, temp_directory, \
install_mode, source_media, target_media, \
workaround_bios_boot_flag, target_filesystem_type, new_file_system_label, \
verbose, debug, parser = init()
try:
main(source_fs_mountpoint, target_fs_mountpoint, source_media, target_media, install_mode, temp_directory,
target_filesystem_type, workaround_bios_boot_flag, parser)
except KeyboardInterrupt:
pass
except Exception as error:
utils.print_with_color(error, "red")
if debug:
traceback.print_exc()
cleanup(source_fs_mountpoint, target_fs_mountpoint, temp_directory)
if __name__ == "__main__":
run()

7
src/data/Makefile.am Normal file
View File

@ -0,0 +1,7 @@
# Il faut mettre les fichiers dans le sous dossier data de share...
pkgdatadir=$(mypkgdatadir)/data
dist_pkgdata_DATA = $(srcdir)/*.png
bindir=${pkgdatadir}
dist_bin_SCRIPTS = listUsb listDvdDrive

BIN
src/data/c501-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

BIN
src/data/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
src/data/woeusb-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

View File

@ -0,0 +1,11 @@
if ! IS_MINGW
desktopdir = $(datadir)/applications
desktop_DATA = $(srcdir)/*.desktop
pixmapdir = $(datadir)/pixmaps
pixmap_DATA = $(srcdir)/*.png
endif
EXTRA_DIST = $(srcdir)/*.desktop $(srcdir)/*.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -0,0 +1,16 @@
[Desktop Entry]
Version=1.0
Exec=woeusbgui
Icon=woeusbgui-icon
Terminal=false
X-MultipleArgs=false
Type=Application
Categories=System;
Keywords=Windows;UEFI;EFI;booting;
StartupNotify=true
Name=WoeUSB
Name[fr_FR]=WoeUSB
Name[zh_TW]=WoeUSB Windows USB
Comment=Create Windows USB stick installer from a real Windows DVD or an image.
Comment[fr_FR]=Créer des clés USB d'installation de Windows depuis une image CD ou un dvd original.
Comment[zh_TW]= Windows DVD Windows USB

107
src/list_devices.py Normal file
View File

@ -0,0 +1,107 @@
#!/usr/bin/env python
"""
This file is part of WoeUSB.
WoeUSB is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
WoeUSB is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with WoeUSB. If not, see <http://www.gnu.org/licenses/>.
"""
import os
import re
import subprocess
# Packed to class for clarity
def usb_drive(show_all=False):
devices_list = []
lsblk = subprocess.run(["lsblk",
"--output", "NAME",
"--noheadings",
"--nodeps"], stdout=subprocess.PIPE).stdout.decode("utf-8")
devices = re.sub("sr[0-9]|cdrom[0-9]", "", lsblk).split()
for device in devices:
if is_removable_and_writable_device(device):
if not show_all:
continue
# FIXME: Needs a more reliable detection mechanism instead of simply assuming it is under /dev
block_device = "/dev/" + device
device_capacity = subprocess.run(["lsblk",
"--output", "SIZE",
"--noheadings",
"--nodeps",
block_device], stdout=subprocess.PIPE).stdout.decode("utf-8").strip()
device_model = subprocess.run(["lsblk",
"--output", "MODEL",
"--noheadings",
"--nodeps",
block_device], stdout=subprocess.PIPE).stdout.decode("utf-8").strip()
if device_model != "":
devices_list.append([block_device, block_device + "(" + device_model + ", " + device_capacity + ")"])
else:
devices_list.append([block_device, block_device + "(" + device_capacity + ")"])
return devices_list
def is_removable_and_writable_device(block_device_name):
sysfs_block_device_dir = "/sys/block/" + block_device_name
# We consider device not removable if the removable sysfs item not exist
if os.path.isfile(sysfs_block_device_dir + "/removable"):
with open(sysfs_block_device_dir + "/removable") as removable:
removable_content = removable.read()
with open(sysfs_block_device_dir + "/ro") as ro:
ro_content = ro.read()
if removable_content.strip("\n") == "1" and ro_content.strip("\n") == "0":
return 0
else:
return 1
else:
return 1
def dvd_drive():
devices_list = []
find = subprocess.run(["find", "/sys/block",
"-maxdepth", "1",
"-mindepth", "1"], stdout=subprocess.PIPE).stdout.decode("utf-8").split()
devices = []
for device in find:
tmp = re.findall("sr[0-9]", device)
if tmp == []:
continue
devices.append([device, tmp[0]])
for device in devices:
optical_disk_drive_devfs_path = "/dev/" + device[1]
with open(device[0] + "/device/model", "r") as model:
model_content = model.read().strip()
devices_list.append([optical_disk_drive_devfs_path, optical_disk_drive_devfs_path + " - " + model_content])
return devices_list

2
src/locale/Makefile.am Normal file
View File

@ -0,0 +1,2 @@
# Il faut mettre les fichiers dans le sous dossier locale de share...
SUBDIRS = fr zh_TW

View File

@ -0,0 +1,9 @@
# Il faut mettre les fichiers dans le sous dossier locale/fr/LC_MESSAGES de share...
pkgdatadir=$(mypkgdatadir)/locale/fr/LC_MESSAGES
%.mo: %.po
msgfmt -o $@ $<
dist_pkgdata_DATA = \
$(srcdir)/woeusb.mo\
$(srcdir)/wxstd.mo

View File

@ -0,0 +1,154 @@
msgid ""
msgstr ""
"Project-Id-Version: woeusb\n"
"Report-Msgid-Bugs-To: WoeUSB Issue Tracker <https://github.com/slacka/WoeUSB/issues>\n"
"POT-Creation-Date: 2011-07-14 00:08+0100\n"
"PO-Revision-Date: 2011-07-14 00:13+0100\n"
"Last-Translator: GILLE Colin <colingille@hotmail.com>\n"
"Language-Team: WoeUSB Issue Tracker <https://github.com/slacka/WoeUSB/issues>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-Basepath: .\n"
"X-Poedit-Language: French\n"
"X-Poedit-Country: FRANCE\n"
"X-Poedit-SearchPath-0: ../../..\n"
#: ../../../MainFrame.cpp:41
msgid "Show all drives"
msgstr "Montrer tous les disques"
#: ../../../MainFrame.cpp:41
msgid "Show all drives, even those not detected as USB stick."
msgstr "Montrer tous les disques, même ceux qui ne sont pas détectés comme des clés USB."
#: ../../../MainFrame.cpp:53
msgid "&File"
msgstr "$Fichier"
#: ../../../MainFrame.cpp:54
msgid "&Help"
msgstr "&Aide"
#: ../../../App.cpp:82
msgid "Error : "
msgstr "Erreur :"
#: ../../../App.cpp:82
#: ../../../App.cpp:124
msgid "Error..."
msgstr "Erreur..."
#: ../../../App.cpp:117
msgid "Unknown error as occurred!"
msgstr "Une erreur inconnue s'est produite!"
#: ../../../App.cpp:124
msgid "Fatal error : "
msgstr "Erreur fatale :"
#: ../../../DialogAbout.cpp:46
#, c-format
msgid "Version %s"
msgstr "Version %s"
#: ../../../DialogAbout.cpp:55
msgid "Developer"
msgstr "Développeur"
#: ../../../DialogAbout.cpp:58
#, c-format
msgid ""
"%s is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n"
"\n"
"%s is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.\n"
"\n"
"You should have received a copy of the GNU General Public Licensealong with %s. If not, see <http://www.gnu.org/licenses/>."
msgstr ""
"%s est un logiciel libre ; vous pouvez le diffuser et/ou le modifier suivant les termes de la Licence Publique Générale GNU telle que publiée par la Free Software Foundation ; soit la version 3 de cette licence, soit (à votre convenance) une version ultérieure.\n"
"\n"
"%s est diffusé dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; sans même une garantie implicite de COMMERCIALISATION ou d'ADÉQUATION À UN USAGE PARTICULIER. Voyez la Licence Publique Générale GNU pour plus de détails.\n"
"\n"
"Vous devriez avoir reçu une copie de la Licence Publique Générale GNU avec %s ; sinon, veuillez écrire à la Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis."
#: ../../../DialogAbout.cpp:73
msgid "License"
msgstr "Licence"
#: ../../../MainPanel.cpp:45
msgid "Source :"
msgstr "Source :"
#: ../../../MainPanel.cpp:48
msgid "From a disk image (iso)"
msgstr "Depuis une image disque (iso)"
#: ../../../MainPanel.cpp:53
msgid "Please select a disk image"
msgstr "Veuillez sélectionner une image disque"
#: ../../../MainPanel.cpp:58
msgid "From a CD/DVD drive"
msgstr "Depuis un lecteur de CD/DVD"
#: ../../../MainPanel.cpp:70
msgid "Target device :"
msgstr "Disque de destination :"
#: ../../../MainPanel.cpp:81
msgid "Install"
msgstr "Installer"
#: ../../../MainPanel.cpp:247
msgid "Installing.."
msgstr "Installation en cours..."
#: ../../../MainPanel.cpp:247
msgid "Please wait..."
msgstr "Veuillez patienter..."
#: ../../../MainPanel.cpp:270
#: ../../../MainPanel.cpp:289
msgid "Are you sure you want to cancel the installation?"
msgstr "Êtes-vous sûr de vouloir annuler l'installation?"
#: ../../../MainPanel.cpp:270
#: ../../../MainPanel.cpp:289
msgid "Cancel"
msgstr "Annuler"
#: ../../../MainPanel.cpp:312
msgid "Installation succeeded!"
msgstr "Installation réussie!"
#: ../../../MainPanel.cpp:312
#: ../../../MainPanel.cpp:316
msgid "Installation"
msgstr "Installation"
#: ../../../MainPanel.cpp:316
msgid "Installation failed!"
msgstr "Erreur lors de l'installation!"
#: ../../../findFile.cpp:54
msgid "File not Found : "
msgstr "Fichier non trouvé :"
#: ../../../findFile.cpp:54
msgid "Error"
msgstr "Erreur"
#: ../../../strWxStdConv.hpp:106
msgid "bytes"
msgstr "octets"
#: ../../../AppConfig.hpp:7
msgid "WoeUSB"
msgstr "WoeUSB"
#: ../../../DialogAbout.hpp:68
msgid "About"
msgstr "À Propos"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
SUBDIRS = LC_MESSAGES

View File

@ -0,0 +1,122 @@
# Polish translations for woeusb package
# Polskie tłumaczenia dla pakietu woeusb.
# Copyright (C) 2018 THE woeusb'S COPYRIGHT HOLDER
# This file is distributed under the same license as the woeusb package.
# Jakub Szymański <jakubmateusz@poczta.onet.pl>, 2018.
#
msgid ""
msgstr ""
"Project-Id-Version: woeusb\n"
"Report-Msgid-Bugs-To: WoeUSB Issue Tracker <https://github.com/slacka/WoeUSB/"
"issues>\n"
"POT-Creation-Date: 2018-07-30 15:09+0200\n"
"PO-Revision-Date: 2018-07-30 15:34+0200\n"
"Last-Translator: Jakub Szymański <jakubmateusz@poczta.onet.pl>\n"
"Language-Team: Polish\n"
"Language: pl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
"|| n%100>=20) ? 1 : 2);\n"
"X-Generator: Poedit 2.0.9\n"
"X-Poedit-SearchPath-0: ..\n"
#: woeusbgui:67
msgid "Show all drives"
msgstr "Pokaż wszystkie dyski"
#: woeusbgui:68
msgid "Show all drives, even those not detected as USB stick."
msgstr ""
"Pokaż wszystkie dyski, nawet jeśli system nie widzi ich jako pamięci na USB."
#: woeusbgui:78
msgid "Set boot flag"
msgstr "Ustaw flagę boot"
#: woeusbgui:79
msgid "Sets boot flag after process of copying."
msgstr "Ustawia flagę \"boot\" po zakończeniu kopiowania."
#: woeusbgui:81
msgid "Use NTFS"
msgstr "Użyj NTFS"
#: woeusbgui:82
msgid "Use NTFS instead of FAT. NOTE: NTFS seems to be slower than FAT."
msgstr "Użyj NTFS zamiast FAT. Notka: NTFS zdaje się być wolniejszy od FAT."
#: woeusbgui:88
msgid "&File"
msgstr "&Plik"
#: woeusbgui:89
msgid "&Options"
msgstr "&Opcje"
#: woeusbgui:90
msgid "&Help"
msgstr "&Pomoc"
#: woeusbgui:146
msgid "Source :"
msgstr "Źródło :"
#: woeusbgui:149
msgid "From a disk image (iso)"
msgstr "Z pliku (iso) na dysku"
#: woeusbgui:154
msgid "Please select a disk image"
msgstr "Prosze wybierz obraz dysku"
#: woeusbgui:160
msgid "From a CD/DVD drive"
msgstr "Z napędu optycznego"
#: woeusbgui:173
msgid "Target device :"
msgstr "Urządzenie docelowe :"
#: woeusbgui:185
msgid "Install"
msgstr "Instaluj"
#: woeusbgui:275
msgid "Installing"
msgstr "Instalacja"
#: woeusbgui:275
msgid "Please wait..."
msgstr "Proszę czekać..."
#: woeusbgui:286
msgid "Are you sure you want to cancel the installation?"
msgstr "Jesteś pewnien że chcesz przerwać instalacje?"
#: woeusbgui:286
msgid "Cancel"
msgstr "Przerwi"
#: woeusbgui:295
msgid "Installation succeeded!"
msgstr "Instalacja!"
#: woeusbgui:295 woeusbgui:297
msgid "Installation"
msgstr "Instalacja"
#: woeusbgui:297
msgid "Installation failed!"
msgstr "Instalacja zakończona niepowodzeniem!"
#: woeusbgui:312
msgid "About"
msgstr "O programie"
#: woeusbgui:370
msgid "License"
msgstr "Licencja"

117
src/locale/woeusb.pot Normal file
View File

@ -0,0 +1,117 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: woeusb\n"
"Report-Msgid-Bugs-To: WoeUSB Issue Tracker <https://github.com/slacka/WoeUSB/issues>\n"
"POT-Creation-Date: 2018-07-30 15:09+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Jakub Szymański <jakubmateusz@poczta.onet.pl>\n"
"Language-Team: WoeUSB Issue Tracker <https://github.com/slacka/WoeUSB/issues>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-Basepath: .\n"
"X-Poedit-SearchPath-0: ..\n"
#: woeusbgui:67
msgid "Show all drives"
msgstr ""
#: woeusbgui:68
msgid "Show all drives, even those not detected as USB stick."
msgstr ""
#: woeusbgui:78
msgid "Set boot flag"
msgstr ""
#: woeusbgui:79
msgid "Sets boot flag after process of copying."
msgstr ""
#: woeusbgui:81
msgid "Use NTFS"
msgstr ""
#: woeusbgui:82
msgid "Use NTFS instead of FAT. NOTE: NTFS seems to be slower than FAT."
msgstr ""
#: woeusbgui:88
msgid "&File"
msgstr ""
#: woeusbgui:89
msgid "&Options"
msgstr ""
#: woeusbgui:90
msgid "&Help"
msgstr ""
#: woeusbgui:146
msgid "Source :"
msgstr ""
#: woeusbgui:149
msgid "From a disk image (iso)"
msgstr ""
#: woeusbgui:154
msgid "Please select a disk image"
msgstr ""
#: woeusbgui:160
msgid "From a CD/DVD drive"
msgstr ""
#: woeusbgui:173
msgid "Target device :"
msgstr ""
#: woeusbgui:185
msgid "Install"
msgstr ""
#: woeusbgui:275
msgid "Installing"
msgstr ""
#: woeusbgui:275
msgid "Please wait..."
msgstr ""
#: woeusbgui:286
msgid "Are you sure you want to cancel the installation?"
msgstr ""
#: woeusbgui:286
msgid "Cancel"
msgstr ""
#: woeusbgui:295
msgid "Installation succeeded!"
msgstr ""
#: woeusbgui:295 woeusbgui:297
msgid "Installation"
msgstr ""
#: woeusbgui:297
msgid "Installation failed!"
msgstr ""
#: woeusbgui:312
msgid "About"
msgstr ""
#: woeusbgui:370
msgid "License"
msgstr ""

View File

@ -0,0 +1,7 @@
# Il faut mettre les fichiers dans le sous dossier locale/zh_TW/LC_MESSAGES de share...
pkgdatadir=$(mypkgdatadir)/locale/zh_TW/LC_MESSAGES
%.mo: %.po
msgfmt -o $@ $<
dist_pkgdata_DATA = $(srcdir)/woeusb.mo

View File

@ -0,0 +1,149 @@
msgid ""
msgstr ""
"Project-Id-Version: winusb\n"
"Report-Msgid-Bugs-To: WoeUSB Issue Tracker <https://github.com/slacka/WoeUSB/issues>\n"
"POT-Creation-Date: 2011-07-14 00:08+0100\n"
"PO-Revision-Date: 2016-07-09 20:51+0800\n"
"Last-Translator: V字龍 <Vdragon.Taiwan@gmail.com>\n"
"Language-Team: chinese-l10n <chinese-l10n@googlegroups.com>\n"
"Language: zh_TW\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Poedit 1.8.7.1\n"
"X-Poedit-SearchPath-0: ../../..\n"
#: ../../../MainFrame.cpp:41
msgid "Show all drives"
msgstr "秀出所有磁碟機"
#: ../../../MainFrame.cpp:41
msgid "Show all drives, even those not detected as USB stick."
msgstr "秀出所有磁碟機,就算沒有識別為 USB 記憶碟也一樣。"
#: ../../../MainFrame.cpp:53
msgid "&File"
msgstr "檔案(&F)"
#: ../../../MainFrame.cpp:54
msgid "&Help"
msgstr "尋求幫助(&H)"
#: ../../../App.cpp:82
msgid "Error : "
msgstr "錯誤:"
#: ../../../App.cpp:82 ../../../App.cpp:124
msgid "Error..."
msgstr "錯誤……"
#: ../../../App.cpp:117
msgid "Unknown error as occurred!"
msgstr "發生了未知的錯誤!"
#: ../../../App.cpp:124
msgid "Fatal error : "
msgstr "致命錯誤:"
#: ../../../DialogAbout.cpp:46
#, c-format
msgid "Version %s"
msgstr "第 %s 版"
#: ../../../DialogAbout.cpp:55
msgid "Developer"
msgstr "軟體開發者"
#: ../../../DialogAbout.cpp:58
#, c-format
msgid ""
"%s is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n"
"\n"
"%s is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.\n"
"\n"
"You should have received a copy of the GNU General Public Licensealong with %s. If not, see <http://www.gnu.org/licenses/>."
msgstr ""
"%s 為自由軟體:您可以在 Free Software Foundation 所發表的 GNU General Public License 授權條款第 3 版或任意(您所中意之)更近期版本的規定下進行本軟體的再散佈與修改。\n"
"\n"
"%s 以其會有所用的期望下而散佈,但**不做任何擔保**;甚至於不包含暗示其對於**商業價值**或是**特定需求的適用性**的保證。更多相關細節請參考 GNU General Public License 授權條款。\n"
"\n"
"您應該已經隨 %s 得到一份 GNU General Public License 授權條款的副本。如果沒有的話請上 <http://www.gnu.org/licenses/> 瀏覽。"
#: ../../../DialogAbout.cpp:73
msgid "License"
msgstr "授權條款"
#: ../../../MainPanel.cpp:45
msgid "Source :"
msgstr "來源可開機媒體:"
#: ../../../MainPanel.cpp:48
msgid "From a disk image (iso)"
msgstr "從一個光碟映像檔(iso)"
#: ../../../MainPanel.cpp:53
msgid "Please select a disk image"
msgstr "請選取一個光碟映像檔"
#: ../../../MainPanel.cpp:58
msgid "From a CD/DVD drive"
msgstr "從一個 CD/DVD 光碟機"
#: ../../../MainPanel.cpp:70
msgid "Target device :"
msgstr "目標裝置:"
#: ../../../MainPanel.cpp:81
msgid "Install"
msgstr "開始安裝"
#: ../../../MainPanel.cpp:247
msgid "Installing.."
msgstr "正在安裝……"
#: ../../../MainPanel.cpp:247
msgid "Please wait..."
msgstr "請稍候……"
#: ../../../MainPanel.cpp:270 ../../../MainPanel.cpp:289
msgid "Are you sure you want to cancel the installation?"
msgstr "請問您確定要取消安裝程序嗎?"
#: ../../../MainPanel.cpp:270 ../../../MainPanel.cpp:289
msgid "Cancel"
msgstr "取消"
#: ../../../MainPanel.cpp:312
msgid "Installation succeeded!"
msgstr "安裝成功!"
#: ../../../MainPanel.cpp:312 ../../../MainPanel.cpp:316
msgid "Installation"
msgstr "安裝程序"
#: ../../../MainPanel.cpp:316
msgid "Installation failed!"
msgstr "安裝失敗!"
#: ../../../findFile.cpp:54
msgid "File not Found : "
msgstr "找不到檔案:"
#: ../../../findFile.cpp:54
msgid "Error"
msgstr "錯誤"
#: ../../../strWxStdConv.hpp:106
msgid "bytes"
msgstr "位元組"
#: ../../../AppConfig.hpp:7
msgid "WinUSB"
msgstr "WinUSB Windows 可開機 USB 製作工具"
#: ../../../DialogAbout.hpp:68
msgid "About"
msgstr "關於本軟體"

View File

@ -0,0 +1 @@
SUBDIRS = LC_MESSAGES

333
src/utils.py Normal file
View File

@ -0,0 +1,333 @@
#!/usr/bin/env python
"""
This file is part of WoeUSB.
WoeUSB is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
WoeUSB is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with WoeUSB. If not, see <http://www.gnu.org/licenses/>.
"""
import os
import re
import sys
import shutil
import pathlib
import subprocess
#: Disable message coloring when set to True, set by --no-color
no_color = False
# External tools
try:
import termcolor
except ImportError:
print("Module termcolor is not installed, text coloring disabled")
no_color = True
gui = None
verbose = False
def check_runtime_dependencies(application_name):
"""
:param application_name:
:return:
"""
result = "success"
system_commands = ["mount", "wipefs", "lsblk", "blockdev", "df", "parted", "7z"]
for command in system_commands:
if shutil.which(command) is None:
print_with_color(
"Error: " + application_name + " requires " + command +
" command in the executable search path, but it is not found.",
"red")
result = "failed"
fat = ["mkdosfs", "mkfs.msdos", "mkfs.vfat", "mkfs.fat"]
for command in fat:
if shutil.which(command) != "":
fat = command
break
if isinstance(fat, list):
print_with_color("Error: mkdosfs/mkfs.msdos/mkfs.vfat/mkfs.fat command not found!", "red")
print_with_color("Error: Please make sure that dosfstools is properly installed!", "red")
result = "failed"
ntfs = "mkntfs"
if shutil.which("mkntfs") == "":
print_with_color("Error: mkntfs command not found!", "red")
print_with_color("Error: Please make sure that ntfs-3g is properly installed!", "red")
result = "failed"
grub = ["grub-install", "grub2-install"]
for command in grub:
if shutil.which(command) != "":
grub = command
break
if isinstance(grub, list):
print_with_color("Error: grub-install or grub2-install command not found!", "red")
print_with_color("Error: Please make sure that GNU GRUB is properly installed!", "red")
result = "failed"
if result != "success":
raise RuntimeError("Dependencies are not met")
else:
return [fat, ntfs, grub]
def check_runtime_parameters(install_mode, source_media, target_media):
"""
:param install_mode:
:param source_media:
:param target_media:
:return:
"""
if not os.path.isfile(source_media) and not pathlib.Path(source_media).is_block_device():
print_with_color(
"Error: source media \"" + source_media + "\" not found or not a regular file or a block device file!",
"red")
return 1
if not pathlib.Path(target_media).is_block_device():
print_with_color("Error: Target media \"" + target_media + "\" is not a block device file!", "red")
return 1
if install_mode == "device" and target_media[-1].isdigit():
print_with_color("Error: Target media \"" + target_media + "\" is not an entire storage device!", "red")
return 1
if install_mode == "partition" and not target_media[-1].isdigit():
print_with_color("Error: Target media \"" + target_media + "\" is not an partition!", "red")
return 1
return 0
def determine_target_parameters(install_mode, target_media):
"""
:param install_mode:
:param target_media:
:return:
"""
if install_mode == "partition":
target_partition = target_media
while target_media[-1].isdigit():
target_media = target_media[:-1]
target_device = target_media
else:
target_device = target_media
target_partition = target_media + str(1)
if verbose:
print_with_color("Info: Target device is " + target_device)
print_with_color("Info: Target partition is " + target_partition)
return [target_device, target_partition]
def check_is_target_device_busy(device):
"""
:param device:
:return:
"""
mount = subprocess.run("mount", stdout=subprocess.PIPE).stdout.decode("utf-8").strip()
if re.findall(device, mount) != []:
return 1
return 0
def check_source_and_target_not_busy(install_mode, source_media, target_device, target_partition):
"""
:param install_mode:
:param source_media:
:param target_device:
:param target_partition:
:return:
"""
if check_is_target_device_busy(source_media):
print_with_color("Error: Source media is currently mounted, unmount the partition then try again", "red")
return 1
if install_mode == "partition":
if check_is_target_device_busy(target_partition):
print_with_color("Error: Target partition is currently mounted, unmount the partition then try again",
"red")
return 1
else:
if check_is_target_device_busy(target_device):
print_with_color(
"Error: Target device is currently busy, unmount all mounted partitions in target device then try again",
"red")
return 1
def check_fat32_filesize_limitation(source_fs_mountpoint):
"""
:param source_fs_mountpoint:
:return:
"""
for dirpath, dirnames, filenames in os.walk(source_fs_mountpoint):
for file in filenames:
path = os.path.join(dirpath, file)
if os.path.getsize(path) > (2 ** 32) - 1: # Max fat32 file size
print_with_color(
"Warining: File " + path + " in source image has exceed the FAT32 Filesystem 4GiB Single File Size Limitation, swiching to NTFS filesystem.",
"yellow")
print_with_color(
"Refer: https://github.com/slacka/WoeUSB/wiki/Limitations#fat32-filesystem-4gib-single-file-size-limitation for more info.",
"yellow")
return 1
return 0
def check_target_partition(target_partition, target_device):
"""
Check target partition for potential problems before mounting them for --partition creation mode as we don't know about the existing partition
:param target_partition: The target partition to check
:param target_device: The parent device of the target partition, this is passed in to check UEFI:NTFS filesystem's existence on check_uefi_ntfs_support_partition
:return:
"""
target_filesystem = subprocess.run(["lsblk",
"--output", "FSTYPE",
"--noheadings",
target_partition], stdout=subprocess.PIPE).stdout.decode("utf-8").strip()
if target_filesystem == "vfat":
pass # supported
elif target_filesystem == "ntfs":
check_uefi_ntfs_support_partition(target_device)
else:
print_with_color("Error: Target filesystem not supported, currently supported filesystem: FAT, NTFS.", "red")
return 1
return 0
def check_uefi_ntfs_support_partition(target_device):
"""
Check if the UEFI:NTFS support partition exists
Currently it depends on the fact that this partition has a label of "UEFI_NTFS"
:param target_device: The UEFI:NTFS partition residing entier device file
:return:
"""
lsblk = subprocess.run(["lsblk",
"--output", "LABEL",
"--noheadings",
target_device], stdout=subprocess.PIPE).stdout.decode("utf-8").strip()
if re.findall("UEFI_NTFS", lsblk) != []:
print_with_color(
"Warning: Your device doesn't seems to have an UEFI:NTFS partition, UEFI booting will fail if the motherboard firmware itself doesn't support NTFS filesystem!")
print_with_color(
"Info: You may recreate disk with an UEFI:NTFS partition by using the --device creation method")
def check_target_filesystem_free_space(target_fs_mountpoint, source_fs_mountpoint, target_partition):
"""
:param target_fs_mountpoint:
:param source_fs_mountpoint:
:param target_partition:
:return:
"""
df = subprocess.run(["df",
"--block-size=1",
target_fs_mountpoint], stdout=subprocess.PIPE).stdout
# free_space = int(df.strip().split()[4])
awk = subprocess.Popen(["awk", "{print $4}"], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
free_space = awk.communicate(input=df)[0]
free_space = free_space.decode("utf-8").strip()
free_space = re.sub("[^0-9]", "", free_space)
free_space = int(free_space)
needed_space = 0
for dirpath, dirnames, filenames in os.walk(source_fs_mountpoint):
for file in filenames:
path = os.path.join(dirpath, file)
needed_space += os.path.getsize(path)
additional_space_required_for_grub_installation = 1000 * 1000 * 10 # 10MiB
needed_space += additional_space_required_for_grub_installation
if needed_space > free_space:
print_with_color("Error: Not enough free space on target partition!")
print_with_color(
"Error: We required " + get_size(
str(needed_space)) + "(" + str(needed_space) + " bytes) but '" + target_partition + "' only has " + str(free_space) + "(" + str(free_space) + " bytes).")
return 1
def print_with_color(text, color=""):
"""
Print function
This function takes into account no_color flag
Also if used by gui, sends information to it, rather than putting it into standard output
:param text: Text to be printed
:param color: Color of the text
"""
if gui is not None:
gui.state = text
if color == "red":
gui.error = text
sys.exit()
else:
if no_color or color == "":
sys.stdout.write(text + "\n")
else:
termcolor.cprint(text, color)
def convert_to_human_readable_format(num, suffix='B'):
for unit in ['', 'Ki', 'Mi', 'Gi']:
if abs(num) < 1024.0:
return "%3.1f%s%s" % (num, unit, suffix)
num /= 1024.0
return "%.1f%s%s" % (num, 'Ti', suffix)
def get_size(path):
total_size = 0
for dirpath, _, filenames in os.walk(path):
for file in filenames:
path = os.path.join(dirpath, file)
total_size += os.path.getsize(path)
return total_size
# Ok, you may asking yourself, what the f**k is this, and why is it called everywhere. Let me explain
# In python you can't just stop or kill thread, it must end its execution,
# or recognize moment where you want it to stop and politely perform euthanasia on itself.
# So, here, if gui is set, we throw exception which is going to be (hopefully) catch by GUI,
# simultaneously ending whatever script was doing meantime!
# Everyone goes to home happy and user is left with wrecked pendrive (just joking, next thing called by gui is cleanup)
def check_kill_signal():
"""
Ok, you may asking yourself, what the f**k is this, and why is it called everywhere. Let me explain
In python you can't just stop or kill thread, it must end its execution,
or recognize moment where you want it to stop and politely perform euthanasia on itself.
So, here, if gui is set, we throw exception which is going to be (hopefully) catch by GUI,
simultaneously ending whatever script was doing meantime!
Everyone goes to home happy and user is left with wrecked pendrive (just joking, next thing called by gui is cleanup)
"""
if gui is not None:
if gui.kill:
raise sys.exit()

2
src/win32/Makefile.am Normal file
View File

@ -0,0 +1,2 @@
EXTRA_DIST = $(srcdir)/icon.ico $(srcdir)/winProg.manifest

BIN
src/win32/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly
xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<assemblyIdentity
processorArchitecture="x86"
version="5.1.0.0"
type="win32"
name="c501wakeonlan.exe"/>
<description>c501wakeonlan</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="x86"/>
</dependentAssembly>
</dependency>
</assembly>

56
src/woeusb Normal file
View File

@ -0,0 +1,56 @@
#!/usr/bin/env python
"""
+A Linux program to create bootable Windows USB stick from a real Windows DVD or an image
+Copyright © 2013 Colin GILLE / congelli501
+Copyright © 2017 slacka et. al.
+Python port - 2018 WaxyMocha
+
+This file is part of WoeUSB.
+
+WoeUSB is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+WoeUSB is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with WoeUSB If not, see <http://www.gnu.org/licenses/>.
+"""
import os
import sys
if "XDG_DATA_DIRS" in os.environ:
dirs = os.environ["XDG_DATA_DIRS"].split(":")
tmp = []
for directory in dirs:
tmp.append(directory + "/WoeUSB")
dirs = tmp
else:
dirs = ["/usr/local/share/WoeUSB", "/usr/share/WoeUSB"]
try:
# Try to import from same folder where this file is
import core
except ImportError:
# Add possible directories where WoeUSB can be installed and try to import form them
sys.path = sys.path + dirs
try:
import core
except ImportError:
# Broken installation?
print("Couldn't find program files, please reinstall WoeUSB and if that won't help contact us on github")
sys.exit(1)
core.run()

480
src/woeusbgui Normal file
View File

@ -0,0 +1,480 @@
#!/usr/bin/env python
"""
This file is part of WoeUSB.
WoeUSB is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
WoeUSB is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with WoeUSB. If not, see <http://www.gnu.org/licenses/>.
"""
import os
import sys
import time
import gettext
import threading
import subprocess
from os.path import dirname, realpath
import wx
import wx.adv
if "XDG_DATA_DIRS" in os.environ:
dirs = os.environ["XDG_DATA_DIRS"].split(":")
tmp = []
for directory in dirs:
tmp.append(directory + "/WoeUSB")
dirs = tmp
else:
dirs = ["/usr/local/share/WoeUSB", "/usr/share/WoeUSB"]
dirs.append(dirname(realpath(__file__)))
try:
# Try to import from same folder where this file is
import core
import list_devices
except ImportError:
# Add possible directories where WoeUSB can be installed and try to import form them
sys.path = sys.path + dirs
try:
import core
import list_devices
except ImportError:
# Broken installation?
print("Couldn't find program files, please reinstall WoeUSB and if that won't help contact us on github")
sys.exit(1)
app = wx.App()
locale = wx.Locale(wx.LANGUAGE_DEFAULT)
locale.AddCatalogLookupPathPrefix("locale")
locale.AddCatalog("woeusb")
translation = gettext.translation("woeusb", "locale",
[locale.GetCanonicalName()], fallback=True)
translation.install()
_ = wx.GetTranslation
PROG_FULL_NAME = "WoeUSB"
# Missing config.hpp included by AppConfig.hpp?
# PROG_PKG_NAME = PACKAGE
# PROG_PKG_NAME_GETTEXT = PROG_PKG_NAME
VERSION = "1.0.0"
class MainFrame(wx.Frame):
__MainPanel = None
__MenuBar = None
__menuItemShowAll = None
def __init__(self, title, pos, size, style=wx.DEFAULT_FRAME_STYLE):
super(MainFrame, self).__init__(None, -1, title, pos, size, style)
file_menu = wx.Menu()
self.__menuItemShowAll = wx.MenuItem(file_menu, wx.ID_ANY, _("Show all drives") + " \tCtrl+A",
_("Show all drives, even those not detected as USB stick."), wx.ITEM_CHECK)
file_menu.Append(self.__menuItemShowAll)
file_menu.AppendSeparator()
exit_item = file_menu.Append(wx.ID_EXIT)
help_menu = wx.Menu()
help_item = help_menu.Append(wx.ID_ABOUT)
options_menu = wx.Menu()
self.options_boot = wx.MenuItem(options_menu, wx.ID_ANY, _("Set boot flag"),
_("Sets boot flag after process of copying."),
wx.ITEM_CHECK)
self.options_filesystem = wx.MenuItem(options_menu, wx.ID_ANY, _("Use NTFS"),
_("Use NTFS instead of FAT. NOTE: NTFS seems to be slower than FAT."),
wx.ITEM_CHECK)
options_menu.Append(self.options_boot)
options_menu.Append(self.options_filesystem)
self.__MenuBar = wx.MenuBar()
self.__MenuBar.Append(file_menu, _("&File"))
self.__MenuBar.Append(options_menu, _("&Options"))
self.__MenuBar.Append(help_menu, _("&Help"))
self.SetMenuBar(self.__MenuBar)
main_sizer = wx.BoxSizer(wx.VERTICAL)
self.__MainPanel = MainPanel(self, wx.ID_ANY)
main_sizer.Add(self.__MainPanel, 1, wx.EXPAND | wx.ALL, 4)
self.SetSizer(main_sizer)
# self.Connect(self.__menuItemShowAll.GetId(), wx.EVT_MENU, MainPanel.on_show_all_drive, None, self.__MainPanel)
self.Bind(wx.EVT_MENU, self.__MainPanel.on_show_all_drive)
self.Bind(wx.EVT_MENU, self.on_quit, exit_item)
self.Bind(wx.EVT_MENU, self.on_about, help_item)
def on_quit(self, _):
self.Close(True)
def on_about(self, _):
my_dialog_about = DialogAbout(self, wx.ID_ANY)
my_dialog_about.ShowModal()
def is_show_all_checked(self):
return self.__menuItemShowAll.IsChecked()
class MainPanel(wx.Panel):
__parent = None
__dvdDriveList = None
__usbStickList = wx.ListBox
__dvdDriveDevList = []
__usbStickDevList = []
__isoFile = wx.FilePickerCtrl
__parentFrame = None
__btInstall = None
__btRefresh = None
__isoChoice = None
__dvdChoice = None
def __init__(self, parent, ID, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL):
super(MainPanel, self).__init__(parent, ID, pos, size, style)
self.__parent = parent
# Controls
main_sizer = wx.BoxSizer(wx.VERTICAL)
# Iso / CD
main_sizer.Add(wx.StaticText(self, wx.ID_ANY, _("Source :")), 0, wx.ALL, 3)
# Iso
self.__isoChoice = wx.RadioButton(self, wx.ID_ANY, _("From a disk image (iso)"))
main_sizer.Add(self.__isoChoice, 0, wx.ALL, 3)
tmp_sizer = wx.BoxSizer(wx.HORIZONTAL)
tmp_sizer.AddSpacer(20)
self.__isoFile = wx.FilePickerCtrl(self, wx.ID_ANY, "", _("Please select a disk image"),
"Iso images (*.iso)|*.iso;*.ISO|All files|*")
tmp_sizer.Add(self.__isoFile, 1, wx.LEFT | wx.RIGHT | wx.BOTTOM, 3)
main_sizer.Add(tmp_sizer, 0, wx.EXPAND, 0)
# DVD
self.__dvdChoice = wx.RadioButton(self, wx.ID_ANY, _("From a CD/DVD drive"))
main_sizer.Add(self.__dvdChoice, 0, wx.ALL, 3)
# List
tmp_sizer = wx.BoxSizer(wx.HORIZONTAL)
tmp_sizer.AddSpacer(20)
self.__dvdDriveList = wx.ListBox(self, wx.ID_ANY)
tmp_sizer.Add(self.__dvdDriveList, 1, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 3)
main_sizer.Add(tmp_sizer, 1, wx.EXPAND, 0)
# Target
main_sizer.AddSpacer(20)
main_sizer.Add(wx.StaticText(self, wx.ID_ANY, _("Target device :")), 0, wx.ALL, 3)
# List
self.__usbStickList = wx.ListBox(self, wx.ID_ANY)
main_sizer.Add(self.__usbStickList, 1, wx.EXPAND | wx.ALL, 3)
# Buttons
main_sizer.AddSpacer(30)
bt_sizer = wx.BoxSizer(wx.HORIZONTAL)
self.__btRefresh = wx.Button(self, wx.ID_REFRESH)
bt_sizer.Add(self.__btRefresh, 0, wx.ALL, 3)
self.__btInstall = wx.Button(self, wx.ID_ANY, _("Install"))
bt_sizer.Add(self.__btInstall, 0, wx.ALL, 3)
main_sizer.Add(bt_sizer, 0, wx.ALIGN_RIGHT, 0)
# Finalization
self.SetSizer(main_sizer)
self.Bind(wx.EVT_LISTBOX, self.on_list_or_file_modified, self.__usbStickList)
self.Bind(wx.EVT_LISTBOX, self.on_list_or_file_modified, self.__dvdDriveList)
self.Bind(wx.EVT_FILEPICKER_CHANGED, self.on_list_or_file_modified, self.__isoFile)
self.Bind(wx.EVT_BUTTON, self.on_install, self.__btInstall)
self.Bind(wx.EVT_BUTTON, self.on_refresh, self.__btRefresh)
self.Bind(wx.EVT_RADIOBUTTON, self.on_source_option_changed, self.__isoChoice)
self.Bind(wx.EVT_RADIOBUTTON, self.on_source_option_changed, self.__dvdChoice)
self.refresh_list_content()
self.on_source_option_changed(wx.CommandEvent)
self.__btInstall.Enable(self.is_install_ok())
def refresh_list_content(self):
# USB
self.__usbStickDevList = []
self.__usbStickList.Clear()
show_all_checked = self.__parent.is_show_all_checked()
device_list = list_devices.usb_drive(show_all_checked)
for device in device_list:
self.__usbStickDevList.append(device[0])
self.__usbStickList.Append(device[1])
# ISO
self.__dvdDriveDevList = []
self.__dvdDriveList.Clear()
drive_list = list_devices.dvd_drive()
for drive in drive_list:
self.__dvdDriveDevList.append(drive[0])
self.__dvdDriveList.Append(drive[1])
self.__btInstall.Enable(self.is_install_ok())
def on_source_option_changed(self, _):
is_iso = self.__isoChoice.GetValue()
self.__isoFile.Enable(is_iso)
self.__dvdDriveList.Enable(not is_iso)
self.__btInstall.Enable(self.is_install_ok())
def is_install_ok(self):
is_iso = self.__isoChoice.GetValue()
return ((is_iso and os.path.isfile(self.__isoFile.GetPath())) or (
not is_iso and self.__dvdDriveList.GetSelection() != wx.NOT_FOUND)) and self.__usbStickList.GetSelection() != wx.NOT_FOUND
def on_list_or_file_modified(self, event):
if event.GetEventType() == wx.EVT_LISTBOX and not event.IsSelection():
return
self.__btInstall.Enable(self.is_install_ok())
def on_refresh(self, _):
self.refresh_list_content()
def on_install(self, _):
global woe
if self.is_install_ok():
is_iso = self.__isoChoice.GetValue()
device = self.__usbStickDevList[self.__usbStickList.GetSelection()]
if is_iso:
iso = self.__isoFile.GetPath()
else:
iso = self.__dvdDriveDevList[self.__dvdDriveList.GetSelection()]
if self.__parent.options_filesystem.IsChecked():
filesystem = "NTFS"
else:
filesystem = "FAT"
woe = WoeUSB(iso, device, boot_flag=self.__parent.options_boot.IsChecked(), filesystem=filesystem)
woe.start()
dialog = wx.ProgressDialog(_("Installing"), _("Please wait..."), 101, self.GetParent(),
wx.PD_APP_MODAL | wx.PD_SMOOTH | wx.PD_CAN_ABORT)
while woe.is_alive():
if not woe.progress:
status = dialog.Pulse(woe.state)[0]
time.sleep(0.06)
else:
status = dialog.Update(woe.progress, woe.state)[0]
if not status:
if wx.MessageBox(_("Are you sure you want to cancel the installation?"), _("Cancel"),
wx.YES_NO | wx.ICON_QUESTION, self) == wx.NO:
dialog.Resume()
else:
woe.kill = True
break
dialog.Destroy()
if woe.error == "":
wx.MessageBox(_("Installation succeeded!"), _("Installation"), wx.OK | wx.ICON_INFORMATION, self)
else:
wx.MessageBox(_("Installation failed!") + "\n" + str(woe.error), _("Installation"), wx.OK | wx.ICON_ERROR,
self)
def on_show_all_drive(self, _):
self.refresh_list_content()
class DialogAbout(wx.Dialog):
__bitmapIcone = None
__staticTextTitre = None
__staticTextVersion = None
__NotebookAutorLicence = None
__MyPanelNoteBookAutors = None
__BtOk = None
def __init__(self, parent, ID=wx.ID_ANY, title=_("About"), pos=wx.DefaultPosition, size=wx.Size(570, 590),
style=wx.DEFAULT_DIALOG_STYLE):
super(DialogAbout, self).__init__(parent, ID, title, pos, size, style)
self.SetSizeHints(wx.DefaultSize, wx.DefaultSize)
sizer_all = wx.BoxSizer(wx.VERTICAL)
sizer_img = wx.BoxSizer(wx.HORIZONTAL)
img_file_name = "data/icon.png"
img = wx.Image(img_file_name, wx.BITMAP_TYPE_PNG)
self.__bitmapIcone = wx.StaticBitmap(self, wx.ID_ANY, wx.Bitmap(img), wx.DefaultPosition, wx.Size(48, 48))
sizer_img.Add(self.__bitmapIcone, 0, wx.ALL, 5)
sizer_text = wx.BoxSizer(wx.VERTICAL)
self.__staticTextTitre = wx.StaticText(self, wx.ID_ANY, PROG_FULL_NAME)
self.__staticTextTitre.SetFont(wx.Font(16, 74, 90, 92, False, "Sans"))
self.__staticTextTitre.SetForegroundColour(wx.Colour(0, 60, 118))
sizer_text.Add(self.__staticTextTitre, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 5)
self.__staticTextVersion = wx.StaticText(self, wx.ID_ANY, VERSION)
self.__staticTextVersion.SetFont(wx.Font(10, 74, 90, 92, False, "Sans"))
self.__staticTextVersion.SetForegroundColour(wx.Colour(69, 141, 196))
sizer_text.Add(self.__staticTextVersion, 0, wx.LEFT, 5)
sizer_img.Add(sizer_text, 0, 0, 5)
sizer_all.Add(sizer_img, 0, wx.EXPAND, 5)
self.__NotebookAutorLicence = wx.Notebook(self, wx.ID_ANY)
self.__NotebookAutorLicence.AddPage(
PanelNoteBookAutors(self.__NotebookAutorLicence, wx.ID_ANY, "slacka et al.", "data/woeusb-logo.png",
"github.com/slacka/WoeUSB"), "Authors", True)
self.__NotebookAutorLicence.AddPage(
PanelNoteBookAutors(self.__NotebookAutorLicence, wx.ID_ANY, "Colin GILLE / Congelli501",
"data/c501-logo.png", "www.congelli.eu"), "Original WinUSB Developer", False)
licence_str = '''
This file is part of WoeUSB.
WoeUSB is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
WoeUSB is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with WoeUSB. If not, see <http://www.gnu.org/licenses/>.
'''
licence_txt = wx.TextCtrl(self.__NotebookAutorLicence, wx.ID_ANY, licence_str, wx.DefaultPosition,
wx.DefaultSize, wx.TE_MULTILINE | wx.TE_READONLY)
self.__NotebookAutorLicence.AddPage(licence_txt, _("License"))
sizer_all.Add(self.__NotebookAutorLicence, 1, wx.EXPAND | wx.ALL, 5)
self.__BtOk = wx.Button(self, wx.ID_OK)
sizer_all.Add(self.__BtOk, 0, wx.ALIGN_RIGHT | wx.BOTTOM | wx.RIGHT, 5)
self.__BtOk.SetFocus()
self.SetSizer(sizer_all)
self.Layout()
class PanelNoteBookAutors(wx.Panel):
def __init__(self, parent, ID=wx.ID_ANY, autherName="", imgName="", siteLink="", pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.TAB_TRAVERSAL):
super(PanelNoteBookAutors, self).__init__(parent, ID, pos, size, style)
sizer_note_book_autors = wx.BoxSizer(wx.VERTICAL)
auteur_static_text = wx.StaticText(self, wx.ID_ANY, autherName)
sizer_note_book_autors.Add(auteur_static_text, 0, wx.ALL, 5)
if siteLink != "":
autor_link = wx.adv.HyperlinkCtrl(self, wx.ID_ANY, siteLink, siteLink)
sizer_note_book_autors.Add(autor_link, 0, wx.LEFT | wx.BOTTOM, 5)
if imgName != "":
# img_file_name = findFile(imgName)
img = wx.Image(imgName, wx.BITMAP_TYPE_PNG)
img_autor_logo = wx.StaticBitmap(self, wx.ID_ANY, wx.Bitmap(img))
sizer_note_book_autors.Add(img_autor_logo, 0, wx.LEFT, 5)
self.SetSizer(sizer_note_book_autors)
class WoeUSB(threading.Thread):
"""
Class for handling communication with woeusb.
"""
progress = False
state = ""
error = ""
kill = False
def __init__(self, source, target, boot_flag, filesystem):
threading.Thread.__init__(self)
core.gui = self
self.source = source
self.target = target
self.boot_flag = boot_flag
self.filesystem = filesystem
def run(self):
source_fs_mountpoint, target_fs_mountpoint, temp_directory = core.init(from_cli=False,
install_mode="device",
source_media=self.source,
target_media=self.target)[:3]
try:
core.main(source_fs_mountpoint, target_fs_mountpoint, self.source, self.target, "device", temp_directory,
self.filesystem, self.boot_flag, )
except SystemExit:
pass
core.cleanup(source_fs_mountpoint, target_fs_mountpoint, temp_directory)
if __name__ == "__main__":
if os.getuid() != 0:
for directory in dirs:
if os.path.isfile(directory.rstrip("/") + "/woeusbgui"):
subprocess.run(["pkexec", directory.rstrip("/") + "/woeusbgui"])
exit(0)
frameTitle = PROG_FULL_NAME
frame = MainFrame(frameTitle, wx.DefaultPosition, wx.Size(400, 600))
frame.SetMinSize(wx.Size(300, 450))
frame.Show(True)
app.MainLoop()

145
src/workaround.py Normal file
View File

@ -0,0 +1,145 @@
#!/usr/bin/env python
"""
This file is part of WoeUSB.
WoeUSB is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
WoeUSB is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with WoeUSB. If not, see <http://www.gnu.org/licenses/>.
"""
import os
import subprocess
import time
import utils
def make_system_realize_partition_table_changed(target_device):
"""
:param target_device:
:return:
"""
utils.print_with_color("Making system realize that partition table has changed...")
subprocess.run(["blockdev", "--rereadpt", target_device])
utils.print_with_color("Wait 3 seconds for block device nodes to populate...")
time.sleep(3)
def buggy_motherboards_that_ignore_disks_without_boot_flag_toggled(target_device):
"""
Some buggy BIOSes won't put detected device with valid MBR but no partitions with boot flag toggled into the boot menu, workaround this by setting the first partition's boot flag(which partition doesn't matter as GNU GRUB doesn't depend on it anyway
:param target_device:
:return:
"""
utils.print_with_color(
"Applying workaround for buggy motherboards that will ignore disks with no partitions with the boot flag toggled")
subprocess.run(["parted", "--script",
target_device,
"set", "1", "boot", "on"])
def support_windows_7_uefi_boot(source_fs_mountpoint, target_fs_mountpoint):
"""
As Windows 7's installation media doesn't place the required EFI
bootloaders in the right location, we extract them from the
system image manually
:TODO: Functionize Windows 7 checking
:param source_fs_mountpoint:
:param target_fs_mountpoint:
:return:
"""
grep = subprocess.run(["grep", "--extended-regexp", "--quiet", "^MinServer=7[0-9]{3}\.[0-9]",
source_fs_mountpoint + "/sources/cversion.ini"],
stdout=subprocess.PIPE).stdout.decode("utf-8").strip()
if grep == "" and not os.path.isfile(source_fs_mountpoint + "/bootmgr.efi"):
return 0
utils.print_with_color(
"Source media seems to be Windows 7-based with EFI support, applying workaround to make it support UEFI booting",
"yellow")
test_efi_directory = subprocess.run(["find", target_fs_mountpoint, "-ipath", target_fs_mountpoint + "/efi"],
stdout=subprocess.PIPE).stdout.decode("utf-8").strip()
if test_efi_directory == "":
efi_directory = target_fs_mountpoint + "/efi"
if utils.verbose:
print("DEBUG: Can't find efi directory, use " + efi_directory)
else:
efi_directory = test_efi_directory
if utils.verbose:
print("DEBUG: " + efi_directory + " detected.")
test_efi_boot_directory = subprocess.run(["find", target_fs_mountpoint, "-ipath", target_fs_mountpoint + "/boot"],
stdout=subprocess.PIPE).stdout.decode("utf-8").strip()
if test_efi_boot_directory == "":
efi_boot_directory = target_fs_mountpoint + "/boot"
if utils.verbose:
print("DEBUG: Can't find efi/boot directory, use " + efi_boot_directory)
else:
efi_boot_directory = test_efi_boot_directory
if utils.verbose:
print("DEBUG: " + efi_boot_directory + " detected.")
# If there's already an EFI bootloader existed, skip the workaround
test_efi_bootloader = subprocess.run(
["find", target_fs_mountpoint, "-ipath", target_fs_mountpoint + "/efi/boot/boot*.efi"],
stdout=subprocess.PIPE).stdout.decode("utf-8").strip()
if test_efi_bootloader != "":
print("INFO: Detected existing EFI bootloader, workaround skipped.")
return 0
os.makedirs(efi_boot_directory, exist_ok=True)
bootloader = subprocess.run(["7z",
"e",
"-so",
source_fs_mountpoint + "/sources/install.wim",
"Windows/Boot/EFI/bootmgfw.efi"], stdout=subprocess.PIPE).stdout
with open(efi_boot_directory + "/bootx64.efi", "wb") as target_bootloader:
target_bootloader.write(bootloader)
def linux_make_writeback_buffering_not_suck(mode):
"""
:param mode: True - enable; False - disable
"""
if mode:
utils.print_with_color(
"Applying workaround to prevent 64-bit systems with big primary memory from being unresponsive during copying files.",
"yellow")
vm_dirty_background_bytes = str(16 * 1024 * 1024) # 16MiB
vm_dirty_bytes = str(48 * 1024 * 1024) # 48MiB
else:
utils.print_with_color(
"Resetting workaround to prevent 64-bit systems with big primary memory from being unresponsive during copying files.",
"yellow")
vm_dirty_background_bytes = "0"
vm_dirty_bytes = "0"
with open("/proc/sys/vm/dirty_background_bytes", "w") as dirty_background_bytes:
dirty_background_bytes.write(vm_dirty_background_bytes)
with open("/proc/sys/vm/dirty_bytes", "w") as dirty_bytes:
dirty_bytes.write(vm_dirty_bytes)