mirror of
https://github.com/clearlinux/common.git
synced 2026-06-16 19:16:00 +00:00
Compare commits
88 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c1e426713a | |||
| d9e4f478eb | |||
| 96b366e71f | |||
| 84097fd526 | |||
| c2cd51b5f2 | |||
| ed1ef58d9a | |||
| 497f2a66f4 | |||
| 3b8d3c66ea | |||
| 373cbad44c | |||
| 0fcc984675 | |||
| 78023bd74a | |||
| d2b5b72346 | |||
| 4953d9e087 | |||
| ee37765ed2 | |||
| 492abf6d32 | |||
| 2562a8c7fb | |||
| 5fd02ece36 | |||
| 039e63fb1e | |||
| dcf8bc4978 | |||
| 3951710117 | |||
| 504d77bc58 | |||
| d3514ae496 | |||
| 4403e9280a | |||
| 0aed61be35 | |||
| cdda6bcece | |||
| 61203724ab | |||
| 3dfbdf4c58 | |||
| e0e5b4b1a7 | |||
| b95dd8c67f | |||
| 8ed4d2d0de | |||
| 023a2da624 | |||
| cdd4aeebe2 | |||
| ee744332e0 | |||
| 353042a9bd | |||
| 1a0366ab21 | |||
| 4080b704f3 | |||
| 4626f673ca | |||
| 5121c565eb | |||
| a26aea0290 | |||
| 54a9f967c3 | |||
| 9153630dcb | |||
| d80039c90b | |||
| f5a3630590 | |||
| 75cb8bf424 | |||
| 2a586be1b3 | |||
| 93fccd1edf | |||
| 9527057e5e | |||
| f3500feb2d | |||
| 05598abd55 | |||
| 2b0163ef73 | |||
| 3f2b9100e6 | |||
| 1b841e095d | |||
| 579d79ef92 | |||
| d85dfaec30 | |||
| 8787caac84 | |||
| 181006f851 | |||
| 480917e514 | |||
| afab562778 | |||
| 21ae357eeb | |||
| b4989fae9b | |||
| 09d1f48a31 | |||
| 3a5cfb76c6 | |||
| 763c25ac43 | |||
| b97bc72f65 | |||
| 6af8cdfa99 | |||
| dd378bba6c | |||
| 4b63761b45 | |||
| 5882fa9b80 | |||
| 8c028f361d | |||
| 56dfe24b31 | |||
| 5f2827db17 | |||
| f3d664e694 | |||
| 088ab41319 | |||
| b2a39834c2 | |||
| b7184a56a8 | |||
| 976837dd36 | |||
| 6102ce39b8 | |||
| 4ed6de4b77 | |||
| 5af73631bd | |||
| 7a63c36293 | |||
| 442543a9aa | |||
| 43b28277c0 | |||
| c371f6a233 | |||
| 485815c4fe | |||
| ffd02240f4 | |||
| 69e4a64658 | |||
| 61a91af0ff | |||
| fc6b90aaa5 |
+12
-5
@@ -157,10 +157,6 @@ pullrebase:
|
||||
fi \
|
||||
fi
|
||||
|
||||
# help vendor: Attempt to create an updated vendor tar archive if needed
|
||||
vendor: preautospec-checks pullrebase clean-old-content
|
||||
@ $(TOPLVL)/projects/common/vendor.py $(firstword $(NEWURL) $(URL)) $(PKG_NAME) $(VND_BASE_URL)
|
||||
|
||||
preautospec-checks:
|
||||
|
||||
#help autospec: automatically generates a specfile. If there is
|
||||
@@ -174,8 +170,8 @@ autospec: preautospec-checks pullrebase localreponotice clean-old-content
|
||||
echo "Specfile already exists and was not created by autospec.py! Aborting."; \
|
||||
exit 1; \
|
||||
fi
|
||||
$(eval ARCHIVES = $(shell $(TOPLVL)/projects/common/vendor.py '$(value ARCHIVES)' $(firstword $(NEWURL) $(URL)) $(PKG_NAME) $(VND_BASE_URL)))
|
||||
@printf 'PKG_NAME := %s\nURL = %s\nARCHIVES = %s\n\ninclude ../common/Makefile.common\n' $(PKG_NAME) '$(firstword $(value NEWURL) $(value URL))' '$(value ARCHIVES)' > Makefile
|
||||
@$(MAKE) vendor
|
||||
python3 $(TOPLVL)/projects/autospec/autospec/autospec.py \
|
||||
--target . \
|
||||
--integrity \
|
||||
@@ -391,6 +387,17 @@ koji-waitrepo: kojidef
|
||||
koji wait-repo --build=${SRPMVERS} ${WAIT_OPTS} ${KOJI_TAG}-build; \
|
||||
fi
|
||||
|
||||
.PHONY: koji-tag
|
||||
#help koji-tag: runs koji tag-pkg on what's in the current specfile's nvr
|
||||
koji-tag:
|
||||
koji tag-pkg dist-clear $(SRPMVERS)
|
||||
|
||||
.PHONY: koji-untag
|
||||
#help koji-untag: runs koji untag-pkg on what's in the current specfile's nvr
|
||||
koji-untag:
|
||||
koji untag-pkg dist-clear $(SRPMVERS)
|
||||
|
||||
|
||||
update-versions:
|
||||
|
||||
.PHONY: update
|
||||
|
||||
+9
-3
@@ -126,11 +126,17 @@ endif
|
||||
pull: ${PULL_PKGS}
|
||||
|
||||
#help clean-pkgs-dir: For packages that are no longer present in the distro,
|
||||
#help removes the associated package repos from the ./packages tree
|
||||
#help removes the associated package repos from the ./packages tree and stores
|
||||
#help it in packages_old. If it already exists in packages_old, skip it.
|
||||
clean-pkgs-dir: $(PACKAGES_FILE)
|
||||
@for p in ${PKGS_ORPHANED}; do \
|
||||
echo "Removing $$p from packages, it is no longer in common/packages."; \
|
||||
rm -rf packages/$$p; \
|
||||
mkdir -p packages_old; \
|
||||
if [ -d "packages_old/$$p" ]; then \
|
||||
echo "packages_old/$$p already exists, not touching it"; \
|
||||
else \
|
||||
echo "Moving $$p from packages to packages_old, as it is no longer in common/packages."; \
|
||||
mv packages/$$p packages_old/$$p; \
|
||||
fi; \
|
||||
done
|
||||
@echo "packages directory cleaned";
|
||||
|
||||
|
||||
@@ -2,4 +2,3 @@
|
||||
/usr/lib/systemd/system/sysinit.target.wants/systemd-firstboot.service
|
||||
/usr/lib/systemd/system/sysinit.target.wants/systemd-hwdb-update.service
|
||||
/usr/lib/systemd/system/sysinit.target.wants/systemd-update-done.service
|
||||
/usr/lib/systemd/system/update-triggers.target.wants
|
||||
|
||||
+6
-2
@@ -98,9 +98,13 @@ def zap_entire_file_end(filename):
|
||||
global files
|
||||
global files_chunks
|
||||
global files_header
|
||||
files_to_remove = list()
|
||||
for file in files:
|
||||
if file.endswith(filename):
|
||||
files.remove(file)
|
||||
# Don't modify the original list while iterating over it
|
||||
files_to_remove.append(file)
|
||||
for file in files_to_remove:
|
||||
files.remove(file)
|
||||
|
||||
def zap_line_in_file_substring(filename, match):
|
||||
global header
|
||||
@@ -186,7 +190,7 @@ def zap_empty_chunks():
|
||||
files_to_remove = list()
|
||||
for file in files:
|
||||
if file not in files_chunks:
|
||||
files.remove(file)
|
||||
files_to_remove.append(file)
|
||||
continue
|
||||
to_remove = list()
|
||||
for chunk in files_chunks[file]:
|
||||
|
||||
@@ -30,6 +30,7 @@ def vendor_check():
|
||||
|
||||
def get_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('archives')
|
||||
parser.add_argument('url')
|
||||
parser.add_argument('name')
|
||||
parser.add_argument('git')
|
||||
@@ -44,7 +45,7 @@ def setup_content(url):
|
||||
with open(outfile, 'wb') as cfile:
|
||||
cfile.write(response.content)
|
||||
|
||||
subprocess.run(f"tar xf {outfile}", shell=True, cwd=tdir, check=True)
|
||||
subprocess.run(f"tar xf {outfile}", shell=True, cwd=tdir, check=True, stdout=subprocess.DEVNULL)
|
||||
os.remove(outfile)
|
||||
return tdir
|
||||
|
||||
@@ -60,61 +61,88 @@ def setup_cargo_vendor(path):
|
||||
def update_cargo_vendor(path, name, git):
|
||||
git_uri = os.path.join(git, name)
|
||||
vendor_path = os.path.join(path, 'vendor')
|
||||
subprocess.run(f"git clone {git_uri} {vendor_path}", shell=True, check=True)
|
||||
subprocess.run(f"git clone {git_uri} {vendor_path}", shell=True, check=True,
|
||||
stdout=subprocess.DEVNULL)
|
||||
vendor_git = os.path.join(vendor_path, '.git')
|
||||
if not os.path.isdir(vendor_git):
|
||||
# initialize a git repo
|
||||
subprocess.run('git init .', cwd=vendor_path, shell=True, check=True)
|
||||
subprocess.run('git init .', cwd=vendor_path, shell=True, check=True,
|
||||
stdout=subprocess.DEVNULL)
|
||||
subprocess.run(f"git remote add origin {git_uri}", cwd=vendor_path,
|
||||
shell=True, check=True)
|
||||
shell=True, check=True, stdout=subprocess.DEVNULL)
|
||||
backup_vendor_git = os.path.join(path, 'clear-linux-vendor-git')
|
||||
subprocess.run(f"cp -a {vendor_git} {backup_vendor_git}", cwd=path,
|
||||
shell=True, check=True)
|
||||
shell=True, check=True, stdout=subprocess.DEVNULL)
|
||||
shutil.rmtree(vendor_path)
|
||||
subprocess.run('cargo vendor', cwd=path, shell=True, check=True)
|
||||
subprocess.run('cargo vendor', cwd=path, shell=True, check=True,
|
||||
stdout=subprocess.DEVNULL)
|
||||
subprocess.run(f"cp -a {backup_vendor_git} {vendor_git}", cwd=path,
|
||||
shell=True, check=True)
|
||||
shell=True, check=True, stdout=subprocess.DEVNULL)
|
||||
repo = Repo(vendor_path)
|
||||
if not len(repo.untracked_files) > 0 or repo.is_dirty():
|
||||
if not (len(repo.untracked_files) > 0 or repo.is_dirty()):
|
||||
return False
|
||||
subprocess.run('git add .', cwd=vendor_path, shell=True, check=True)
|
||||
subprocess.run('git add .', cwd=vendor_path, shell=True, check=True,
|
||||
stdout=subprocess.DEVNULL)
|
||||
subprocess.run('git commit -m "vendor update"', cwd=vendor_path,
|
||||
shell=True, check=True)
|
||||
shell=True, check=True, stdout=subprocess.DEVNULL)
|
||||
gmt = time.gmtime()
|
||||
tag = f"{gmt.tm_year}-{gmt.tm_mon:02d}-{gmt.tm_mday:02d}-{gmt.tm_hour:02d}-{gmt.tm_min:02d}-{gmt.tm_sec:02d}"
|
||||
subprocess.run(f"git tag {tag}", cwd=vendor_path, shell=True,
|
||||
check=True)
|
||||
check=True, stdout=subprocess.DEVNULL)
|
||||
subprocess.run(f"git push origin main:main {tag}", cwd=vendor_path,
|
||||
shell=True, check=True)
|
||||
shell=True, check=True, stdout=subprocess.DEVNULL)
|
||||
time.sleep(30)
|
||||
return tag
|
||||
|
||||
|
||||
def update_cargo_sources(name, tag):
|
||||
makefile = []
|
||||
archive_match = os.path.join('$(CGIT_BASE_URL)', 'vendor', name,
|
||||
options = []
|
||||
archive_match = os.path.join(r'\$\(CGIT_BASE_URL\)', 'vendor', name,
|
||||
'snapshot', name)
|
||||
archive_replace = os.path.join('$(CGIT_BASE_URL)', 'vendor', name,
|
||||
'snapshot', name)
|
||||
with open('Makefile', encoding='utf8') as mfile:
|
||||
for line in mfile.readlines():
|
||||
if line.startswith('ARCHIVES'):
|
||||
if re.match(archive_match + '[a-zA-Z0-9_\-.]+\.tar\.xz', line):
|
||||
new_archives = re.sub(archive_match + '[a-zA-Z0-9_\-.]+\.tar\.xz',
|
||||
f"{archive_match}-{tag}.tar.xz\n", line)
|
||||
if re.search(archive_match + r'[a-zA-Z0-9_\-.]+\.tar\.xz', line):
|
||||
new_archives = re.sub(archive_match + r'[a-zA-Z0-9_\-.]+\.tar\.xz',
|
||||
f"{archive_replace}-{tag}.tar.xz", line)
|
||||
else:
|
||||
new_archives = f"ARCHIVES = {archive_match}-{tag}.tar.xz ./vendor\n"
|
||||
new_archives = f"{line[:-1]} {archive_replace}-{tag}.tar.xz ./vendor\n"
|
||||
print(new_archives.replace('ARCHIVES = ', '', 1))
|
||||
makefile.append(new_archives)
|
||||
else:
|
||||
makefile.append(line)
|
||||
with open('Makefile', 'w', encoding='utf8') as mfile:
|
||||
mfile.writelines(makefile)
|
||||
|
||||
archive_match = os.path.join('http://localhost', 'cgit', 'vendor', name,
|
||||
'snapshot', name)
|
||||
with open('options.conf', encoding='utf8') as ofile:
|
||||
for line in ofile.readlines():
|
||||
if line.startswith('archives'):
|
||||
if re.search(archive_match + r'[a-zA-Z0-9_\-.]+\.tar\.xz', line):
|
||||
new_archives = re.sub(archive_match + r'[a-zA-Z0-9_\-.]+\.tar\.xz',
|
||||
f"{archive_match}-{tag}.tar.xz", line)
|
||||
else:
|
||||
new_archives = f"{line[:-1]} {archive_match}-{tag}.tar.xz ./vendor\n"
|
||||
options.append(new_archives)
|
||||
else:
|
||||
options.append(line)
|
||||
with open('options.conf', 'w', encoding='utf8') as ofile:
|
||||
ofile.writelines(options)
|
||||
|
||||
|
||||
def main():
|
||||
updated = False
|
||||
args = get_args()
|
||||
|
||||
vtype = vendor_check()
|
||||
if not vtype:
|
||||
print(args.archives)
|
||||
return
|
||||
|
||||
args = get_args()
|
||||
tdir = setup_content(args.url)
|
||||
if vtype == 'cargo':
|
||||
vdir = setup_cargo_vendor(tdir)
|
||||
@@ -122,7 +150,11 @@ def main():
|
||||
tag = update_cargo_vendor(vdir, args.name, args.git)
|
||||
if tag:
|
||||
update_cargo_sources(args.name, tag)
|
||||
updated = True
|
||||
if not updated:
|
||||
print(args.archives)
|
||||
shutil.rmtree(tdir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user