[packages/unetbootin] - yet another ugly way to detect usb devices
arekm
arekm at pld-linux.org
Sat Mar 3 11:38:38 CET 2018
commit f63327164603980b3c8e4535da4d71a15cec03a2
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Sat Mar 3 11:38:30 2018 +0100
- yet another ugly way to detect usb devices
unetbootin.spec | 4 +++-
usb.patch | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+), 1 deletion(-)
---
diff --git a/unetbootin.spec b/unetbootin.spec
index bd6d829..7ef192f 100644
--- a/unetbootin.spec
+++ b/unetbootin.spec
@@ -7,7 +7,7 @@ Group: Base
URL: https://unetbootin.github.io/
Source0: https://github.com/unetbootin/unetbootin/releases/download/%{version}/%{name}-source-%{version}.tar.gz
# Source0-md5: 50ad69c1d703e635d30c3aa4305093f7
-# Syslinux is only available on x86 architectures
+Patch0: usb.patch
BuildRequires: desktop-file-utils
BuildRequires: qt4-build
Requires: syslinux
@@ -23,6 +23,8 @@ distribution isn't on the list.
%prep
%setup -q -c
+%patch0 -p1
+
sed -i '/^Version/d' unetbootin.desktop
sed -i '/\[en_US\]/d' unetbootin.desktop
sed -i 's|%{_bindir}/unetbootin|unetbootin|g' unetbootin.desktop
diff --git a/usb.patch b/usb.patch
new file mode 100644
index 0000000..708daf1
--- /dev/null
+++ b/usb.patch
@@ -0,0 +1,58 @@
+diff -ur 1.org/unetbootin.cpp 1/unetbootin.cpp
+--- 1.org/unetbootin.cpp 2017-07-14 10:54:12.000000000 +0200
++++ 1/unetbootin.cpp 2018-03-03 11:31:28.430440832 +0100
+@@ -258,6 +258,10 @@
+ dfcommand = "/bin/df";
+ else
+ dfcommand = locatecommand("df", tr("either"), "util-linux");
++ if (QFile::exists("/bin/udevadm"))
++ udevadmcommand = "/bin/udevadm";
++ else
++ udevadmcommand = locatecommand("udevadm", tr("either"), "silent");
+ if (QFile::exists("/sbin/sfdisk"))
+ sfdiskcommand = "/sbin/sfdisk";
+ else
+@@ -585,6 +589,14 @@
+ return matchinglist;
+ }
+
++bool unetbootin::is_usb(QFileInfo path)
++{
++ if (!udevadmcommand.isEmpty()) {
++ return QString(callexternapp(udevadmcommand, QString("info -q path %2").arg(path.canonicalFilePath()))).contains(QRegExp("/usb\\d+/"));
++ }
++ return false;
++}
++
+ QStringList unetbootin::listsanedrives()
+ {
+ QStringList fulldrivelist;
+@@ -617,7 +629,8 @@
+ // fulldrivelist.append(usbfileinfoL.at(i).canonicalFilePath());
+ // }
+ if (usbfileinfoL.at(i).fileName().contains(QRegExp("^usb-\\S{1,}$")) ||
+- usbfileinfoL.at(i).fileName().contains(QRegExp("^mmc-\\S{1,}$")))
++ usbfileinfoL.at(i).fileName().contains(QRegExp("^mmc-\\S{1,}$")) ||
++ is_usb(usbfileinfoL.at(i)))
+ {
+ if (!volidcommand.isEmpty())
+ {
+diff -ur 1.org/unetbootin.h 1/unetbootin.h
+--- 1.org/unetbootin.h 2017-07-14 07:31:37.000000000 +0200
++++ 1/unetbootin.h 2018-03-03 11:27:22.499726441 +0100
+@@ -232,6 +232,7 @@
+ #ifdef Q_OS_UNIX
+ QString fdiskcommand;
+ QString sfdiskcommand;
++ QString udevadmcommand;
+ QString dfcommand;
+ QString blkidcommand;
+ QString volidcommand;
+@@ -302,6 +303,7 @@
+ QStringList matchinglist(QRegExp regex, QString text);
+ QStringList listsanedrives();
+ QStringList listalldrives();
++ bool is_usb(QFileInfo path);
+ void replaceTextInFile(QString repfilepath, QRegExp replaceme, QString replacewith);
+ QString fixkernelbootoptions(const QString &cfgfileCL);
+ void setLabel(QString devname, QString newlabel);
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/unetbootin.git/commitdiff/f63327164603980b3c8e4535da4d71a15cec03a2
More information about the pld-cvs-commit
mailing list