+
    �zºj½2  ã                   ó  € ^ RI HtHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIHt ^ RIHt  ! R R]4      t ! R R]4      t ! R	 R
]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      tR# )é    )Úprint_functionÚunicode_literalsN)Úfind_executable)Úgettextc                   ó   € ] tR t^#tRtR# )ÚAptBtrfsSnapshotError© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r	   ó    Ú@/usr/lib/python3/dist-packages/DistUpgrade/apt_btrfs_snapshot.pyr   r   #   ó   † Ûr   r   c                   ó   € ] tR t^'tRtR# )ÚAptBtrfsNotSupportedErrorr	   Nr
   r	   r   r   r   r   '   r   r   r   c                   ó   € ] tR t^+tRtR# )ÚAptBtrfsRootWithNoatimeErrorr	   Nr
   r	   r   r   r   r   +   r   r   r   c                   óD   a € ] tR t^/t o Rt]R 4       tRR ltR tRt	V t
R# )Ú
FstabEntryza single fstab entry line c                ón   € VP                  R 4      ^ ,          P                  4       p\        VR,          !  # )Ú#:r   é   N)Ú	partitionÚsplitr   )ÚclsÚlineÚargss   && r   Ú	from_lineÚFstabEntry.from_line1   s1   € ð �~‰~˜cÓ" 1Õ%×+Ñ+Ó-ˆô ˜4 �9Ñ%Ð%r   c                óN   € Wn         W n        W0n        W@n        WPn        W`n        R # ©N©Úfs_specÚ
mountpointÚfstypeÚoptionsÚdumpÚpassno)Úselfr&   r'   r(   r)   r*   r+   s   &&&&&&&r   Ú__init__ÚFstabEntry.__init__9   s    € àŒØ$ŒØŒØŒØŒ	ØŽr   c                ó°   € R V P                   : RV P                  : RV P                  : RV P                  : RV P                  : RV P
                  : R2# )z<FstabEntry 'z' 'z'>r%   ©r,   s   &r   Ú__repr__ÚFstabEntry.__repr__B   s2   � à�LŒL˜$Ÿ/œ/¨4¯;¬;Ø�LŒL˜$Ÿ)œ) T§[¤[ð2ð 	2r   )r*   r&   r(   r'   r)   r+   N)r   r   )r   r   r   r   Ú__doc__Úclassmethodr!   r-   r1   r   Ú__classdictcell__©Ú__classdict__s   @r   r   r   /   s)   ø‡ € Ù%Øñ&ó ð&ô÷2ð 2r   r   c                   ó:   a a€ ] tR t^Ht oRtRV 3R lltRtVtV ;t# )ÚFstabza list of FstabEntry items c                ó^  <€ \         \        V `  4        \        V4      ;_uu_ 4       pR  V 4        FJ  pVR8X  g   VP	                  R4      '       d   K#   \
        P                  V4      pT P                  T4       KL  	  RRR4       R#   \         d     Kf  i ; i  + '       g   i     R# ; i)c              3   ó@   "  € T F  qP                  4       x € K  	  R # 5ir$   )Ústrip)Ú.0r   s   & r   Ú	<genexpr>Ú!Fstab.__init__.<locals>.<genexpr>N   s   é € Ð!F¹:°4§*¡*§, ,»:ùs   ‚Ú r   N)	Úsuperr9   r-   ÚopenÚ
