Skip to content

Commit

Permalink
Merge pull request #128 from cubicdaiya/feature_add_freenginx_remove_…
Browse files Browse the repository at this point in the history
…tengine

add support for freenginx and remove support for tengine
  • Loading branch information
catatsuy authored Feb 24, 2024
2 parents 2019cc2 + 456feb2 commit bceac57
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 47 deletions.
1 change: 1 addition & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ jobs:
make
./nginx-build -c ./config/configure.example -m ./config/modules.json.example -d work -clear -pcre -zlib -openssl
./nginx-build -c ./config/configure.example -m ./config/modules.json.example -d work -clear -pcre -zlib -libressl
./nginx-build -c ./config/configure.example -m ./config/modules.json.example -d work -clear -freenginx -pcre -zlib -openssl
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

* [nginx](https://nginx.org/)
* [OpenResty](https://openresty.org/)
* [Tengine](https://tengine.taobao.org/)
* [freenginx](https://freenginx.org/)

## Installation

Expand Down Expand Up @@ -205,16 +205,12 @@ And there is the limitation for the support of OpenResty.
`nginx-build` does not allow to use OpenResty's unique configure options directly.
If you want to use OpenResty's unique configure option, [Configuration for building nginx](#configuration-for-building-nginx) is helpful.

## Build Tengine
## Build freenginx

`nginx-build` supports to build [Tengine](https://tengine.taobao.org/).
`nginx-build` supports to build [freenginx](https://freenginx.org/).

```bash
$ nginx-build -d work -tengine -openssl
$ nginx-build -d work -freenginx -openssl
```

If you don't install OpenSSL on your system, it is required to add the option `-openssl`.

There is the limitation for the support of [Tengine](https://tengine.taobao.org/).
`nginx-build` does not allow to use Tengine's unique configure options directly.
If you want to use Tengine's unique configure option, [Configuration for building nginx](#configuration-for-building-nginx) is helpful.
16 changes: 8 additions & 8 deletions builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var (
opensslVersionRe *regexp.Regexp
libresslVersionRe *regexp.Regexp
openrestyVersionRe *regexp.Regexp
tengineVersionRe *regexp.Regexp
freenginxVersionRe *regexp.Regexp
)

func init() {
Expand All @@ -35,7 +35,7 @@ func init() {
opensslVersionRe = regexp.MustCompile(`--with-openssl=.+/openssl-(\d+\.\d+\.\d+[a-z]*)`)
libresslVersionRe = regexp.MustCompile(`--with-openssl=.+/libressl-(\d+\.\d+\.\d+)`)
openrestyVersionRe = regexp.MustCompile(`nginx version: openresty/(\d+\.\d+\.\d+\.\d+)`)
tengineVersionRe = regexp.MustCompile(`Tengine version: Tengine/(\d+\.\d+\.\d+)`)
freenginxVersionRe = regexp.MustCompile(`freenginx version: freenginx/(\d+\.\d+\.\d+)`)
}

func (builder *Builder) name() string {
Expand All @@ -53,8 +53,8 @@ func (builder *Builder) name() string {
name = "zlib"
case ComponentOpenResty:
name = openresty.Name(builder.Version)
case ComponentTengine:
name = "tengine"
case ComponentFreenginx:
name = "freenginx"
default:
panic("invalid component")
}
Expand Down Expand Up @@ -137,8 +137,8 @@ func (builder *Builder) InstalledVersion() (string, error) {
versionRe = opensslVersionRe
case "libressl":
versionRe = libresslVersionRe
case "tengine":
versionRe = tengineVersionRe
case "freenginx":
versionRe = freenginxVersionRe
}

m := versionRe.FindSubmatch(result)
Expand All @@ -165,8 +165,8 @@ func MakeBuilder(component int, version string) Builder {
builder.DownloadURLPrefix = ZlibDownloadURLPrefix
case ComponentOpenResty:
builder.DownloadURLPrefix = OpenRestyDownloadURLPrefix
case ComponentTengine:
builder.DownloadURLPrefix = TengineDownloadURLPrefix
case ComponentFreenginx:
builder.DownloadURLPrefix = FreenginxDownloadURLPrefix
default:
panic("invalid component")
}
Expand Down
22 changes: 11 additions & 11 deletions builder/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func setupBuilders(t *testing.T) []Builder {
builders[ComponentLibreSSL] = MakeLibraryBuilder(ComponentLibreSSL, LibreSSLVersion, true)
builders[ComponentZlib] = MakeLibraryBuilder(ComponentZlib, ZlibVersion, false)
builders[ComponentOpenResty] = MakeBuilder(ComponentOpenResty, OpenRestyVersion)
builders[ComponentTengine] = MakeBuilder(ComponentTengine, TengineVersion)
builders[ComponentFreenginx] = MakeBuilder(ComponentFreenginx, FreenginxVersion)
return builders
}

Expand Down Expand Up @@ -49,8 +49,8 @@ func TestName(t *testing.T) {
want: "openresty",
},
{
got: builders[ComponentTengine].name(),
want: "tengine",
got: builders[ComponentFreenginx].name(),
want: "freenginx",
},
}

Expand Down Expand Up @@ -125,8 +125,8 @@ func TestDownloadURL(t *testing.T) {
want: fmt.Sprintf("%s/openresty-%s.tar.gz", OpenRestyDownloadURLPrefix, OpenRestyVersion),
},
{
got: builders[ComponentTengine].DownloadURL(),
want: fmt.Sprintf("%s/tengine-%s.tar.gz", TengineDownloadURLPrefix, TengineVersion),
got: builders[ComponentFreenginx].DownloadURL(),
want: fmt.Sprintf("%s/freenginx-%s.tar.gz", FreenginxDownloadURLPrefix, FreenginxVersion),
},
}

Expand Down Expand Up @@ -169,8 +169,8 @@ func TestSourcePath(t *testing.T) {
want: fmt.Sprintf("openresty-%s", OpenRestyVersion),
},
{
got: builders[ComponentTengine].SourcePath(),
want: fmt.Sprintf("tengine-%s", TengineVersion),
got: builders[ComponentFreenginx].SourcePath(),
want: fmt.Sprintf("freenginx-%s", FreenginxVersion),
},
}

Expand Down Expand Up @@ -213,8 +213,8 @@ func TestArchivePath(t *testing.T) {
want: fmt.Sprintf("openresty-%s.tar.gz", OpenRestyVersion),
},
{
got: builders[ComponentTengine].ArchivePath(),
want: fmt.Sprintf("tengine-%s.tar.gz", TengineVersion),
got: builders[ComponentFreenginx].ArchivePath(),
want: fmt.Sprintf("freenginx-%s.tar.gz", FreenginxVersion),
},
}

Expand Down Expand Up @@ -257,8 +257,8 @@ func TestLogPath(t *testing.T) {
want: fmt.Sprintf("openresty-%s.log", OpenRestyVersion),
},
{
got: builders[ComponentTengine].LogPath(),
want: fmt.Sprintf("tengine-%s.log", TengineVersion),
got: builders[ComponentFreenginx].LogPath(),
want: fmt.Sprintf("freenginx-%s.log", FreenginxVersion),
},
}

Expand Down
8 changes: 4 additions & 4 deletions builder/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ const (
OpenRestyDownloadURLPrefix = "https://openresty.org/download"
)

// tengine
// freenginx
const (
TengineVersion = "2.3.3"
TengineDownloadURLPrefix = "https://tengine.taobao.org/download"
FreenginxVersion = "1.25.4"
FreenginxDownloadURLPrefix = "https://freenginx.org/download"
)

// component enumerations
const (
ComponentNginx = iota
ComponentOpenResty
ComponentTengine
ComponentFreenginx
ComponentPcre
ComponentOpenSSL
ComponentLibreSSL
Expand Down
16 changes: 8 additions & 8 deletions nginx-build.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func main() {
versionPrint := nginxBuildOptions.Bools["version"].Enabled
versionsPrint := nginxBuildOptions.Bools["versions"].Enabled
openResty := nginxBuildOptions.Bools["openresty"].Enabled
tengine := nginxBuildOptions.Bools["tengine"].Enabled
freenginx := nginxBuildOptions.Bools["freenginx"].Enabled
configureOnly := nginxBuildOptions.Bools["configureonly"].Enabled
idempotent := nginxBuildOptions.Bools["idempotent"].Enabled
helpAll := nginxBuildOptions.Bools["help-all"].Enabled
Expand All @@ -132,7 +132,7 @@ func main() {
libreSSLVersion := nginxBuildOptions.Values["libresslversion"].Value
zlibVersion := nginxBuildOptions.Values["zlibversion"].Value
openRestyVersion := nginxBuildOptions.Values["openrestyversion"].Value
tengineVersion := nginxBuildOptions.Values["tengineversion"].Value
freenginxVersion := nginxBuildOptions.Values["freenginxversion"].Value
patchOption := nginxBuildOptions.Values["patch-opt"].Value

// Allow multiple flags for `--patch`
Expand Down Expand Up @@ -184,16 +184,16 @@ func main() {
command.VerboseEnabled = *verbose

var nginxBuilder builder.Builder
if *openResty && *tengine {
log.Fatal("select one between '-openresty' and '-tengine'.")
if *openResty && *freenginx {
log.Fatal("select one between '-openresty' and '-freenginx'.")
}
if *openSSLStatic && *libreSSLStatic {
log.Fatal("select one between '-openssl' and '-libressl'.")
}
if *openResty {
nginxBuilder = builder.MakeBuilder(builder.ComponentOpenResty, *openRestyVersion)
} else if *tengine {
nginxBuilder = builder.MakeBuilder(builder.ComponentTengine, *tengineVersion)
} else if *freenginx {
nginxBuilder = builder.MakeBuilder(builder.ComponentFreenginx, *freenginxVersion)
} else {
nginxBuilder = builder.MakeBuilder(builder.ComponentNginx, *version)
}
Expand Down Expand Up @@ -251,8 +251,8 @@ func main() {
var workDir string
if *openResty {
workDir = *workParentDir + "/openresty/" + *openRestyVersion
} else if *tengine {
workDir = *workParentDir + "/tengine/" + *tengineVersion
} else if *freenginx {
workDir = *workParentDir + "/freenginx/" + *freenginxVersion
} else {
workDir = *workParentDir + "/nginx/" + *version
}
Expand Down
10 changes: 5 additions & 5 deletions option.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func makeNginxBuildOptions() Options {
argsBool["openresty"] = OptionBool{
Desc: "download openresty instead of nginx",
}
argsBool["tengine"] = OptionBool{
Desc: "download tengine instead of nginx",
argsBool["freenginx"] = OptionBool{
Desc: "download freenginx instead of nginx",
}
argsBool["configureonly"] = OptionBool{
Desc: "configure nginx only not building",
Expand Down Expand Up @@ -119,9 +119,9 @@ func makeNginxBuildOptions() Options {
Desc: "openresty version",
Default: builder.OpenRestyVersion,
}
argsString["tengineversion"] = OptionValue{
Desc: "tengine version",
Default: builder.TengineVersion,
argsString["freenginxversion"] = OptionValue{
Desc: "freenginx version",
Default: builder.FreenginxVersion,
}
argsString["patch"] = OptionValue{
Desc: "patch path for applying to nginx",
Expand Down
6 changes: 3 additions & 3 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ func versionsGenOpenResty() []string {
}
}

func versionsGenTengine() []string {
func versionsGenFreenginx() []string {
return []string{
fmt.Sprintf("tengine-%s", builder.TengineVersion),
fmt.Sprintf("freenginx-%s", builder.FreenginxVersion),
}
}

func printNginxVersions() {
var versions []string
versions = append(versions, versionsGenNginx()...)
versions = append(versions, versionsGenOpenResty()...)
versions = append(versions, versionsGenTengine()...)
versions = append(versions, versionsGenFreenginx()...)
for _, v := range versions {
fmt.Println(v)
}
Expand Down

0 comments on commit bceac57

Please sign in to comment.