Skip to content

Commit 618f796

Browse files
authored
Merge pull request #23 from swelljoe/remove-dzil
Remove dzil
2 parents 0bfd77a + f82fa5b commit 618f796

10 files changed

Lines changed: 283 additions & 56 deletions

File tree

.github/workflows/virtualmin.dev+virtualmin-config.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ env:
3535

3636
jobs:
3737
build-amd64:
38+
if: ${{ github.repository == 'virtualmin/Virtualmin-Config' && (github.event_name == 'release' || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && !contains(github.event.head_commit.message, '[no-build]'))) }}
3839
runs-on: ubuntu-latest
39-
if: ${{ github.event_name == 'release' || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && !contains(github.event.head_commit.message, '[no-build]')) }}
4040
env:
4141
TZ: Europe/Nicosia
4242
steps:
4343
- uses: actions/checkout@v4
44-
44+
4545
- uses: awalsh128/cache-apt-pkgs-action@latest
46-
with:
46+
with:
4747
packages: ${{ env.BUILD_DEPS }}
4848
version: 1.0
4949

@@ -64,10 +64,10 @@ jobs:
6464
RELEASE_TAG: ${{ github.event.release.tag_name }}
6565
MANUAL_VERSION: ${{ inputs.version }}
6666
run: |-
67-
67+
6868
# Fail on error
6969
set -euo pipefail
70-
70+
7171
# Bootstrap build
7272
source bootstrap.bash \
7373
$([[ "$IS_RELEASE" == "true" ]] && echo "--release" || echo "--testing") \
@@ -86,7 +86,7 @@ jobs:
8686
8787
# Set package section
8888
pkg_section=$([ "$IS_RELEASE" = "true" ] && echo admin || echo devel)
89-
89+
9090
# Set build base directory
9191
pkg_name="${{ env.PKG_NAME }}"
9292
destdirbase="$HOME/$pkg_name"
@@ -103,9 +103,9 @@ jobs:
103103
INSTALLBIN=/usr/bin \
104104
SITEPREFIX=/usr \
105105
PREFIX=/usr
106-
make
106+
make
107107
make DESTDIR=$destdirbase-deb install
108-
108+
109109
# Make for RPM
110110
make clean
111111
perl Makefile.PL \
@@ -119,7 +119,7 @@ jobs:
119119
INSTALLBIN=/usr/bin \
120120
SITEPREFIX=/usr \
121121
PREFIX=/usr
122-
make
122+
make
123123
make DESTDIR=$destdirbase-rpm install
124124
125125
# Create symlinks
@@ -150,7 +150,7 @@ jobs:
150150
--description "${{ env.PKG_DESC }}" \
151151
--summary "${{ env.PKG_SUMMARY }}" \
152152
--homepage "${{ env.PKG_HOMEPAGE }}"
153-
153+
154154
# Build RPM package
155155
build_native_package \
156156
--architectures noarch \
@@ -174,7 +174,7 @@ jobs:
174174
--description "${{ env.PKG_DESC }}" \
175175
--summary "${{ env.PKG_SUMMARY }}" \
176176
--homepage "${{ env.PKG_HOMEPAGE }}"
177-
177+
178178
# Upload and sign
179179
upload_list=("$ROOT_REPOS/"*)
180180
cloud_upload upload_list

Makefile.PL

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.014.
21
use strict;
32
use warnings;
43

README.pod

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,24 @@ git clone:
5454
make test
5555
make install
5656

57-
Or, use your system native package manager. The followin assumes you have all
57+
Or, use your system native package manager. The following assumes you have all
5858
of the packages needed to build native packages installed.
5959

6060
To build a dpkg for Debian/Ubuntu:
6161

6262
dpkg-buildpackage -b -rfakeroot -us -uc
6363

64+
Or use the helper script:
65+
66+
packaging/build-deb.sh
67+
6468
And, for CentOS/Fedora/RHEL/etc. RPM distributions:
6569