startswithr   r!   Ú
ValueErrorÚappend)r,   ÚfstabÚ
fstab_fileÚstripped_lineÚentryÚ	__class__s   &&   €r   r-   ÚFstab.__init__J   sŽ   ø€ ÜŒe�TÑ#Ô%ä�%�[Œ[˜JÙ!F¹:Ö!F�Ø  BÔ&¨-×*BÑ*BÀ3×*GÒ*GÙðÜ&×0Ñ0°Ó?�Eð —‘˜EÖ"ñ "G÷ ‰[øô "ô Úðú÷ �[ˆ[ús5   §*BÁBÁB	Á*BÂ	B	ÂBÂB	ÂBÂB,	r	   ©z
/etc/fstab)	r   r   r   r   r3   r-   r   r5   Ú__classcell__)rJ   r7   s   @@r   r9   r9   H   s   ù‡ € Ù&÷#÷ #r   r9   c                   ó<   a € ] tR t^Xt o RtR tR tR tR tRt	V t
R# )ÚLowLevelCommandsz\lowlevel commands invoked to perform various tasks like
interact with mount and btrfs tools
c                ó<   € \         P                  ! R W.4      pV^ 8H  # )Úmount©Ú
subprocessÚcall)r,   r&   r'   Úrets   &&& r   rQ   ÚLowLevelCommands.mount\   s   € Ü�oŠo˜w¨Ð<Ó=ˆØ�a‰xˆr   c                ó<   € \         P                  ! R V.4      pV^ 8H  # )ÚumountrR   )r,   r'   rU   s   && r   rX   ÚLowLevelCommands.umount`   s   € Ü�oŠo˜x¨Ð4Ó5ˆØ�a‰xˆr   c                ó@   € \         P                  ! R RRW.4      pV^ 8H  # )ÚbtrfsÚ	subvolumeÚsnapshotrR   )r,   ÚsourceÚdestrU   s   &&& r   Úbtrfs_subvolume_snapshotÚ)LowLevelCommands.btrfs_subvolume_snapshotd   s'   € Ü�oŠo˜w¨°ZØ%ð-ó .ˆà�a‰xˆr   c                ó@   € \         P                  ! R RRV.4      pV^ 8H  # )r[   r\   ÚdeleterR   )r,   r]   rU   s   && r   Úbtrfs_delete_snapshotÚ&LowLevelCommands.btrfs_delete_snapshoti   s"   € Ü�oŠo˜w¨°X¸xÐHÓIˆØ�a‰xˆr   r	   N)r   r   r   r   r3   rQ   rX   r`   rd   r   r5   r6   s   @r   rO   rO   X   s#   ø‡ € ñòòò÷
ð r   rO   c                   ó¼   a € ] tR t^nt o RtRt]R,           tRtRR ltR t	R t
RR ltR	 tR
 tR tRR ltRR ltR tR tR tRR ltR tR tRR ltR tRtV tR# )ÚAptBtrfsSnapshotz>the high level object that interacts with the snapshot system z@apt-snapshot-z	old-root-z/run/apt-btrfs-snapshot/rootc                ó`   € \        V4      V n        \        4       V n        R V n        R V n        R # r$   )r9   rF   rO   ÚcommandsÚ_btrfs_root_mountpointÚmounted)r,   rF   s   &&r   r-   ÚAptBtrfsSnapshot.__init__x   s&   € Ü˜5“\ˆŒ
