Skip to content

Commit

Permalink
v1.13 backport of #2205, fixes #2092 (Use debian existing package con…
Browse files Browse the repository at this point in the history
…f, not new conf) (#2207)

* Use debian existing package conf, not new conf, fixes #2092
* Improve TestExtraPackages as early warning for all PHP changes
* Backport circleci fix to pyenv global for pip3
* Make TestTimezoneConfig more robust for summertime CEST (#2136)
  • Loading branch information
rfay committed Apr 21, 2020
1 parent 611c9e0 commit 00994b9
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 33 deletions.
1 change: 1 addition & 0 deletions .circleci/linux_circle_vm_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ nvm use 10
npm install --global markdownlint-cli
markdownlint --version
# readthedocs has ancient version of mkdocs in it.
pyenv global 3.7.0 # added to make CircleCi give us pip3
pip3 install -q yq mkdocs==0.17.5

# Get the Stubs and Plugins for makensis; the linux makensis build doesn't do this.
Expand Down
2 changes: 1 addition & 1 deletion docs/users/extend/customizing-images.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ ADD README.txt /
Note that if a Dockerfile is provided, any config.yaml `webimage_extra_packages` or `dbimage_extra_packages` will be ignored. If you need to add packages as well as other custom configuration, add them to your Dockerfile with a line like

```
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confnew" --no-install-recommends --no-install-suggests php-yaml php7.3-ldap
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confold" --no-install-recommends --no-install-suggests php-yaml php7.3-ldap
```
2 changes: 1 addition & 1 deletion pkg/ddevapp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ RUN (groupadd --gid $gid "$username" || groupadd "$username" || true) && (userad
`
if extraPackages != nil {
contents = contents + `
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confnew" --no-install-recommends --no-install-suggests ` + strings.Join(extraPackages, " ") + "\n"
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confold" --no-install-recommends --no-install-suggests ` + strings.Join(extraPackages, " ") + "\n"
}
return WriteImageDockerfile(fullpath, []byte(contents))
}
Expand Down
70 changes: 40 additions & 30 deletions pkg/ddevapp/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"regexp"
"runtime"
"sort"
"strings"
Expand Down Expand Up @@ -749,7 +750,7 @@ func TestExtraPackages(t *testing.T) {
switchDir := site.Chdir()
defer switchDir()

runTime := util.TimeTrack(time.Now(), fmt.Sprintf("%s TestExtraPackages", site.Name))
runTime := util.TimeTrack(time.Now(), fmt.Sprintf("%s %s", site.Name, t.Name()))

err := app.Init(site.Dir)
assert.NoError(err)
Expand All @@ -761,13 +762,11 @@ func TestExtraPackages(t *testing.T) {
_, err = exec.RunCommand("bash", []string{"-c", command})
assert.NoError(err)

oldPHPVersion := app.PHPVersion
app.PHPVersion = "7.3"
defer func() {
_ = app.Stop(true, false)
app.WebImageExtraPackages = nil
app.DBImageExtraPackages = nil
app.PHPVersion = oldPHPVersion
app.PHPVersion = nodeps.PHPDefault
_ = app.WriteConfig()
_ = fileutil.RemoveContents(app.GetConfigPath("web-build"))
_ = fileutil.RemoveContents(app.GetConfigPath("db-build"))
Expand All @@ -780,39 +779,50 @@ func TestExtraPackages(t *testing.T) {
err = app.Start()
assert.NoError(err)

_, _, err = app.Exec(&ExecOpts{
Service: "web",
Cmd: "dpkg -s php7.3-gmp",
})
assert.Error(err)
assert.Contains(err.Error(), "exit status 1")

// Test db container to make sure no ncdu in there at beginning
_, _, err = app.Exec(&ExecOpts{
Service: "db",
Cmd: "command -v ncdu",
})
assert.Error(err)
assert.Contains(err.Error(), "exit status 1")

// Now add the packages and start again, they should be in there
app.WebImageExtraPackages = []string{"php7.3-gmp"}
app.DBImageExtraPackages = []string{"ncdu"}
err = app.Start()
assert.NoError(err)
for _, v := range nodeps.GetValidPHPVersions() {
t.Log("Testing extra packages with PHP" + v)
app.PHPVersion = v

stdout, stderr, err := app.Exec(&ExecOpts{
Service: "web",
Cmd: "dpkg -s php7.3-gmp",
})
assert.NoError(err, "dpkg -s php7.3-gmp failed", stdout, stderr)
// Start and make sure that the packages don't exist already
err = app.Start()
assert.NoError(err)

stdout, stderr, err = app.Exec(&ExecOpts{
Service: "web",
Cmd: "php -i | grep 'gmp support =. enabled'",
})
assert.NoError(err, "failed to grep for gmp support, stdout=%s, stderr=%s", stdout, stderr)
_, _, err = app.Exec(&ExecOpts{
Service: "web",
Cmd: "dpkg -s php" + v + "-ldap",
})
assert.Error(err)
assert.Contains(err.Error(), "exit status 1")

stdout, _, err = app.Exec(&ExecOpts{
// Now add the packages and start again, they should be in there
app.WebImageExtraPackages = []string{"php" + v + "-ldap"}
app.DBImageExtraPackages = []string{"ncdu"}
err = app.Start()
assert.NoError(err)

stdout, stderr, err := app.Exec(&ExecOpts{
Service: "web",
Cmd: "dpkg -s php" + v + "-ldap",
})
assert.NoError(err, "dpkg -s php"+v+"-ldap failed", stdout, stderr)

stdout, stderr, err = app.Exec(&ExecOpts{
Service: "web",
Cmd: "php -i | grep 'LDAP Support =. enabled'",
})
assert.NoError(err, "failed to grep for ldap support, stdout=%s, stderr=%s", stdout, stderr)

}

stdout, _, err := app.Exec(&ExecOpts{
Service: "db",
Cmd: "command -v ncdu",
})
Expand Down Expand Up @@ -868,15 +878,15 @@ func TestTimezoneConfig(t *testing.T) {
Cmd: "printf \"timezone=$(date +%Z)\n\" && php -r 'print \"phptz=\" . date_default_timezone_get();'",
})
assert.NoError(err)
assert.Equal("timezone=CET\nphptz=Europe/Paris", stdout)
assert.Regexp(regexp.MustCompile("timezone=CES?T\nphptz=Europe/Paris"), stdout)

// Make sure db container is also working with Dublin time/IST
// Make sure db container is also working with CET
stdout, _, err = app.Exec(&ExecOpts{
Service: "db",
Cmd: "echo -n timezone=$(date +%Z)",
})
assert.NoError(err)
assert.Equal("timezone=CET", stdout)
assert.Regexp(regexp.MustCompile("timezone=CES?T"), stdout)

runTime()
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/nodeps/values.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package nodeps

import "sort"

// Providers
const (
ProviderDrudS3 = "drud-s3"
Expand Down Expand Up @@ -183,7 +185,7 @@ func GetValidPHPVersions() []string {
for p := range ValidPHPVersions {
s = append(s, p)
}

sort.Strings(s)
return s
}

Expand Down

0 comments on commit 00994b9

Please sign in to comment.