f1055a46c6925853d84e2fc41861e3bc233f38ba — Rory Bradford 26 days ago
fixes and improvements
5 files changed, 24 insertions(+), 18 deletions(-)

M Makefile
M control
M ddb
A ddb.ini
D test.ini
M Makefile => Makefile +1 -1
@@ 3,7 3,7 @@ output = output
  
  deb: prepare
- 	./ddb test.ini $(name) $(output)
+ 	./ddb ddb.ini $(name) $(output)
  
  prepare:
  	mkdir -p $(prefix)

M control => control +1 -1
@@ 1,5 1,5 @@ Package: ddb
- Version: 1.0.0
+ Version: 1.0.1-1-{{release}}
  Depends: nini
  Maintainer: Rory Bradford <roryrjb@gmail.com>
  Architecture: all

M ddb => ddb +14 -8
@@ 51,17 51,20 @@ exit 1
      fi
  
+     name=$(nini "$config_file" config name)
      commands=$(nini "$config_file" commands command)
-     images=$(nini "$config_file" images name)
+     images=$(nini "$config_file" images _)
+     raw_version=$(grep -Po 'Version:(.*)' "$target_dir/DEBIAN/control" | sed 's/\s*Version\s*:\s*//i')
  
-     for image in $images; do
-         name="ddb-$image"
-         name="$(echo "$name" | sed s/:/_/)"
+     echo "$images" | while IFS=" = " read -r release image; do
          mkdir -p "$root/$name"
+         version=$(echo "$raw_version" | sed s/{{release}}/$release/)
  
          {
              echo "FROM $image"
              echo "ENV name $name"
+             echo "ENV release $release"
+             echo "ENV version $version"
          } > "$root/$name/Dockerfile"
  
          for command in "$commands"; do


@@ 73,15 76,18 @@ {
              echo "RUN mkdir /root/ddb"
              echo "COPY $target_dir /root/ddb/$name/"
+             echo "RUN sed -i s/{{release}}/$release/ /root/ddb/$name/DEBIAN/control"
              echo "WORKDIR /root/ddb"
              echo "RUN dpkg-deb --build $name"
              echo "ENTRYPOINT sleep 1"
          } >> "$root/$name/Dockerfile"
  
-         docker build -t "$name" "$root/$name/"
-         docker run --rm -d --name "$name" "$name"
-         docker cp "$name":/root/ddb/$name.deb "$output_dir"
-         docker stop "$name"
+         tag="ddb-$name-$release"
+ 
+         docker build -t "$tag" "$root/$name/"
+         docker run --rm -d --name "$tag" "$tag"
+         docker cp "$tag:/root/ddb/$name.deb" "$output_dir/$name-$release-$version.deb"
+         docker stop "$tag"
      done
  }
  

A ddb.ini => ddb.ini +8 -0
@@ 0,0 1,8 @@
+ [config]
+ name = ddb
+ 
+ [images]
+ xenial = ubuntu:16.04
+ bionic = ubuntu:18.04
+ stretch = debian:stretch
+ buster = debian:buster

D test.ini => test.ini +0 -8
@@ 1,8 0,0 @@-[images]
- name = ubuntu:16.04
- name = ubuntu:18.04
- name = debian:stretch
- name = debian:buster
- 
- [commands]
- command = RUN echo "building $name"