Ü(Ó*ˆŒØ&*ˆÔ#ØˆŽr   c                óP   € \        R4      '       g   R# V P                  4       pVRJ# )zcverify that the system supports apt btrfs snapshots
by checking if the right fs layout is used etc
r[   FN)r   Ú%_get_supported_btrfs_root_fstab_entry©r,   rI   s   & r   Úsnapshots_supportedÚ$AptBtrfsSnapshot.snapshots_supported~   s+   € ô   ×(Ò(Ùà×:Ñ:Ó<ˆØ˜DÐ Ð r   c                ó¢   € V P                    F>  pVP                  R8X  g   K  VP                  R8X  g   K)  RVP                  9   g   K<  Vu # 	  R# )z3return the supported btrfs root FstabEntry or None Ú/r[   zsubvol=@N)rF   r'   r(   r)   ro   s   & r   rn   Ú6AptBtrfsSnapshot._get_supported_btrfs_root_fstab_entryˆ   s@   € à—Z”ZˆEà×$Ñ$¨Ö+Ø—L‘L GÖ+Ø %§-¡-Ö/Ø’ñ  ñ r   c                ój   € V P                    F"  pVP                  V8X  g   K  VP                  u # 	  R# )z3return the device or UUID for the given mountpoint N)rF   r'   r&   )r,   r'   rF   rI   s   &&& r   Ú_uuid_for_mountpointÚ%AptBtrfsSnapshot._uuid_for_mountpoint’   s-   € à—Z”ZˆEØ×Ñ :Ö-Ø—}‘}Ò$ñ  ñ r   c                óÖ  € V P                   '       d&   V ;P                   ^,          un         V P                  # V P                  R4      p\        P                  ! V P
                  RR7       \        P                  P                  V P
                  4      '       g.   V P                  P                  WP
                  4      '       g   R# ^V n         V P
                  V n        V P                  # )z-mount the mount point and return it (or None)rs   T)Úexist_okN)
rk   rj   rv   ÚosÚmakedirsÚ
MOUNTPOINTÚpathÚismountri   rQ   )r,   Úuuids   & r   Ú	__enter__ÚAptBtrfsSnapshot.__enter__™   s™   € à�<�<ˆ<Ø�LŠL˜AÕ�LØ×.Ñ.Ð.Ø×(Ñ(¨Ó-ˆÜ
�Š�D—O‘O¨dÕ3Ü�w‰w�‰˜tŸ™×/Ò/Ø—=‘=×&Ñ& t¯_©_×=Ò=ÙØˆŒØ&*§o¡oˆÔ#Ø×*Ñ*Ð*r   c                ó   € V P                   '       g   R # V ;P                   ^,          un         V P                   '       d   R # V P                  P                  V P                  4       \        P
                  ! V P                  4       R V n        R # r$   )rk   ri   rX   rj   rz   Úrmdir)r,   r    s   &*r   Ú__exit__ÚAptBtrfsSnapshot.__exit__§   sZ   € Ø�|�|ˆ|ÙØ�Š˜Õ�Ø�<�<ˆ<ÙØ�‰×Ñ˜T×8Ñ8Ô9Ü
�Š�×,Ñ,Ô-Ø&*ˆÖ#r   c                óŽ   € \         P                   P                  4       P                  ^ R7      P                  \	        R4      4      # )r   )ÚmicrosecondÚ_)ÚdatetimeÚnowÚreplaceÚ	isoformatÚstrr0   s   &r   Ú_get_now_strÚAptBtrfsSnapshot._get_now_str±   s9   € Ü× Ñ ×$Ñ$Ó&×.Ñ.¸1Ð.Ó=×GÑGÜ�‹Hóð 	r   c                ó˜  € T ;_uu_ 4       pV P                  4       p\        P                  P                  VR 4      p\        P                  P                  W0P                  V,           V,           4      p\        P                  P                  V4      '       d(   \        \        R4      V3,          4        RRR4       R# V P                  P                  WV4      pV'       dK   \        P                  P                  R4      '       d   \        \        R4      4       MV P                  4        VuuRRR4       #   + '       g   i     R# ; i)Ú@zDINFO: snapshot directory '%s' already exists, not creating duplicateNTzAPT::Snapshots::MaxAgezoINFO: Not pruning automatically as APT::Snapshots::MaxAge is set, consider using APT::Snapshots::Retain instead)rŽ   rz   r}   ÚjoinÚSNAP_PREFIXÚexistsÚprintrˆ   ri   r`   Úapt_pkgÚconfigÚfind_iÚ$clean_btrfs_root_snapshots_by_policy)r,   Úadditional_prefixÚpruneÚmpÚsnap_idr^   ÚtargetÚress   &&&     r   Úcreate_btrfs_root_snapshotÚ+AptBtrfsSnapshot.create_btrfs_root_snapshotµ   só   € ß‰T�RØ×'Ñ'Ó)ˆGÜ—W‘W—\‘\ " cÓ*ˆFÜ—W‘W—\‘\ "×&6Ñ&6Ð9JÕ&JØ")õ'*ó +ˆFô �w‰w�~‰~˜f×%Ò%Ü”að 1ó 2Ø5;°Iõ>ô ?à÷ ‰Tð —m‘m×<Ñ<¸VÓL�ßÜ—~‘~×,Ñ,Ð-E×FÒFÜœað !Gó Hõ Ið ×AÑAÔCà÷) �T�T‹Tús   ‹B*D8Â?AD8Ä&D8Ä8E		c                óF  € . pV^ 8w  d>   V P                  4       pV'       g   \        4       hRVP                  9   d   \        4       hV^ 8X  d   \        P                  ! 4       pT ;_uu_ 4       p\
        P                  ! V4       F}  pVP                  V P                  4      '       g   K&  \
        P                  P                  \
        P                  P                  WERR4      4      pWa8  g   Kl  VP                  V4       K  	  RRR4       V#   + '       g   i     T# ; i)z”get the list of available snapshot
If "older_then" is given (in unixtime format) it will only include
snapshots that are older then the given date)
ÚnoatimeÚetcrF   N)rn   r   r)   r   Útimerz   ÚlistdirrC   r“   r}   Úgetatimer’   rE   )r,   Ú
older_thanÚresultrI   rœ   ÚeÚatimes   &&     r   Úget_btrfs_root_snapshots_listÚ.AptBtrfsSnapshot.get_btrfs_root_snapshots_listÌ   sÜ   € ð
 ˆð ˜Œ?Ø×>Ñ>Ó@ˆEßÜ/Ó1Ð1Ø˜EŸM™MÔ)Ü2Ó4Ð4à˜Œ?ÜŸš›ˆJß‰T�RÜ—Z’Z –^�Ø—<‘< × 0Ñ 0×1Ô1ô ŸG™G×,Ñ,¬R¯W©W¯\©\¸"Ø:?Àó.Jó K�EàÖ)ØŸ™ aÖ(ñ $÷ ð ˆ÷ ŽTð ˆús   Á-8DÂ*ADÃ0DÄD 	c                ól   € \        R 4       \        RP                  V P                  4       4      4       R# )zAvailable snapshots:ú  
T)r•   r’   r¬   r0   s   &r   Úprint_btrfs_root_snapshotsÚ+AptBtrfsSnapshot.print_btrfs_root_snapshotsè   s(   € ÜÐ$Ô%Üˆf�k‰k˜$×<Ñ<Ó>Ó?Ô@Ùr   c                óÆ   € \         P                   ! 4       pVP                  R 4      '       g   \        R4      h\        VRR 4      pW#^,          ^<,          ^<,          ,
          # )Údz&Please specify time in days (e.g. 10d)Néÿÿÿÿ)r¥   ÚendswithÚ	ExceptionÚint)r,   ÚtimefmtrŠ   Údayss   &&  r   Ú_parse_older_than_to_unixtimeÚ.AptBtrfsSnapshot._parse_older_than_to_unixtimeí   sP   € Ü�iŠi‹kˆØ×Ñ ×$Ò$ÜÐDÓEÐEÜ�7˜3˜B�<Ó ˆØ˜R•i "•n rÕ)Õ*Ð*r   c                ó  € V P                  V4      p \        R V,          4       \        RP                  V P                  VR7      4      4       R#   \         d$    \
        P                  P                  R4        R# i ; i)z$Available snapshots older than '%s':r¯   ©r¨   ú6Error: fstab option 'noatime' incompatible with optionFT)rº   r•   r’   r¬   r   ÚsysÚstderrÚwrite)r,   r¸   Úolder_than_unixtimes   && r   Ú%print_btrfs_root_snapshots_older_thanÚ6AptBtrfsSnapshot.print_btrfs_root_snapshots_older_thanô   s   € Ø"×@Ñ@ÀÓIÐð	ÜÐ8¸7ÕBÔCÜ�&—+‘+˜d×@Ñ@Ø.ð Aó 0ó 1ô 2ñ øô	 ,ô 	Ü�J‰J×Ñð +ô ,âð	ús   “<A Á*A?Á>A?c                óx  a€ R RRRRRRRRRRRRR/p. pV P                  4        F6  p \        P                  P                  VR4      pTP	                  YE34       K8  	  VP                  R R	R
7       \        P                  ! \        4      pVP                  4        FŠ  w  pw  op\        P                  P                  RV 2V4      p\        P                  ! VV3R l4      p	\        V	4       F4  w  p
w  r¼W¨8¼  d    Kc   \!        V4      pWm,          P	                  V4       K6  	  KŒ  	  R	pV Fc  w  rW3V9   d3   V'       d)   \%        RRVRRP'                  WgV3,          4      4       K=  K?  \%        RRV4       WàP)                  V4      ,          pKe  	  V#   \         d     EK‚  i ; i  \"         d     KÊ  i ; i)ÚlatestÚminutelyÚhourlyÚdailyÚweeklyÚmonthlyÚyearlyz@apt-snapshot-%Y-%m-%d_%H:%M:%Sc                 ó   € V ^,          # ©é   r	   )Úks   &r   Ú<lambda>ÚGAptBtrfsSnapshot.clean_btrfs_root_snapshots_by_policy.<locals>.<lambda>  s   €   1¦r   T)ÚkeyÚreversezAPT::Snapshot::Retain::c                 ó4   <€ V ^,          P                  S4      # rÎ   )Ústrftime)rÐ   Úfmts   &€r   rÑ   rÒ     s   ø€ ¸!¸A½$¿-¹-ÈÔ:Lr   ÚKeepingr]   zdue toz, ÚDeletingzexpired snapshot)z%Y-%m-%d %H:%M:%Sr   )z%Y-%m-%d %Hé   )z%Y-%m-%dé   )z	%Y-week%Vé   )z%Y-%mr   )z%Yr   )r¬   r‰   Ústrptimer¶   rE   ÚsortÚcollectionsÚdefaultdictÚlistÚitemsr–   r—   r˜   Ú	itertoolsÚgroupbyÚ	enumerateÚnextÚStopIterationr•   r’   Údelete_snapshot)r,   ÚverboseÚkeepÚsnapsÚsnapÚdtÚto_keepÚnameÚcountÚgroup_by_periodÚindexÚ_grouprâ   ÚirŸ   Ú_dtr×   s   &&              @r   r™   Ú5AptBtrfsSnapshot.clean_btrfs_root_snapshots_by_policy   sÌ  ø€ àÐ2ØÐ4ØÐ,Ø˜ØÐ*Ø˜<Ø˜)ð
ˆð ˆØ×6Ñ6Ö8ˆDðÜ×&Ñ&×/Ñ/°ð1DóE�ð
 �L‰L˜$˜Ö$ñ 9ð 	�
‰
‘~¨tˆ
Ô4Ü×)Ò)¬$Ó/ˆØ"&§*¡*¦,ÑˆD‘,�3˜Ü—N‘N×)Ñ)Ð,CÀDÀ6Ð*JØ*/ó1ˆEô (×/Ò/°Ü0LóNˆOô +4°OÖ*DÑ&�‘˜Ø”>ÚðÜ˜U›�AØ•J×%Ñ% dÖ+ó +Eñ #/ð( ˆÛ‰IˆDØˆ{˜gÔ%ßÜ˜) Z°Ø" D§I¡I¨g¸S°kÕ.BÓ$CöEñ ô �jÐ"4°dÔ;Ø×+Ñ+¨DÓ1Õ1’ñ ð ˆ
øôI ô Ûðûô. %ô Úðús#   ¨ FÄ "F*ÆF'Æ&F'Æ*F9Æ8F9c                óð   € R pV P                  V4      p V P                  VR7       F  pW P                  V4      ,          pK  	  V#   \         d$    \        P
                  P                  R4        R# i ; i)Tr½   r¾   F)rº   r¬   rè   r   r¿   rÀ   rÁ   )r,   r¸   rŸ   rÂ   rì   s   &&   r   Ú%clean_btrfs_root_snapshots_older_thanÚ6AptBtrfsSnapshot.clean_btrfs_root_snapshots_older_than7  s   € ØˆØ"×@Ñ@ÀÓIÐð	Ø×:Ñ:Ø2ð ;ö 4�à×+Ñ+¨DÓ1Õ1’ñ4ð ˆ
øô	 ,ô 	Ü�J‰J×Ñð &ô 'âð	ús   •0A Á*A5Á4A5c                ó(   € V P                  V4      pV# r$   )Úset_default)r,   Úsnapshot_namerŸ   s   && r   Úcommand_set_defaultÚ$AptBtrfsSnapshot.command_set_defaultD  s   € Ø×Ñ˜}Ó-ˆØˆ
r   c                óh  € T ;_uu_ 4       p\         P                  P                  W14      p\         P                  P                  V4      '       d¼   VP	                  R4      '       d¥   VR8w  dž   \         P                  P                  VR4      p\         P                  P                  W0P
                  V P                  4       ,           4      p\         P                  ! WR4       \         P                  ! WE4       \        RV,          4       M\        R4       RRR4       R#   + '       g   i     R# ; i)zset new default r‘   z@Default changed to %s, please reboot for changes to take effect.z_You have selected an invalid snapshot. Please make sure that it exists, and that it is not "@".NT)	rz   r}   r’   ÚisdirrC   ÚBACKUP_PREFIXrŽ   Úrenamer•   )r,   rü   Úbackuprœ   Únew_rootÚdefault_roots   &&&   r   rû   ÚAptBtrfsSnapshot.set_defaultH  sÛ   € ç‰T�RÜ—w‘w—|‘| BÓ6ˆHä—G‘G—M‘M (×+Ò+Ø!×,Ñ,¨S×1Ò1Ø! SÔ(Ü!Ÿw™wŸ|™|¨B°Ó4�ÜŸ™Ÿ™ b×*<Ñ*<Ø(,×(9Ñ(9Ó(;õ+<ó =�ä—	’	˜,Ô/Ü—	’	˜(Ô1Üð 0Ø2?õ@õ Aô ð 2ô 3÷ ñ" ÷# ŽTñ" ús   ‹AD Á'B/D Ä D1	c                óÄ   € V ;_uu_ 4       pV P                   P                  \        P                  P	                  W!4      4      pR R R 4       V#   + '       g   i     X# ; ir$   )ri   rd   rz   r}   r’   )r,   rü   rœ   rŸ   s   &&  r   rè   Ú AptBtrfsSnapshot.delete_snapshot]  sH   € ß‰T�RØ—-‘-×5Ñ5Ü—‘—‘˜RÓ/ó1ˆC÷ ð ˆ
÷ ŽTð ˆ
ús   ‹9AÁA	)rj   ri   rF   rk   NrL   )r@   F)r   )F)T)r   r   r   r   r3   r“   r  r|   r-   rp   rn   rv   r€   r„   rŽ   r    r¬   r°   rº   rÃ   r™   rø   rý   rû   rè   r   r5   r6   s   @r   rg   rg   n   sy   ø‡ € ÙIð #€Kà +Õ-€Mà/€Jôò!òôò+ò+òôô.ò8ò
+ò
ô5ònòô÷*ð r   rg   )Ú
__future__r   r   r–   rß   r‰   rã   rz   rS   r¿   r¥   Údistutils.spawnr   r   rˆ   r¶   r   r   r   Úobjectr   rá   r9   rO   rg   r	   r   r   Ú<module>r     s€   ð÷& 8ã Û Û Û Û 	Û Û 
Û å +å  ô	˜Iô 	ô	Ð 5ô 	ô	Ð#8ô 	ô2�ô 2ô2#ˆDô #ô �vô ô,s�vö sr   