Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

started adding ovz template patching...

  • Loading branch information...
commit 561fe7ee9e7f53b7b340a1eb6481023decdbe0b9 1 parent cd6b779
@JedMeister authored
Showing with 140 additions and 27 deletions.
  1. +57 −27 bin/tklpatch
  2. +46 −0 bin/tklpatch-extract-ovz
  3. +37 −0 bin/tklpatch-genovz
View
84 bin/tklpatch
@@ -1,5 +1,7 @@
#!/bin/bash -e
# Copyright (c) 2009 Alon Swartz <alon@turnkeylinux.org> - all rights reserved
+# Hacked by Jeremy Davis (aka JedMeister) <jedmeister@turnkeylinux.org
+# to enable it to patch OVZ templates too! :)
fatal() {
echo "fatal: $@" 1>&2
@@ -8,20 +10,25 @@ fatal() {
usage() {
cat<<EOF
-Syntax: $(basename $0) image.iso patch-dir|patch.tar.gz
-Patch ISO build of appliance by applying a patch.
+Syntax: $(basename $0) image.iso|template.tar.gz patch-dir|patch.tar.gz
+Patch ISO/OVZ build of appliance by applying a patch.
TKLPatch is a set of shell scripts which provide a simple way to customize and
extend any appliance in the TurnKey Linux virtual appliance library. It's
designed in the Unix tradition as a modular collection of simple sub-scripts.
-This is the top high level script, which calls:
+This is the top high level script, which calls (a=ISO, b=OVZ):
- 1) tklpatch-extract-iso
- Disassemble the ISO to extract its contents
+ 1a) tklpatch-extract-iso
+ Disassemble the ISO to extract its contents
- 1) cdroot: ISO filesystem - contains bootloader and compressed rootfs
- 2) rootfs: uncompressed root filesystem
+ 1) cdroot: ISO filesystem - contains bootloader and compressed rootfs
+ 2) rootfs: uncompressed root filesystem
+
+ 1b) tklpatch-extract-ovz
+ Extract the OVZ contents
+
+ 1) rootfs: uncompressed root filesystem
2) tklpatch-apply
Apply the patch to the root filesystem.
@@ -33,12 +40,17 @@ This is the top high level script, which calls:
overlay/ # overlay applied to root filesystem
conf # configuration script to execute in chroot (rootfs)
- 3) tklpatch-prepare-cdroot
+ 3a) tklpatch-prepare-cdroot
Prepare cdroot for ISO creation. This mainly compresses the extracted
root filesystem.
+
+ 3b) Not required...
- 4) tklpatch-geniso
- Generate an ISO from the cdroot.
+ 4a) tklpatch-geniso
+ Generate an ISO from the cdroot.
+
+ 4b) tklpatch-genovz
+ Generate an OVZ (tar.gz) template from the rootfs
Environment variables:
@@ -61,11 +73,11 @@ fi
[ "$(id -u)" != "0" ] && fatal "must be run as root"
-isofile=$1
+tklfile=$1
patch=$2
-if ! [ -f $isofile ]; then
- fatal "no such file '$isofile;"
+if ! [ -f $tklfile ]; then
+ fatal "no such file '$tklfile;"
fi
if ! [ -e $patch ]; then
@@ -74,18 +86,36 @@ fi
[ -n "$TKLPATCH_DEBUG" ] && set -x
-name="$(basename $isofile)"
-name="$(echo $name | sed 's/.iso$//')"
-
-rootfs=$name.rootfs
-cdroot=$name.cdroot
-
-tklpatch-extract-iso $isofile
-tklpatch-apply $rootfs $patch
-tklpatch-prepare-cdroot $rootfs $cdroot
-tklpatch-geniso $cdroot
-
-# delete temporary rootfs and cdroot unless TKLCONV_DEBUG
-[ -z "$TKLPATCH_DEBUG" ] && rm -rf $rootfs
-[ -z "$TKLPATCH_DEBUG" ] && rm -rf $cdroot
+name="$(basename $tklfile)"
+
+if [[ $tklfile == *.tar.gz ]]; then
+
+ name="$(echo $name | sed 's/.tar.gz$//')"
+
+ rootfs=$name.rootfs
+
+ tklpatch-extract-iovz $tklfile
+ tklpatch-apply $rootfs $patch
+ tklpatch-bundle $rootfs
+
+if [ $tklfile == *.iso ]; then
+
+ name="$(echo $name | sed 's/.iso$//')"
+
+ rootfs=$name.rootfs
+ cdroot=$name.cdroot
+
+ tklpatch-extract-iso $tklfile
+ tklpatch-apply $rootfs $patch
+ tklpatch-prepare-cdroot $rootfs $cdroot
+ tklpatch-geniso $cdroot
+
+ # delete temporary cdroot unless TKLCONV_DEBUG
+ [ -z "$TKLPATCH_DEBUG" ] && rm -rf $cdroot
+
+else
+ fatal "'$tklfile' is not an ISO or a TAR.GZ"
+fi
+# delete temporary rootfs unless TKLCONV_DEBUG
+[ -z "$TKLPATCH_DEBUG" ] && rm -rf $rootfs
View
46 bin/tklpatch-extract-ovz
@@ -0,0 +1,46 @@
+#!/bin/bash -e
+# Original Copyright (c) 2009 Alon Swartz <alon@turnkeylinux.org> - all rights reserved
+# Repurposed (ie hacked) by Jeremy Davis, aka JedMeister <jedmeister@turnkeylinux.org>
+# Depends: tar, gzip
+
+fatal() {
+ echo "fatal: $@" 1>&2
+ exit 1
+}
+
+usage() {
+cat<<EOF
+Syntax: $(basename $0) ovzfile.tar.gz
+Extract the OVZ (tar.gz) template.
+
+ rootfs: uncompressed root filesystem
+
+Environment variables:
+
+ TKLPATCH_DEBUG Turn on debugging. Increases verbosity.
+EOF
+ exit 1
+}
+
+if [[ "$#" != "1" ]]; then
+ usage
+fi
+
+[ "$(id -u)" != "0" ] && fatal "must be run as root"
+
+[ -n "$TKLPATCH_DEBUG" ] && set -x
+
+ovzfile=$1
+
+[ -f $ovzfile ] || fatal "no such file: $ovzfile"
+
+name="$(basename $ovzfile)"
+name="$(echo $name | sed 's/.tar.gz$//')"
+
+rootfs=$name.rootfs
+
+[ -d $rootfs ] && fatal "directory already exists: $rootfs"
+
+echo "# extracting root filesystem from OVZ template"
+mkdir $rootfs
+tar xfz $ovzfile -C $rootfs/
View
37 bin/tklpatch-genovz
@@ -0,0 +1,37 @@
+#!/bin/bash -e
+# Copyright (c) 2009 Alon Swartz <alon@turnkeylinux.org> - all rights reserved
+# Depends: tar, gzip
+
+fatal() {
+ echo "fatal: $@" 1>&2
+ exit 1
+}
+
+usage() {
+cat<<EOF
+Syntax: $(basename $0) patch-dir
+Bundles patch-dir into an easy to distribute tarball.
+
+Environment variables:
+
+ TKLPATCH_DEBUG Turn on debugging.
+EOF
+ exit 1
+}
+
+if [[ "$#" != "1" ]]; then
+ usage
+fi
+
+[ -n "$TKLPATCH_DEBUG" ] && set -x
+patch_dir=$1
+
+patch_tarball="$(basename $patch_dir)"
+patch_tarball="$patch_tarball.tar.gz"
+
+[ -d $patch_dir ] || fatal "no such directory: $patch_dir"
+[ -f $patch_tarball ] && fatal "file already exists: $patch_tarball"
+
+echo "# creating tarball $patch_tarball"
+tar -zcf $patch_tarball -C $(dirname $patch_dir) $(basename $patch_dir)
+tar -ztf $patch_tarball
Please sign in to comment.
Something went wrong with that request. Please try again.