66-
dzil build # Creates a tarball
67-
cp Virtualmin-Config-*.tar.gz ~/rpmbuild/SOURCES
68-
rpmbuild -bb virtualmin-config.spec
70+
packaging/build-rpm.sh
71+
72+
To create a source tarball for distribution:
73+
74+
packaging/build-tarball.sh
6975

7076
=head1 ATTRIBUTES
7177

dist.ini

Lines changed: 0 additions & 39 deletions
This file was deleted.

packaging/build-deb.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
packaging_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
# shellcheck source=packaging/lib.sh
6+
source "$packaging_dir/lib.sh"
7+
8+
usage() {
9+
cat <<'USAGE'
10+
Usage: build-deb.sh [--output-dir DIR]
11+
12+
Options:
13+
--output-dir DIR Copy resulting artifacts to DIR
14+
USAGE
15+
}
16+
17+
out_dir="${OUT_DIR:-}"
18+
19+
while [[ $# -gt 0 ]]; do
20+
case "$1" in
21+
--output-dir)
22+
out_dir="$2"
23+
shift 2
24+
;;
25+
-h|--help)
26+
usage
27+
exit 0
28+
;;
29+
*)
30+
echo "Unknown argument: $1" >&2
31+
usage >&2
32+
exit 2
33+
;;
34+
esac
35+
done
36+
37+
version="$(get_version 2>/dev/null || true)"
38+
changelog_version=""
39+
40+
if command -v dpkg-parsechangelog >/dev/null 2>&1; then
41+
changelog_version="$(dpkg-parsechangelog -S Version 2>/dev/null || true)"
42+
else
43+
changelog_version="$(perl -ne 'if (/^\S+ \(([^)]+)\)/) {print $1; exit}' "$root_dir/debian/changelog")"
44+
fi
45+
46+
if [[ -n "$version" && -n "$changelog_version" && "$version" != "$changelog_version" ]]; then
47+
echo "Warning: dist.ini/Makefile.PL version ($version) differs from debian/changelog ($changelog_version)." >&2
48+
fi
49+
50+
cd "$root_dir"
51+
dpkg-buildpackage -us -uc -b
52+
53+
if [[ -n "$out_dir" ]]; then
54+
mkdir -p "$out_dir"
55+
pkg_name="virtualmin-config"
56+
find "$root_dir/.." -maxdepth 1 -type f \( \
57+
-name "${pkg_name}_*.deb" -o \
58+
-name "${pkg_name}_*.buildinfo" -o \
59+
-name "${pkg_name}_*.changes" \
60+
\) -exec cp -a {} "$out_dir/" \;
61+
printf '%s\n' "$out_dir"
62+
fi

packaging/build-rpm.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
packaging_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
# shellcheck source=packaging/lib.sh
6+
source "$packaging_dir/lib.sh"
7+
8+
usage() {
9+
cat <<'USAGE'
10+
Usage: build-rpm.sh [--version VERSION] [--rpmbuild-root DIR] [--output-dir DIR]
11+
12+
Options:
13+
--version VERSION Override detected version
14+
--rpmbuild-root DIR rpmbuild root (default: ./build/rpmbuild)
15+
--output-dir DIR Copy resulting RPMs to DIR
16+
USAGE
17+
}
18+
19+
out_dir="${OUT_DIR:-}"
20+
rpmbuild_root="${RPMBUILD_ROOT:-$root_dir/build/rpmbuild}"
21+
version="${VERSION:-}"
22+
23+
while [[ $# -gt 0 ]]; do
24+
case "$1" in
25+
--output-dir)
26+
out_dir="$2"
27+
shift 2
28+
;;
29+
--rpmbuild-root)
30+
rpmbuild_root="$2"
31+
shift 2
32+
;;
33+
--version)
34+
version="$2"
35+
shift 2
36+
;;
37+
-h|--help)
38+
usage
39+
exit 0
40+
;;
41+
*)
42+
echo "Unknown argument: $1" >&2
43+
usage >&2
44+
exit 2
45+
;;
46+
esac
47+
done
48+
49+
if [[ -z "$version" ]]; then
50+
version="$(get_version)" || {
51+
echo "Unable to determine version; set VERSION or --version." >&2
52+
exit 1
53+
}
54+
fi
55+
56+
mkdir -p "$rpmbuild_root"/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
57+
58+
"$packaging_dir/build-tarball.sh" --output-dir "$rpmbuild_root/SOURCES" --version "$version" >/dev/null
59+
60+
spec_in="$root_dir/virtualmin-config.spec"
61+
spec_out="$rpmbuild_root/SPECS/virtualmin-config.spec"
62+
63+
sed -E "s/^Version:[[:space:]]+.*/Version: $version/" "$spec_in" > "$spec_out"
64+
65+
rpmbuild -ba --define "_topdir $rpmbuild_root" "$spec_out"
66+
67+
if [[ -n "$out_dir" ]]; then
68+
mkdir -p "$out_dir"
69+
find "$rpmbuild_root/RPMS" "$rpmbuild_root/SRPMS" -type f -name '*.rpm' -exec cp -a {} "$out_dir/" \;
70+
printf '%s\n' "$out_dir"
71+
else
72+
printf '%s\n' "$rpmbuild_root"
73+
fi

