Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit94df234

Browse files
committed
Ignore syntax errors before concatenating source files
1 parent11c3b90 commit94df234

File tree

12 files changed

+123
-62
lines changed

12 files changed

+123
-62
lines changed

‎src/ashpk_core.py‎

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@
1212
fromastimportliteral_eval
1313
fromconfigparserimportConfigParser,NoOptionError,NoSectionError
1414
fromfilecmpimportcmp
15+
fromglobimportglob
1516
fromreimportsub
1617
fromshutilimportcopy,rmtree
1718
fromtempfileimportTemporaryDirectory
1819
fromurllib.errorimportURLError,HTTPError
1920
fromurllib.requestimporturlopen
21+
try:
22+
fromsrc.distros._emptyimport*
23+
exceptImportError:
24+
pass# ignore
2025

2126
# Directories
2227
# All snapshots share one /var
@@ -60,25 +65,25 @@ def ash_mounts(i, CHR=""):
6065
os.system(f"mount --bind --make-slave /etc /.snapshots/rootfs/snapshot-{CHR}{i}/etc{DEBUG}")
6166
os.system(f"mount --bind --make-slave /home /.snapshots/rootfs/snapshot-{CHR}{i}/home{DEBUG}")
6267
os.system(f"mount --types proc /proc /.snapshots/rootfs/snapshot-{CHR}{i}/proc{DEBUG}")
63-
#os.system(f"mount --rbind --make-rslave /proc /.snapshots/rootfs/snapshot-{CHR}{i}/proc{DEBUG}") ### REVIEW2023 USE THIS INSTEAD?
64-
#os.system(f"mount --bind --make-slave /root /.snapshots/rootfs/snapshot-{CHR}{i}/root{DEBUG}") ### REVIEW2023 ADD THIS TOO?
68+
#os.system(f"mount --rbind --make-rslave /proc /.snapshots/rootfs/snapshot-{CHR}{i}/proc{DEBUG}") # REVIEWuse this instead?
69+
#os.system(f"mount --bind --make-slave /root /.snapshots/rootfs/snapshot-{CHR}{i}/root{DEBUG}") # REVIEWadd this too?
6570
os.system(f"mount --bind --make-slave /run /.snapshots/rootfs/snapshot-{CHR}{i}/run{DEBUG}")
66-
#os.system(f"mount --rbind --make-rslave /run /.snapshots/rootfs/snapshot-chr{i}/run{DEBUG}") ### REVIEW2023 USE THIS INSTEAD?
71+
#os.system(f"mount --rbind --make-rslave /run /.snapshots/rootfs/snapshot-chr{i}/run{DEBUG}") # REVIEWuse this instead?
6772
os.system(f"mount --rbind --make-rslave /sys /.snapshots/rootfs/snapshot-{CHR}{i}/sys{DEBUG}")
6873
os.system(f"mount --bind --make-slave /tmp /.snapshots/rootfs/snapshot-{CHR}{i}/tmp{DEBUG}")
69-
#os.system(f"mount --rbind --make-rslave /tmp /.snapshots/rootfs/snapshot-{CHR}{i}/tmp{DEBUG}") ### REVIEW2023 USE THIS INSTEAD?
74+
#os.system(f"mount --rbind --make-rslave /tmp /.snapshots/rootfs/snapshot-{CHR}{i}/tmp{DEBUG}") # REVIEWuse this instead?
7075
os.system(f"mount --bind --make-slave /var /.snapshots/rootfs/snapshot-{CHR}{i}/var{DEBUG}")
7176
ifis_efi():
7277
os.system(f"mount --rbind --make-rslave /sys/firmware/efi/efivars /.snapshots/rootfs/snapshot-{CHR}{i}/sys/firmware/efi/efivars{DEBUG}")
73-
os.system(f"cp --dereference /etc/resolv.conf /.snapshots/rootfs/snapshot-{CHR}{i}/etc/{DEBUG}")### REVIEWMaybe not needed?
78+
os.system(f"cp --dereference /etc/resolv.conf /.snapshots/rootfs/snapshot-{CHR}{i}/etc/{DEBUG}")# REVIEWmaybe not needed?
7479

75-
### Lock ash(no longer needed) REVIEW 2023
76-
###def ash_lock():
77-
### os.system("touch /.snapshots/ash/lock-disable")
80+
# Lock ash# REVIEWno longer needed
81+
#def ash_lock():
82+
# os.system("touch /.snapshots/ash/lock-disable")
7883

79-
### Unlock ash(no longer needed) REVIEW 2023
80-
###def ash_unlock():
81-
### os.system("rm -rf /.snapshots/ash/lock")
84+
# Unlock ash# REVIEWno longer needed
85+
#def ash_unlock():
86+
# os.system("rm -rf /.snapshots/ash/lock")
8287

