-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update make_deb.py to work for Python2 or 3 (#47)
* Convert make_deb.py to Python2 + Python 3 * Pass environment to make_deb and other helpers so that Python expect UTF-8 IO * Handle argv correctly w.r.t PEP-383 * Test for python2 and python3.
- Loading branch information
Showing
6 changed files
with
125 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,29 @@ pkg_deb( | |
version = "test", | ||
) | ||
|
||
pkg_deb( | ||
name = "test-deb-py2", | ||
built_using = "some_test_data (0.1.2)", | ||
conffiles = [ | ||
"/etc/nsswitch.conf", | ||
"/etc/other", | ||
], | ||
config = ":testdata/config", | ||
data = ":test-tar-gz.tar.gz", | ||
depends = [ | ||
"dep1", | ||
"dep2", | ||
], | ||
description = "toto ®, Й, ק ,م, ๗, あ, 叶, 葉, 말, ü and é", | ||
distribution = "trusty", | ||
maintainer = "somé[email protected]", | ||
make_deb = "@rules_pkg//:make_deb_py2", | ||
package = "titi", | ||
templates = ":testdata/templates", | ||
urgency = "low", | ||
version = "test_py2", | ||
) | ||
|
||
[pkg_tar( | ||
name = "test-tar-%s" % ext[1:], | ||
srcs = [ | ||
|
@@ -191,6 +214,7 @@ sh_test( | |
data = [ | ||
"testenv.sh", | ||
":test-deb.deb", | ||
":test-deb-py2.deb", | ||
":test-tar-.tar", | ||
":test-tar-bz2.tar.bz2", | ||
":test-tar-empty_dirs.tar", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,22 +177,20 @@ drwxrwxrwx 0/0 0 2000-01-01 00:00 ./pmt/" \ | |
"$(get_tar_verbose_listing test-tar-mtime.tar)" | ||
} | ||
|
||
function test_deb() { | ||
if ! (which dpkg-deb); then | ||
echo "Unable to run test for debian, no dpkg-deb!" >&2 | ||
return 0 | ||
fi | ||
function check_deb() { | ||
package="$1" | ||
|
||
local listing="./ | ||
./etc/ | ||
./etc/nsswitch.conf | ||
./usr/ | ||
./usr/titi | ||
./usr/bin/ | ||
./usr/bin/java -> /path/to/bin/java" | ||
check_eq "$listing" "$(get_deb_listing test-deb.deb)" | ||
check_eq "-rwxr-xr-x" "$(get_deb_permission test-deb.deb ./usr/titi)" | ||
check_eq "-rw-r--r--" "$(get_deb_permission test-deb.deb ./etc/nsswitch.conf)" | ||
get_deb_description test-deb.deb >$TEST_log | ||
check_eq "$listing" "$(get_deb_listing ${package})" | ||
check_eq "-rwxr-xr-x" "$(get_deb_permission ${package} ./usr/titi)" | ||
check_eq "-rw-r--r--" "$(get_deb_permission ${package} ./etc/nsswitch.conf)" | ||
get_deb_description ${package} >$TEST_log | ||
expect_log "Description: toto ®, Й, ק ,م, ๗, あ, 叶, 葉, 말, ü and é" | ||
expect_log "Package: titi" | ||
expect_log "somé[email protected]" | ||
|
@@ -203,14 +201,14 @@ function test_deb() { | |
expect_log "Urgency: low" | ||
expect_log "Distribution: trusty" | ||
|
||
get_deb_ctl_file test-deb.deb templates >$TEST_log | ||
get_deb_ctl_file ${package} templates >$TEST_log | ||
expect_log "Template: titi/test" | ||
expect_log "Type: string" | ||
|
||
get_deb_ctl_file test-deb.deb config >$TEST_log | ||
get_deb_ctl_file ${package} config >$TEST_log | ||
expect_log "# test config file" | ||
|
||
if ! dpkg_deb_supports_ctrl_tarfile test-deb.deb ; then | ||
if ! dpkg_deb_supports_ctrl_tarfile ${package} ; then | ||
echo "Unable to test deb control files listing, too old dpkg-deb!" >&2 | ||
return 0 | ||
fi | ||
|
@@ -221,14 +219,23 @@ templates" | |
# TODO: The config and templates come out with a+x permissions. Because I am | ||
# currently seeing the same behavior in the Bazel sources, I am going to look | ||
# at root causes later. I am not sure if this is WAI or not. | ||
check_eq "$ctrl_listing" "$(get_deb_ctl_listing test-deb.deb)" | ||
check_eq "-rw-r--r--" "$(get_deb_ctl_permission test-deb.deb conffiles)" | ||
check_eq "-rwxr-xr-x" "$(get_deb_ctl_permission test-deb.deb config)" | ||
check_eq "-rw-r--r--" "$(get_deb_ctl_permission test-deb.deb control)" | ||
check_eq "-rwxr-xr-x" "$(get_deb_ctl_permission test-deb.deb templates)" | ||
check_eq "$ctrl_listing" "$(get_deb_ctl_listing ${package})" | ||
check_eq "-rw-r--r--" "$(get_deb_ctl_permission ${package} conffiles)" | ||
check_eq "-rwxr-xr-x" "$(get_deb_ctl_permission ${package} config)" | ||
check_eq "-rw-r--r--" "$(get_deb_ctl_permission ${package} control)" | ||
check_eq "-rwxr-xr-x" "$(get_deb_ctl_permission ${package} templates)" | ||
local conffiles="/etc/nsswitch.conf | ||
/etc/other" | ||
check_eq "$conffiles" "$(get_deb_ctl_file test-deb.deb conffiles)" | ||
check_eq "$conffiles" "$(get_deb_ctl_file ${package} conffiles)" | ||
} | ||
|
||
function test_deb() { | ||
if ! (which dpkg-deb); then | ||
echo "Unable to run test for debian, no dpkg-deb!" >&2 | ||
return 0 | ||
fi | ||
check_deb "test-deb.deb" | ||
check_deb "test-deb-py2.deb" | ||
} | ||
|
||
run_suite "build_test" |