-
Notifications
You must be signed in to change notification settings - Fork 435
Use partuuid in installed_os.json #497
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -530,7 +530,13 @@ bool MultiImageWriteThread::processImage(OsInfo *image) | |
| QVariantList vpartitions; | ||
| foreach (PartitionInfo *p, *partitions) | ||
| { | ||
| vpartitions.append(p->partitionDevice()); | ||
| QString part = p->partitionDevice(); | ||
| if (part.left(13) != "/dev/mmcblk0p") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just out of curiosity, what happens if you remove this special-casing for
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We used to have some Linux distributions that came with an initramfs that did not support partuuid parameters (e.g. OSMC).
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @procount I wonder if it'd be worth adding an extra param to the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we piggy-back the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC, if an OS doesn't support partuuid, then it can't be installed to USB. If so, then the additional code won't be necessary. I'm sure @XECDesign or @maxnet explained the use of |
||
| { | ||
| part = getPartUUID(part); | ||
| } | ||
| vpartitions.append(part); | ||
|
|
||
| } | ||
| QSettings settings("/settings/noobs.conf", QSettings::IniFormat); | ||
| int videomode = settings.value("display_mode", 0).toInt(); | ||
|
|
@@ -1009,31 +1015,6 @@ void MultiImageWriteThread::patchConfigTxt() | |
|
|
||
| } | ||
|
|
||
| QByteArray MultiImageWriteThread::getLabel(const QString part) | ||
| { | ||
| QByteArray result; | ||
| QProcess p; | ||
| p.start("/sbin/blkid -s LABEL -o value "+part); | ||
| p.waitForFinished(); | ||
|
|
||
| if (p.exitCode() == 0) | ||
| result = p.readAll().trimmed(); | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| QByteArray MultiImageWriteThread::getUUID(const QString part) | ||
| { | ||
| QByteArray result; | ||
| QProcess p; | ||
| p.start("/sbin/blkid -s UUID -o value "+part); | ||
| p.waitForFinished(); | ||
|
|
||
| if (p.exitCode() == 0) | ||
| result = p.readAll().trimmed(); | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| QString MultiImageWriteThread::getDescription(const QString &folder, const QString &flavour) | ||
| { | ||
|
|
@@ -1065,35 +1046,3 @@ bool MultiImageWriteThread::isURL(const QString &s) | |
| return s.startsWith("http:") || s.startsWith("https:"); | ||
| } | ||
|
|
||
| QByteArray MultiImageWriteThread::getDiskId(const QString &device) | ||
| { | ||
| mbr_table mbr; | ||
|
|
||
| QFile f(device); | ||
| f.open(f.ReadOnly); | ||
| f.read((char *) &mbr, sizeof(mbr)); | ||
| f.close(); | ||
|
|
||
| quint32 diskid = qFromLittleEndian<quint32>(mbr.diskid); | ||
| return QByteArray::number(diskid, 16).rightJustified(8, '0');; | ||
| } | ||
|
|
||
| QByteArray MultiImageWriteThread::getPartUUID(const QString &devpart) | ||
| { | ||
| QByteArray r; | ||
|
|
||
| QRegExp partnrRx("([0-9]+)$"); | ||
| if (partnrRx.indexIn(devpart) != -1) | ||
| { | ||
| QString drive = devpart.left(partnrRx.pos()); | ||
| if (drive.endsWith("p")) | ||
| drive.chop(1); | ||
|
|
||
| r = "PARTUUID="+getDiskId(drive); | ||
| int partnr = partnrRx.cap(1).toInt(); | ||
| QByteArray partnrstr = QByteArray::number(partnr, 16).rightJustified(2, '0'); | ||
| r += '-'+partnrstr; | ||
| } | ||
|
|
||
| return r; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could probably use http://doc.qt.io/archives/qt-4.8/qstring.html#startsWith here instead?