packaging/build-tarball.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
packaging_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
# shellcheck source=packaging/lib.sh
6+
source "$packaging_dir/lib.sh"
7+
8+
usage() {
9+
cat <<'USAGE'
10+
Usage: build-tarball.sh [--version VERSION] [--output-dir DIR]
11+
12+
Options:
13+
--version VERSION Override detected version
14+
--output-dir DIR Output directory (default: ./dist)
15+
USAGE
16+
}
17+
18+
out_dir="${OUT_DIR:-}"
19+
version="${VERSION:-}"
20+
21+
while [[ $# -gt 0 ]]; do
22+
case "$1" in
23+
--output-dir)
24+
out_dir="$2"
25+
shift 2
26+
;;
27+
--version)
28+
version="$2"
29+
shift 2
30+
;;
31+
-h|--help)
32+
usage
33+
exit 0
34+
;;
35+
*)
36+
echo "Unknown argument: $1" >&2
37+
usage >&2
38+
exit 2
39+
;;
40+
esac
41+
done
42+
43+
if [[ -z "$version" ]]; then
44+
version="$(get_version)" || {
45+
echo "Unable to determine version; set VERSION or --version." >&2
46+
exit 1
47+
}
48+
fi
49+
50+
out_dir="${out_dir:-$root_dir/dist}"
51+
mkdir -p "$out_dir"
52+
53+
pkg_name="Virtualmin-Config"
54+
prefix="${pkg_name}-${version}"
55+
out_file="$out_dir/${prefix}.tar.gz"
56+
57+
if git -C "$root_dir" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
58+
git -C "$root_dir" archive --format=tar --prefix "${prefix}/" HEAD | gzip -n > "$out_file"
59+
else
60+
tar -C "$root_dir" -czf "$out_file" \
61+
--transform "s,^,${prefix}/," \
62+
--exclude="./dist" \
63+
--exclude="./build" \
64+
--exclude="./.git" \
65+
.
66+
fi
67+
68+
printf '%s\n' "$out_file"

packaging/lib.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
packaging_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4+
root_dir="$(cd "$packaging_dir/.." && pwd)"
5+
6+
get_version() {
7+
if [[ -n "${VERSION:-}" ]]; then
8+
printf '%s\n' "$VERSION"
9+
return 0
10+
fi
11+
12+
if [[ -f "$root_dir/Makefile.PL" ]]; then
13+
local v
14+
v="$(perl -ne 'if (/\bVERSION\s*=>\s*"([^"]+)"/) {print $1; exit}' "$root_dir/Makefile.PL")"
15+
if [[ -n "$v" ]]; then
16+
printf '%s\n' "$v"
17+
return 0
18+
fi
19+
fi
20+
21+
return 1
22+
}

0 commit comments

Comments
 (0)