8388
# Update ash itself
8489
defash_update(dbg):
@@ -358,7 +363,6 @@ def deploy(snap, secondary=False):
358363
###2023 os.system(f"btrfs sub create /.snapshots/var/var-{tmp} >/dev/null 2>&1") # REVIEW pretty sure not needed
359364
os.system(f"mkdir -p /.snapshots/rootfs/snapshot-{tmp}/boot{DEBUG}")
360365
os.system(f"mkdir -p /.snapshots/rootfs/snapshot-{tmp}/etc{DEBUG}")
361-
###TODEL os.system(f"rm -rf /.snapshots/rootfs/snapshot-{tmp}/var{DEBUG}")
362366
rmrf(f"/.snapshots/rootfs/snapshot-{tmp}/var")
363367
os.system(f"cp -r --reflink=auto /.snapshots/boot/boot-{snap}/. /.snapshots/rootfs/snapshot-{tmp}/boot{DEBUG}")
364368
os.system(f"cp -r --reflink=auto /.snapshots/etc/etc-{snap}/. /.snapshots/rootfs/snapshot-{tmp}/etc{DEBUG}")
@@ -713,9 +717,9 @@ def post_transactions(snap):
713717
# Some operations were moved below to fix hollow functionality ### IMPORTANT REVIEW 2023
714718
# File operations in snapshot-chr
715719
# os.system(f"btrfs sub del /.snapshots/rootfs/snapshot-{snap}{DEBUG}") ### REVIEW # Moved to a few lines below ### GOOD_TO_DELETE_2023
716-
rmrf(f"/.snapshots/boot/boot-chr{snap}","/*")
720+
rmrf_star(f"/.snapshots/boot/boot-chr{snap}")
717721
os.system(f"cp -r --reflink=auto /.snapshots/rootfs/snapshot-chr{snap}/boot/. /.snapshots/boot/boot-chr{snap}{DEBUG}")
718-
rmrf(f"/.snapshots/etc/etc-chr{snap}","/*")
722+
rmrf_star(f"/.snapshots/etc/etc-chr{snap}")
719723
os.system(f"cp -r --reflink=auto /.snapshots/rootfs/snapshot-chr{snap}/etc/. /.snapshots/etc/etc-chr{snap}{DEBUG}")
720724
# Keep package manager's cache after installing packages. This prevents unnecessary downloads for each snapshot when upgrading multiple snapshots
721725
cache_copy(snap,"post_transactions")
@@ -899,19 +903,18 @@ def return_children(tree, id):
899903
children.remove(id)
900904
returnchildren
901905

902-
# Pythonic rm -rf (for both deleting just contents and everything)
903-
defrmrf(a_path,contents=""):
904-
ifcontents=="/*":# just delete a_path/*
905-
forroot,dirs,filesinos.walk(a_path):
906-
forfinfiles:
907-
os.unlink(os.path.join(root,f))
908-
fordindirs:
909-
rmtree(os.path.join(root,d))
910-
else:# delete everything
911-
ifos.path.isfile(a_path):
912-
os.unlink(a_path)
913-
elifos.path.isdir(a_path):
914-
rmtree(a_path)
906+
# rm -rf for deleting everything recursively (even top folder)
907+
defrmrf(*item):
908+
forfinitem:
909+
ifos.path.isdir(f):
910+
rmtree(f)
911+
else:
912+
os.unlink(f)
913+
914+
# rm -rf for just deleting contents
915+
defrmrf_star(a_path):
916+
files=glob(f"{a_path}/*")
917+
rmrf(*files)
915918

916919
# Rollback last booted deployment
917920
defrollback():
@@ -1171,24 +1174,24 @@ def tree_sync(tree, tname, force_offline, live):
11711174
tree_sync_helper("chr",snap_from,snap_to)# Pre-sync
11721175
ifliveandsnap_to==get_current_snapshot():# Live sync
11731176
tree_sync_helper("",snap_from,get_tmp())# Post-sync
1174-
post_transactions(snap_to)### IMPORTANTREVIEW2023 - Moved here from the line immediately after first tree_sync_helper
1177+
post_transactions(snap_to)#REVIEWimportant - Moved here from the line immediately after first tree_sync_helper
11751178
print(f"Tree{tname} synced.")
11761179

