2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 09:32:21 +00:00

First pass at packaging imgutil

This commit is contained in:
Jarrod Johnson 2021-06-14 16:02:52 -04:00
parent ac2474f43e
commit cb4b8ab06f
3 changed files with 45 additions and 7 deletions

View File

@ -4,7 +4,7 @@ Release: 1
Summary: OS Deployment support for confluent
License: Apache2
URL: http://hpc.lenovo.com/
URL: https://hpc.lenovo.com/
Source0: confluent_osdeploy.tar.xz
BuildArch: noarch
Requires: confluent_ipxe mtools tar

View File

@ -0,0 +1,28 @@
Name: confluent_imgutil
Version: #VERSION#
Summary: Confluent OS imaging utility
License: Apache2
URL: https://hpc.lenovo.com/
Source: confluent_imgutil.tar.xz
BuildArch: noarch
BuildRoot: /tmp/
%description
Utility for generating, modifying, and packing confluent deployment
images for diskless boot.
%prep
%setup -n imgutil
%build
mkdir -p opt/confluent/lib/imgutil
mkdir -p opt/confluent/bin
mv imgutil opt/confluent/bin/
mv el8 opt/confluent/lib/imgutil/
%install
cp -a opt %{buildroot}/
%files
/opt/confluent/bin/imgutil
/opt/confluent/lib/imgutil

View File

@ -55,6 +55,14 @@ def create_yumconf(sourcedir):
yumconf.write('enabled=1\ngpgcheck=0\n\n')
return repodir
def get_mydir(oscategory):
mydir = os.path.dirname(__file__)
mycopy = os.path.join(mydir, oscategory)
gencopy = os.path.join('/opt/confluent/lib/imgutil', oscategory)
if os.path.exists(mycopy):
return mycopy
return gencopy
class ElHandler(object):
def __init__(self, name, version, arch):
self.name = name
@ -66,7 +74,7 @@ class ElHandler(object):
self.yumargs = []
def add_pkglists(self, profile='default'):
with open(os.path.join(os.path.dirname(__file__), 'el8/profiles/{}/pkglist'.format(profile)), 'r') as pkglist:
with open(os.path.join(get_mydir('el8'), 'profiles/{}/pkglist'.format(profile)), 'r') as pkglist:
pkgs = pkglist.read()
pkgs = pkgs.split()
self.yumargs.extend(pkgs)
@ -88,8 +96,8 @@ class ElHandler(object):
mkdirp(os.path.join(self.targpath, 'usr/lib/dracut/modules.d'))
mkdirp(os.path.join(self.targpath, 'etc/dracut.conf.d'))
open(os.path.join(self.targpath, 'etc/resolv.conf'),'w').close()
mydir = os.path.dirname(__file__)
dracutdir = os.path.join(mydir, 'el8/dracut')
mydir = get_mydir('el8')
dracutdir = os.path.join(mydir, 'dracut')
targdir = os.path.join(self.targpath, 'usr/lib/dracut/modules.d/97diskless')
shutil.copytree(dracutdir, targdir)
with open(os.path.join(self.targpath, 'etc/dracut.conf.d/diskless.conf'), 'w') as dracutconf:
@ -360,10 +368,12 @@ def pack_image(opts, args):
label = '{0} ({1}'.format(prettyname, 'Diskless Boot')
with open(os.path.join(outdir, 'profile.yaml'), 'w') as profile:
profile.write('label: {0}\nkernelargs: quiet # confluent_imagemethod=untethered|tethered\n')
os.symlink(
'/opt/confluent/lib/osdeploy/{}-diskless/initramfs/addons.cpio'.format(
oshandler.oscategory),
oscat = oshandler.oscategory
confdir = '/opt/confluent/lib/osdeploy/{}-diskless'.format(oscat)
os.symlink('{}/initramfs/addons.cpio'.format(confdir),
os.path.join(outdir, 'boot/initramfs/addons.cpio'))
if os.path.exists('{}/profiles/default'.format(confdir)):
shutil.copytree('{}/profiles/default', outdir)
try:
pwd.getpwnam('confluent')
subprocess.check_call(['chown', '-R', 'confluent', outdir])