Ë ¿{âÛaÈãóB—dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z mZmZmZdZej$«Zd„Zd„ZGd„d e«Zd „Zd „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Z d„Z!d„Z"d„Z#e$dk(rejJe#««yy)z¤ A tool for creating block maps (bmap) and copying disk images using bmap files. Documentation can be found here: source.tizen.org/documentation/reference/bmaptool éNé)Ú BmapCreateÚBmapCopyÚ BmapHelpersÚ TransReadz3.8.0có(—g}tj«dr#tj«j «}n/tj «D�cgc]}|j «‘Œ}}d}t|«dz }|t|«kr0||jd«r|dz }|}n|dz }|t|«krŒ0|d|}|r%tjddj|««|r||z}n t|«}tj|«ycc}w)z9Print an error message occurred along with the traceback.rrz File "éz-An error occurred, here is the traceback: %s Ú N) ÚsysÚexc_infoÚ tracebackÚ format_excÚ splitlinesÚ format_stackÚstripÚlenÚ startswithÚlogÚerrorÚjoinÚstr)Ú msgformatÚargsÚtbackÚlinesÚlineÚidxÚlast_idxÚerrmsgs ú1/usr/lib/python3.12/site-packages/bmaptool/CLI.pyÚprint_error_with_tbr!1sù€ð €Eä ‡|�|ƒ~�aÒÜ×$Ñ$Ó&×1Ñ1Ó3‰ä*3×*@Ñ*@Ô*BÓCÑ*B $�—‘•Ð*BˆÐCà €CÜ�5‹z˜A‰~€HØ ”�E“ Ò Ø �‰:× Ñ  Ô ,Ø �1‰HˆC؉Hà �1‰HˆCð ”�E“ Ó ð �!�HÐ €EÙ Ü � ‰ ÐCÀTÇYÁYÈuÓEUÔVá Ø˜TÑ!‰ä�Y“ˆÜ‡I�IˆfÕùò'DsÁDcóH—tt|«dzg|¢­Žtd«‚)z7Print an error message and terminate program execution.r r)r!rÚ SystemExit)rrs r Ú error_outr$Os$€ôœ˜I›¨Ñ-Ð5°Ó5Ü �Q‹-Ðócó—eZdZdZd„Zd„Zy)Ú NamedFileao This simple class allows us to override the 'name' attribute of a file object. The reason is that some classes use the 'name' attribute of the file object to print file path. But, for example, 'os.fdopen()' sets the name to "", which is not very user-friendly. Also, sometimes we want to substitute the file name with something else. có —||_||_y©N)Ú _file_objÚname)ÚselfÚfile_objr+s r Ú__init__zNamedFile.__init___s€Ø!ˆŒØˆ� r%có.—t|j|«Sr))Úgetattrr*)r,r+s r Ú __getattr__zNamedFile.__getattr__cs€Ü�t—~‘~ tÓ,Ð,r%N)Ú__name__Ú __module__Ú __qualname__Ú__doc__r.r1©r%r r'r'Vs„ñòó-r%r'cój— tj|tjtjz«} tj d«}t|«S#t$r}t d||«Yd}~Œ>d}~wwxYw#t$r,}tj«t d||«Yd}~Œ_d}~wwxYw)am This is a helper function for 'open_files()' which is called if the destination file of the "copy" command is a block device. We handle block devices a little bit different to regular files. Namely, we are trying to make sure that we do not write to a mounted block device, otherwise the user could corrupt, say, the root file system by a mistake. This is achieved by opening the block device in exclusive mode, which guarantees that we are the only users of the block device. This function opens a block device specified by 'path' in exclusive mode. Returns opened file object. z3cannot open block device '%s' in exclusive mode: %sNÚwbz!cannot open block device '%s': %s) ÚosÚopenÚO_WRONLYÚO_EXCLÚOSErrorr$ÚfdopenÚcloser')ÚpathÚ descriptorÚerrr-s r Úopen_block_devicerCgs�€ðTÜ—W‘W˜T¤2§;¡;´·±Ñ#:Ó;ˆ ð CÜ—9‘9˜Z¨Ó.ˆô �X˜tÓ $Ð$øô òTÜÐGÈÈs×SÑSûðTûô òCÜ �‰�ÔÜÐ6¸¸c×BÑBûðCús.‚5A¸A=Á A:Á# A5Á5A:Á= B2Â"B-Â-B2cóº—ddl}|D]Ò}|j|jjzdk7rx|j |j «}|j dj›d|j dj›d�}tjd|›d|j ›d�«Œ¡td|j |jd j««ŒÔy) zà This is a helper function which reports the GPG signature verification results. The 'context' argument is the gpg context object, and the 'sigs' argument contains the results of the 'gpg.verify()' function. rNz <Ú>z-successfully verified bmap file signature of z (fingerprint Ú)z‚signature verification failed (fingerprint %s): %s Either fix the problem or use --no-sig-verify to disable signature verificationr )ÚgpgÚsummaryÚ constantsÚ SIGSUM_VALIDÚget_keyÚfprÚuidsr+ÚemailrÚinfor$ÚstatusÚlower)ÚcontextÚsigsrGÚsigÚkeyÚauthors r Úreport_verification_resultsrW„sª€óãˆØ �K‰K˜#Ÿ-™-×4Ñ4Ñ 4¸Ò :Ø—/‘/ #§'¡'Ó*ˆCØ"%§(¡(¨1¡+×"2Ó"2°C·H±H¸Q±K×4EÓ4EÐFˆFÜ �HŠHâ&,¨c¯g«gð7õ ô ð1ð—‘Ø— ‘ ˜1‘ ×#Ñ#Ó%õ  ñr%có†—|jry|jr- tj|j«}|j}n3 |dz}tj|«}t j d|z«jrO tjd«}tj|«|jd«|j«|} ddl} j#«}t%j&|j(«} t%j&|j(«} |j+| | d«d j,} |j«t7 «dk(rt j9d |z«yt;| «y#tj$r"}t d|j|«Yd}~�Œƒd}~wwxYw#tj$r: |dz}tj|«}n#tj$rYYywxYwY�Œ¯wxYw#t$r}t d|«Yd}~�Œ”d}~wwxYw#t $rt d «Y�ŒuwxYw#j.j0$r&}t d |j3«|«Yd}~�ŒDd}~w|j.j4$r}t d |«Yd}~�Œrd}~wwxYw)zp This is a helper function for 'verify_bmap_signature()' which handles the detached signature case. Nz(cannot open bmap signature file '%s': %sz.ascz.sigz'discovered signature file for bmap '%s'úwb+z4cannot create a temporary file for the signature: %srz”cannot verify the signature because the python "gpg" module is not installed on your system Please, either install the module or use --no-sig-verifyrzYfailure when trying to verify GPG signature: %s Make sure file "%s" has proper GPG formatú#discovered a BAD GPG signature: %s zFthe "%s" signature file does not actually contain any valid signatures)Ú no_sig_verifyÚbmap_sigrÚErrorr$rrOÚis_urlÚtempfileÚNamedTemporaryFileÚIOErrorÚshutilÚ copyfileobjÚseekr?rGÚ ImportErrorÚContextÚioÚFileIOr+ÚverifyÚ signaturesÚerrorsÚ GPGMEErrorÚ getstringÚ BadSignaturesrÚwarningrW) rÚbmap_objÚ bmap_pathÚsig_objrBÚsig_pathÚtmp_objrGrRÚ signatureÚ signed_datarSs r Úverify_detached_bmap_signaturerwŸsn€ð  ×ÒØà ‡}‚}ð WÜ×)Ñ)¨$¯-©-Ó8ˆGð—=‘=‰ð Ø  6Ñ)ˆHÜ×)Ñ)¨(Ó3ˆGô �‰Ð:¸XÑEÔFð‡~‚~ð TÜ×1Ñ1°%Ó8ˆGô ×ј7 GÔ,Ø� ‰ �QŒØ� ‰ ŒØˆð Ûð DØ—+‘+“-ˆÜ—I‘I˜gŸl™lÓ+ˆ Ü—i‘i § ¡ Ó.ˆ Ø�~‰~˜k¨9°dÓ;¸AÑ>×IÑIˆð ‡M�M„Oä ˆ4ƒy�A‚~Ü � ‰ ð #Ø%-ñ .ô ð ô $ G¨TÔ2à øôA�‰ò WÜ ÐAÀ4Ç=Á=ÐRU× VÒ Vûð Wûô�‰ò ð Ø$ vÑ-�Ü#×-Ñ-¨hÓ7‘øÜ—?‘?ò âð úòð ûôò TÜ ÐMÈs× SÒ Sûð Tûô ò Üð 8÷ ð ûð �:‰:× Ñ ò Üð 8à �M‰M‹OØ ÷  ò ûð �:‰:× #Ñ #òDÜÐ8¸(×CÒCûðDúsœ›F ÁGÂHÃH8ÃA.IÆ GÆ F=Æ=GÇHÇG4Ç3HÇ4H ÈHÈ H È HÈHÈ H5È H0È0H5È8IÉIÉKÉ,J Ê KÊ) J;Ê;KcóR—|jr td« ddl} j «}t j |j«}t j«}|j||d«}|js0t!«dk(rt"j%d«n t'|« t)j*d «}j/j1««|j3d«|S#t$rtd«YŒñwxYw#jj$r'}td|dj««Yd}~ŒÙd}~w|jj$r}tdt«Yd}~�Œ d}~wwxYw#t,$r}td |«Yd}~ŒÛd}~wwxYw) zp This is a helper function for 'verify_bmap_signature()' which handles the clarsign signature case. znthe bmap file has clearsign format and already contains the signature, so --bmap-sig option should not be usedrNz½cannot verify the signature because the python "gpg"module is not installed on your system Cannot extract block map from the bmap file which has clearsign format, please, install the modulez]failure when trying to verify GPG signature: %s make sure the bmap file has proper GPG formatr rZzPthe bmap file clearsign signature does not actually contain any valid signaturesúw+ú+cannot create a temporary file for bmap: %s)r\r$rGrerfrgrhr+ÚBytesIOrirkrlrQrnrsr[rrrorWr_Ú TemporaryFileraÚwriteÚgetvaluerd) rrprGrRruÚ plaintextrSrBrts r Úverify_clearsign_bmap_signaturer€îsp€ð  ‡}‚}Üð Eô ð  Ûð DØ—+‘+“-ˆÜ—I‘I˜hŸm™mÓ,ˆ Ü—J‘J“Lˆ Ø�~‰~˜i¨°DÓ9ˆð × Ò Ü ˆt‹9˜Š>Ü �K‰Kð/õ ô (¨°Ô 6ðGÜ×(Ñ(¨Ó.ˆð ‡M�M�)×$Ñ$Ó&Ô'Ø ‡L�L�„OØ €NøôM ò Üð )ö ð ûð �:‰:× Ñ ò Üð <à �‰F�L‰L‹N÷ ñ ûð �:‰:× #Ñ #òDÜÐ8¼(×CÒCûðDûô òGÜÐ@À#×FÑFûðGúsM™C8žADÂ1FÃ8DÄDÄFÄ+E Å FÅ)E?Å?FÆ F&Æ F!Æ!F&cóž—|syd}|jt|««}|jd«||k(r t||«St |||«S)ak Verify GPG signature of the bmap file if it is present. The signature may be in a separate file (detached) or it may be inside the bmap file itself (clearsign signature). If user specifies the --bmap-sig option, the signature is assumed to be detached and is taken from the user-specified file. Otherwise, this function verifies whether the bmap file has clearsign signature, and if not, it tries to automatically discover the detached signature by searching for a ".sig" or ".asc" file at the same path and with the same basename as the bmap file. This function then verifies the signature and reports the results. In case of the clearsign signature, the bmap file has "invalid" format, meaning that the proper bmap XML contents is in the GPG clearsign container. The XML contents has to be extracted from the container before further processing. And this is be done even if user specified the --no-sig-verify option. This function returns an open file object with the extracted XML bmap file contents in this case. Otherwise, this function returns None. Nz"-----BEGIN PGP SIGNED MESSAGE-----r)Úreadrrdr€rw)rrprqÚclearsign_markerÚbufs r Úverify_bmap_signaturer…%sU€ñ. Øà;ÐØ �-‰-œÐ,Ó-Ó .€CØ ‡M�M�!Ôà ÐÒÜ.¨t°XÓ>Ð>ä-¨d°H¸iÓHÐHr%có*—|jry|jr- tj|j«}|j}nA|j } |dz} tj|«}t jd|z« js||fS tjd«}tj |«|j#«|j%d «|j'«||fS#tj$r!}t d|j|«Yd}~Œîd}~wwxYw#tj$rYnwxYwtjj|«\}}|dk(ry�Œ#t$r}t d|«Yd}~Œßd}~wwxYw) a` This is a helper function for 'open_files()' which discovers and opens the bmap file, then returns the corresponding file object and the bmap file path. If the user specified the bmap file explicitly, we just open the provided path. Otherwise, we try to discover the bmap file at the same place where the image file is located. We search for a file with the same path and basename, but with a ".bmap" extension. Additionally, this function makes sure that the returned file object corresponds to a local file, not a remote file. We do this by creating a temporary local copy of the bmap file. The reason is that further on we may need to check the GPG signature of the file, which requires it to be a local file. On top of that, the BmapCopy class requires the bmap file to be memory-mappable ('mmap()'). ©NNzcannot open bmap file '%s': %sNz.bmapzdiscovered bmap file '%s'ÚrYrzr)ÚnobmapÚbmaprr]r$ÚimagerrOr9r@Úsplitextr^r_r`rarbrcÚflushrdr?)rrprBrqÚ image_pathÚextrts r Úfind_and_open_bmapr�Isp€ð& ‡{‚{Øà ‡y‚yð IÜ ×*Ñ*¨4¯9©9Ó5ˆHð—I‘I‰ ð—Z‘Zˆ ØØ" WÑ,ˆIð Ü$×.Ñ.¨yÓ9�Ü—‘Ð4°yÑ@ÔAØð �?Š?ؘ)Ð$Ð$ðGä×-Ñ-¨eÓ4ˆô ×Ñ�x Ô)à ‡M�M„OØ ‡L�L�„OØ ‡N�NÔØ �YÐ ÐøôC�‰ò IÜ Ð7¸¿¹ÀC× HÑ Hûð Iûô—?‘?ò Ùð úô!Ÿg™g×.Ñ.¨zÓ:‰OˆJ˜Ø�bŠyØ#ñøô& òGÜÐ@À#×FÑFûðGúsA›C9Á-D0ÂE3Ã9D-Ä D(Ä(D-Ä0EÅEÅ3 FÅ< F Æ Fcó*— tj|j«}t |«\}}||jk(r|j «td«t jj|j«jd«r¸t jj|j«s1tjd|j›d|j›d�«n^tjt j|j«j «r"tjd|jz«d} t#j$|j«j'«rd }t)|j«}nt+|jd «}|||j.|fS#tj$r}td|z«Yd}~�Œ¿d}~wwxYw#t,$r!}td |j|«Yd}~Œfd}~wwxYw) až This is a helper function for 'copy_command()' which the image, bmap, and the destination files. Returns a tuple of 5 elements: 1 file-like object for the image 2 file object for the destination file 3 file-like object for the bmap 4 full path to the bmap file 5 image size in bytes 6 'True' if the destination file is a block device, otherwise 'False' zcannot open image: %sNzaMake sure you are writing your image and not the bmap file (you specified the same path for them)z/dev/Ú"z+" does not exist, creating a regular file "zA"%s" is under "/dev", but it is a regular file, not a device nodeFTrYz%cannot open destination file '%s': %s)rr‹r]r$r�r?r9r@ÚnormpathÚdestrÚexistsrroÚstatÚS_ISREGÚst_modeÚpathlibÚPathÚis_block_devicerCr:raÚsize)rÚ image_objrBrprqÚdest_is_blkdevÚdest_objs r Ú open_filesr †s–€ð2Ü×'Ñ'¨¯ © Ó3ˆ ô /¨tÓ4Ñ€Xˆyà�D—J‘JÒð �‰ÔÜð 5ô ô ‡w�w×јŸ ™ Ó"×-Ñ-¨gÔ6Ü�w‰w�~‰~˜dŸi™iÔ(Ü �KŠKàŸ)›) T§Y£Yð0õ ô�\‰\œ"Ÿ'™' $§)¡)Ó,×4Ñ4Ô 5Ü �K‰Kð$Ø&*§i¡iñ0ô ð€NðLÜ �<‰<˜Ÿ ™ Ó "× 2Ñ 2Ô 4Ø!ˆNÜ(¨¯©Ó3‰Hä˜DŸI™I uÓ-ˆHð �x ¨9°i·n±nÀnÐ UÐUøôa �?‰?ò2ÜÐ*¨SÑ0×1Ò1ûð2ûôZ òLÜÐ:¸D¿I¹IÀs×KÑKûðLús0‚F9Å AG(Æ9G%Ç G Ç G%Ç( HÇ1H È Hc óî—|jr|jr td«|jr|jr td«t |«\}}}}}}|jr |s td«t |||«}|r|j«|}|r t||«} |r(d|jz}tj||||«} nDdtjj|j«z}tj||||«} |j sh|j"s\t$j&j)«r>t$j*j)«r  j-t$j&d«t/j.«} |s;|jr#t0j3d|jz«nëtd «nßt0j3d  j4z«t0j3d | j6| j8| j:| j<| j>| j@fz«t0j3d tjj|jB«›d ›dtjj|«›d�«|jDr jG|jD«  jId|jJ «t0j3d|jz«  jO«t/j.«| z }  jR| z} t0j3dtUjV| «›dtUjX| «›d�«|j«|r|j«|j«y#tj$r} t| «Yd} ~ �ŒÜd} ~ wwxYw#tjtLjf$r} t| «Yd} ~ �Œ.d} ~ wwxYw#tj$r} t| «Yd} ~ �Œ'd} ~ wwxYw#tP$rtd«Y�ŒFwxYw)z=Copy an image to a block device or a regular file using bmap.z+--nobmap and --bmap cannot be used togetherz6--bmap-sig and --no-sig-verify cannot be used togetherzBthe bmap signature file was specified, but bmap file was not foundzblock device '%s'z file '%s'Nzbmaptool: info: %d%% copiedz(no bmap given, copy entire image to '%s'zFbmap file not found, please, use --nobmap option to flash without bmapzblock map format version %sz:%d blocks of size %d (%s), mapped %d blocks (%s or %.1f%%)zcopying image 'z' to z using bmap file 'Ú'Fzsynchronizing '%s'zinterrupted, exitingzcopying time: z, copying speed z/sec)-r‰rŠr$r\r[r r…r?r'r”rÚ BmapBdevCopyr9r@Úbasenamer]ÚquietÚdebugr ÚstderrÚisattyÚstdoutÚset_progress_indicatorÚtimerrOÚ bmap_versionÚ blocks_cntÚ block_sizeÚimage_size_humanÚ mapped_cntÚmapped_size_humanÚmapped_percentr‹Ú psplash_pipeÚset_psplash_pipeÚcopyÚ no_verifyrÚsyncÚKeyboardInterruptÚ mapped_sizerÚ human_timeÚ human_size)rr�rŸrprqÚ image_sizeržÚf_objÚdest_strÚwriterrBÚ start_timeÚ copying_timeÚ copying_speeds r Ú copy_commandrÃÉsi€ð ‡{‚{�t—y’yÜÐ?Ô@à ‡}‚}˜×+Ò+ÜÐJÔKäKUØ óLÑH€Iˆx˜ 9¨j¸.ð ‡}‚}™XÜØ Sô ô " $¨°)Ó <€EÙ Ø�‰Ô؈áܘX yÓ1ˆð Ù Ø*¨T¯Y©YÑ6ˆHä×*Ñ*¨9°hÀÈ*ÓU‰Fà"¤R§W¡W×%5Ñ%5°d·i±iÓ%@Ñ@ˆHÜ×&Ñ& y°(¸HÀjÓQˆFð �JŠJØ— ’ Ü �J‰J× Ñ Ô Ü �J‰J× Ñ Ô à×%Ñ%¤c§j¡jÐ2OÔPä—‘“€JÙ Ø �;Š;Ü �H‰HÐ?À$Ç)Á)ÑKÕ Lä ð%õ ô �‰Ð.°×1DÑ1DÑDÔEÜ �‰Ø Hà×!Ñ!Ø×!Ñ!Ø×'Ñ'Ø×!Ñ!Ø×(Ñ(Ø×%Ñ%ð ñ ô ô �Šä�w‰w×Ñ § ¡ Õ+ªX´r·w±w×7GÑ7GÈ Õ7Rð Tô ð  ×ÒØ×Ñ × 1Ñ 1Ô2ð *ð Ø �K‰K˜ 4§>¡>Ð1Ô 2ô �‰Ð%¨¯ © Ñ1Ô2ð Ø �K‰KŒMô —9‘9“; Ñ+€LØ×&Ñ&¨,Ñ6€M܇H‚Hä × !Ñ ! ,Õ /´×1GÑ1GÈ Õ1Vð Xôð  ‡N�NÔÙØ�‰ÔØ ‡O�OÕøôG �>‰>òÜ�#�ŠûðûôZ—‘¤ §¡Ð0ò Ü �c�NŠNûð ûô�~‰~ò Ü �c�NŠNûð ûä ò*ÜÐ(×)ð*ússÂ"A.OËO4Ë:"QÌP0ÏO1Ï O,Ï,O1Ï4#P-Ð P(Ð"QÐ(P-Ð-QÐ0QÑ QÑQÑQÑQÑQ4Ñ3Q4có@—|jr t|jd«}n t j d«} t j |jd«}|j|j «|js>jd«tjj|j««j |j"k(rFt$j'd|j(›d|j›d �«t$j'd «yy#t$r"}td|j|«Yd}~�Œd}~wwxYw#t$r}td|«Yd}~�Œ1d}~wwxYw#t j$r}t|«Yd}~�Œd}~wwxYw) a— Generate block map (AKA bmap) for an image. The idea is that while images files may generally be very large (e.g., 4GiB), they may nevertheless contain only little real data, e.g., 512MiB. This data are files, directories, file-system meta-data, partition table, etc. When copying the image to the target device, you do not have to copy all the 4GiB of data, you can copy only 512MiB of it, which is 4 times less, so copying should presumably be 4 times faster. The block map file is an XML file which contains a list of blocks which have to be copied to the target device. The other blocks are not used and there is no need to copy them. The XML file also contains some additional information like block size, image size, count of mapped blocks, etc. There are also many commentaries, so it is human-readable. The image has to be a sparse file. Generally, this means that when you generate this image file, you should start with a huge sparse file which contains a single hole spanning the entire file. Then you should partition it, write all the data (probably by means of loop-back mounting the image or parts of it), etc. The end result should be a sparse file where mapped areas represent useful parts of the image and holes represent useless parts of the image, which do not have to be copied when copying the image to the target device. ryz$cannot open the output file '%s': %sNz"cannot create a temporary file: %sÚsha256rzall z are mapped, no holes in 'r¢z:was the image handled incorrectly and holes were expanded?)Úoutputr:rar$r_r|rr‹ÚgenerateÚ no_checksumr]rdr r©r}r‚r°r­rror¯)rrÆrBÚcreators r Úcreate_commandrÊ1sH€ð6 ‡{‚{ð Qܘ$Ÿ+™+ tÓ,‰Fð Bä×+Ñ+¨DÓ1ˆFðÜ×'Ñ'¨¯ © °F¸HÓEˆØ×јT×-Ñ-Ð-Ô.ð �;Š;Ø� ‰ �AŒÜ � ‰ ×јŸ™›Ô'à×јW×/Ñ/Ò/Ü � Š à×'Ó'¨¯«ð 5ô ô � ‰ ÐSÕTð 0øô'ò QÜ Ð=¸t¿{¹{ÈC× PÒ Pûð Qûô ò BÜ Ð;¸S× AÒ Aûð Bûô × Ñ òÜ�#�ŠûðúsEŽD#¦E¼=E4Ä# EÄ,E Å EÅ E1Å E,Å,E1Å4FÆ FÆFcó"—tjtj}t j |d¬«}|j ddddtzz¬«d}|j d d d |¬ «d }|j ddd |¬ «|jdd¬«}d|_ d}|jd|¬«}|jt¬«d}|j d|¬«d}|j dd|¬«d}|j dd |¬ «d}|jd |¬«}|jt¬«d!d"jtj «z}|j d|¬«d#}|j d$|¬«d%}|j d&|¬«d'}|j d(d |¬ «d)}|j d*|¬«d+}|j d,d |¬ «d-}|j d.d |¬ «d/}|j d0|¬«|j#«S)1z3A helper function which parses the input arguments.Úbmaptool)Ú descriptionÚprogz --versionÚversionz %(prog)s z%s)ÚactionrÏzbe quietz-qz--quietÚ store_true)rÐÚhelpzprint debugging informationz-dz--debugÚcommandsÚcommand)Útitler”Tz?generate bmap for an image file (which should be a sparse file)Úcreate)rÒ)Úfunczthe image to generate bmap forr‹z/the output file name (otherwise stdout is used)z-oz--outputz9do not generate the checksum for block ranges in the bmapz --no-checksumz+write an image to a block device using bmaprµz9the image file to copy. Supported formats: uncompressed, z, z8the destination file or device node to copy the image tor”z the block map file for the imagez--bmapz!allow copying without a bmap filez--nobmapz,the detached GPG signature for the bmap filez --bmap-sigz%do not verify bmap file GPG signatruez--no-sig-verifyz-do not verify the data checksum while writingz --no-verifyz write progress to a psplash pipez--psplash-pipe)r Úmodulesr2r5ÚargparseÚArgumentParserÚ add_argumentÚVERSIONÚadd_subparsersÚrequiredÚ add_parserÚ set_defaultsrÊrÃrrÚSUPPORTED_COMPRESSION_TYPESÚ parse_args)ÚtextÚparserÚ subparsersÚ parser_createÚ parser_copys r Úparse_argumentsrèjsY€ä �;‰;”xÑ × (Ñ (€DÜ × $Ñ $°¸JÔ G€Fð ×ÑØ˜I¨{¸TÄG¹^Ñ/Kðôð €DØ ×ј˜i° À4ÐÔHð )€DØ ×ј˜i° À4ÐÔHà×&Ñ&¨Z¸iÐ&ÓH€JØ€JÔð M€DØ×)Ñ)¨(¸Ð)Ó>€MØ×ѤNÐÔ3ð ,€DØ×јw¨TÐÔ2ð =€DØ×јt Z°dÐÔ;ð G€DØ×ј°|È$ÐÔOð 9€DØ×'Ñ'¨°TÐ'Ó:€KØ×Ѥ,ÐÔ/ð GÈÏÉÜ×-Ñ-óJñ €Dð×јW¨4ÐÔ0ð F€DØ×јV¨$ÐÔ/ð .€DØ×јX¨DÐÔ1ð /€DØ×јZ° À4ÐÔHð :€DØ×ј\°ÐÔ5ð 3€DØ×ÑÐ.°|È$ÐÔOð ;€DØ×ј]°<ÀdÐÔKð .€DØ×ÑÐ-°DÐÔ9à × Ñ Ó Ðr%cóV‡‡—d}d}dŠdŠGˆˆfd„dtj«}tjtj|dz‰z«tjtj|dz‰z«tjtj d «tjtj d «tj|«|d d «}tjtj«}|j|«tj|«y )zm A helper function which configures the root logger. The log level is initialized to 'loglevel'. zzzzcó&•—eZdZdZdˆˆfd„ Zd„Zy)ú!setup_logger..MyFormatterzŽ A custom formatter for logging messages. The reason we have it is to have different format for different log levels. Nc󪕗tjj|||«|j|_d‰zdz‰zdz|jz|_y)zThe constructor.Ú[z %(asctime)sz] [%(module)s,%(lineno)d] N)ÚloggingÚ Formatterr.Ú_fmtÚ _orig_fmtÚ_dbg_fmt)r,ÚfmtÚdatefmtÚesc_endÚ esc_greens €€r r.z*setup_logger..MyFormatter.__init__Ðsdø€ä × Ñ × &Ñ & t¨S°'Ô :à!ŸY™YˆDŒNðØñàñ ðñð/ñ /ð —)‘)ñ ð �Mr%cóÄ—|jtjk(r|j|_tj j ||«}|j|_|S)zy The formatter which which simply prefixes all debugging messages with a time-stamp. )ÚlevelnorîÚDEBUGròrðrïÚformatrñ)r,ÚrecordÚresults r rúz(setup_logger..MyFormatter.formatàsG€ð �~‰~¤§¡Ò.Ø ŸM™M�” ä×&Ñ&×-Ñ-¨d°FÓ;ˆFØŸ™ˆDŒI؈Mr%r‡)r2r3r4r5r.rú)rõrös€€r Ú MyFormatterrëÊsø„ñ ö  ó r%rýÚERRORÚWARNINGr¦rOz$bmaptool: %(levelname)s: %(message)sz%H:%M:%SN)rîrïÚ addLevelNamerþrÿrùÚINFOrÚsetLevelÚ StreamHandlerr r§Ú setFormatterÚ addHandler)ÚloglevelÚesc_redÚ esc_yellowrýÚ formatterÚwhererõrös @@r Ú setup_loggerr ¾sÙù€ð€GØ€JØ€IØ€G÷!”g×'Ñ'ô!ôJ ×ÑœŸ™¨°'Ñ(9¸GÑ(CÔDÜ ×ÑœŸ™¨*°yÑ*@À7Ñ*JÔKÜ ×ÑœŸ™¨Ô0Ü ×ÑœŸ™ vÔ.ä‡L�L�ÔÙÐBÀJÓO€IÜ × !Ñ !¤#§*¡*Ó -€EØ ×Ñ�yÔ!܇N�N�5Õr%cóü—t«}|jrtj}n-|jrtj }ntj }t|«|jr|jr td« |j|«y#t$rÜtjd«tj«tjd«t!dd«5}|D]}t#|j%««Œ ddd«n #1swYnxYwtjd«t!dd«5}|D]}t#|j%««Œ ddd«Yy#1swYYyxYwwxYw) zScript entry point.z+--quiet and --debug cannot be used togetherzOut of memory!zThe contents of /proc/meminfo:z /proc/meminfoÚrtNz"The contents of /proc/self/status:z/proc/self/status)rèr¥rîrÿr¦rùrr r$r×Ú MemoryErrorrrr Ú print_excrOr:Úprintr)rrr-rs r Úmainrûs€ä Ó €Dà ‡z‚zÜ—?‘?‰Ø �ŠÜ—=‘=‰ä—<‘<ˆä�Ôà ‡z‚z�d—j’jÜÐ?Ô@ð$Ø � ‰ �$�øÜ ò $Ü � ‰ Ð"Ô#Ü×ÑÔä �‰Ð1Ô2Ü �/ 4Ô (¨HÛ �Ü�d—j‘j“lÕ#ñ!÷)× (Ñ (úô �‰Ð5Ô6Ü Ð% tÔ ,°Û �Ü�d—j‘j“lÕ#ñ!÷-× ,Ó ,úð $úsCÂBÂAE;Ã)!DÄ E;ÄD Ä(E;Å!E-Å#E;Å-E7 Å2E;Å7E;Ú__main__)&r5rÙr r9r–r«rîr_r rbrgr™rˆrrrrrÜÚ getLoggerrr!r$Úobjectr'rCrWrwr€r…r�r rÃrÊrèr rr2Úexitr6r%r ÚrsÊðñ"óÛ Û Û Û ÛÛÛÛ Û Ûß:Ó:à €à€g×ÑÓ€òò<ô-�ô-ò"%ò:ò6Lò^4òn!IòH: òz@VòFeòP6UòrQòh:òz$ðB ˆzÒØ €C‡H�H‰T‹VÕðr%