1177-
# Sync tree helper function ### REVIEW might need to put it in distribution-specific ashpk.py
1180+
# Sync tree helper function # REVIEW might need to put it in distribution-specific ashpk.py
11781181
deftree_sync_helper(CHR,s_f,s_t):
11791182
os.system("mkdir -p /.snapshots/tmp-db/local/")### REVIEW Still resembling Arch pacman folder structure!
1180-
rmrf("/.snapshots/tmp-db/local","/*")### REVIEW
1183+
rmrf_star("/.snapshots/tmp-db/local")
11811184
pkg_list_from=pkg_list(s_f,"")
11821185
pkg_list_to=pkg_list(s_t,CHR)
11831186
# Get packages to be inherited
11841187
pkg_list_from= [jforjinpkg_list_fromifjnotinpkg_list_to]
11851188
os.system(f"cp -r /.snapshots/rootfs/snapshot-{CHR}{s_t}/usr/share/ash/db/local/. /.snapshots/tmp-db/local/")### REVIEW
11861189
os.system(f"cp -n -r --reflink=auto /.snapshots/rootfs/snapshot-{s_f}/. /.snapshots/rootfs/snapshot-{CHR}{s_t}/{DEBUG}")
1187-
rmrf(f"/.snapshots/rootfs/snapshot-{CHR}{s_t}/usr/share/ash/db/local","/*")### REVIEW
1190+
rmrf_star(f"/.snapshots/rootfs/snapshot-{CHR}{s_t}/usr/share/ash/db/local")
11881191
os.system(f"cp -r /.snapshots/tmp-db/local/. /.snapshots/rootfs/snapshot-{CHR}{s_t}/usr/share/ash/db/local/")### REVIEW
11891192
forentryinpkg_list_from:
11901193
os.system(f"bash -c 'cp -r /.snapshots/rootfs/snapshot-{s_f}/usr/share/ash/db/local/{entry}-[0-9]* /.snapshots/rootfs/snapshot-{CHR}{s_t}/usr/share/ash/db/local/'")### REVIEW
1191-
rmrf("/.snapshots/tmp-db/local","/*")
1194+
rmrf_star("/.snapshots/tmp-db/local")
11921195

11931196
# Recursively run an update in tree
11941197
deftree_upgrade(tree,tname):

‎src/distros/_empty.py‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Just to prevent syntax errors before merging core and distro ashpk files
2+
3+
defauto_upgrade(a):
4+
return0
5+
6+
defcache_copy(a,b):
7+
return0
8+
9+
deffix_package_db():
10+
return0
11+
12+
definit_system_clean(a,b):
13+
return0
14+
15+
definit_system_copy(a,b):
16+
return0
17+
18+
definstall_package(a,b):
19+
return0
20+
21+
definstall_package_live(a,b,c):
22+
return0
23+
24+
defpkg_list(a,b):
25+
return0
26+
27+
defpresets_helper(a,b):
28+
return0
29+
30+
defrefresh_helper(a):
31+
return0
32+
33+
defsnapshot_diff():
34+
return0
35+
36+
defuninstall_package_helper(a,b):
37+
return0
38+
39+
defupgrade_helper(a):
40+
return0
41+

‎src/distros/alpine/ashpk.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromsrc.ashpk_coreimport*
2+
13
# ---------------------------- SPECIFIC FUNCTIONS ---------------------------- #
24

35
# Noninteractive update

‎src/distros/arch/ashpk.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromsrc.ashpk_coreimport*
2+
13
# ---------------------------- SPECIFIC FUNCTIONS ---------------------------- #
24

35
# Check if AUR is setup right
@@ -147,15 +149,15 @@ def fix_package_db(snap = 0):
147149
# Delete init system files (Systemd, OpenRC, etc.)
148150
definit_system_clean(snap,FROM):
149151
ifFROM=="prepare":
150-
rmrf(f"/.snapshots/rootfs/snapshot-chr{snap}/var/lib/systemd","/*")
152+
rmrf_star(f"/.snapshots/rootfs/snapshot-chr{snap}/var/lib/systemd")
151153
elifFROM=="deploy":
152-
rmrf("/var/lib/systemd","/*")
153-
rmrf(f"/.snapshots/rootfs/snapshot-{snap}/var/lib/systemd/","/*")
154+
rmrf_star("/var/lib/systemd")
155+
rmrf_star(f"/.snapshots/rootfs/snapshot-{snap}/var/lib/systemd")
154156

155157
# Copy init system files (Systemd, OpenRC, etc.) to shared
156158
definit_system_copy(snap,FROM):
157159
ifFROM=="post_transactions":
158-
rmrf("/var/lib/systemd","/*")
160+
rmrf_star("/var/lib/systemd")
159161
os.system(f"cp -r --reflink=auto /.snapshots/rootfs/snapshot-{snap}/var/lib/systemd/. /var/lib/systemd/{DEBUG}")
160162

161163
# Install atomic-operation

‎src/distros/cachyos/ashpk.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromsrc.ashpk_coreimport*
2+
13
# ---------------------------- SPECIFIC FUNCTIONS ---------------------------- #
24

35
# Check if AUR is setup right
@@ -205,7 +207,7 @@ def install_package_live(snapshot, tmp, pkg):
205207
else:
206208
#ash_mounts(tmp) ### REVIEW If issues to have this in ashpk_core.py, uncomment this
207209
excode=os.system(f"chroot /.snapshots/rootfs/snapshot-{tmp} pacman -Sy --overwrite '*' --noconfirm{pkg}{DEBUG}")### REVIEW Maybe just do this in try section and remove else section!
208-
returnexcode
210+
returnexcode# type: ignore
209211

210212
# Get list of packages installed in a snapshot
211213
defpkg_list(CHR,snap):
@@ -222,7 +224,7 @@ def snapshot_diff(snap1, snap2):
222224
elifnotos.path.exists(f"/.snapshots/rootfs/snapshot-{snap2}"):
223225
print(f"Snapshot{snap2} not found.")
224226
else:
225-
os.system(f"bash -c\"diff <(ls /.snapshots/rootfs/snapshot-{snap1}/usr/share/ash/db/local) <(ls /.snapshots/rootfs/snapshot-{snap2}/usr/share/ash/db/local) | grep '^>\|^<' | sort\"")
227+
os.system(f"bash -c\"diff <(ls /.snapshots/rootfs/snapshot-{snap1}/usr/share/ash/db/local) <(ls /.snapshots/rootfs/snapshot-{snap2}/usr/share/ash/db/local) | grep '^>\\|^<' | sort\"")# before: '^>\|^<'
226228

227229
# Uninstall package(s) atomic-operation
228230
defuninstall_package_helper(snapshot,pkg):

‎src/distros/debian/ashpk.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromsrc.ashpk_coreimport*
2+
13
# ---------------------------- SPECIFIC FUNCTIONS ---------------------------- #
24

35
# Noninteractive update

‎src/distros/endeavouros/ashpk.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromsrc.ashpk_coreimport*
2+
13
# ---------------------------- SPECIFIC FUNCTIONS ---------------------------- #
24

35
# Check if AUR is setup right
@@ -205,7 +207,7 @@ def install_package_live(snapshot, tmp, pkg):
205207
else:
206208
#ash_mounts(tmp) ### REVIEW If issues to have this in ashpk_core.py, uncomment this
207209
excode=os.system(f"chroot /.snapshots/rootfs/snapshot-{tmp} pacman -Sy --overwrite '*' --noconfirm{pkg}{DEBUG}")### ERROR Sep 28, 2018 GPGME invalid crypto engine!!! ### REVIEW Maybe just do this in try section and remove else section!
208-
returnexcode
210+
returnexcode# type: ignore
209211

210212
# Get list of packages installed in a snapshot
211213
defpkg_list(CHR,snap):
@@ -222,7 +224,7 @@ def snapshot_diff(snap1, snap2):
222224
elifnotos.path.exists(f"/.snapshots/rootfs/snapshot-{snap2}"):
223225
print(f"Snapshot{snap2} not found.")
224226
else:
225-
os.system(f"bash -c\"diff <(ls /.snapshots/rootfs/snapshot-{snap1}/usr/share/ash/db/local) <(ls /.snapshots/rootfs/snapshot-{snap2}/usr/share/ash/db/local) | grep '^>\|^<' | sort\"")
227+
os.system(f"bash -c\"diff <(ls /.snapshots/rootfs/snapshot-{snap1}/usr/share/ash/db/local) <(ls /.snapshots/rootfs/snapshot-{snap2}/usr/share/ash/db/local) | grep '^>\\|^<' | sort\"")# before: '^>\|^<'
226228

227229
# Uninstall package(s) atomic-operation
228230
defuninstall_package_helper(snapshot,pkg):

‎src/distros/fedora/ashpk.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromsrc.ashpk_coreimport*
2+
13
# ---------------------------- SPECIFIC FUNCTIONS ---------------------------- #
24

35
# Noninteractive update

‎src/distros/kicksecure/ashpk.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromsrc.ashpk_coreimport*
2+
13
# ---------------------------- SPECIFIC FUNCTIONS ---------------------------- #
24

35
# Noninteractive update

‎src/distros/proxmox/ashpk.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromsrc.ashpk_coreimport*
2+
13
# ---------------------------- SPECIFIC FUNCTIONS ---------------------------- #
24

35
# Noninteractive update

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp