Codebase list dh-make-golang / d0f82f4
Import upstream version 0.4.0+git20210803.1.fe36d31 Debian Janitor 2 years ago
4 changed file(s) with 18 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
494494 }
495495 // Beginning newline in case the file already exists and lacks a newline
496496 // (not all editors enforce a newline at the end of the file):
497 if _, err := f.Write([]byte("\n.pc\n")); err != nil {
497 if _, err := f.Write([]byte("\n/.pc/\n/_build/\n")); err != nil {
498498 return dir, err
499499 }
500500 if err := f.Close(); err != nil {
506506 return dir, err
507507 }
508508
509 if err := runGitCommandIn(dir, "commit", "-m", "Ignore quilt dir .pc via .gitignore"); err != nil {
509 if err := runGitCommandIn(dir, "commit", "-m", "Ignore _build and quilt .pc dirs via .gitignore"); err != nil {
510510 return dir, err
511511 }
512512
513513 return dir, nil
514514 }
515515
516 // normalize program/source name into Debian standard[1]
517 // https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source
516 // normalize package name into Debian standard[1]
517 // https://www.debian.org/doc/debian-policy/ch-controlfields.html#source
518518 // Package names (both source and binary, see Package, Section 5.6.7) must
519519 // consist only of lower case letters (a-z), digits (0-9), plus (+) and minus
520520 // (-) signs, and periods (.). They must be at least two characters long and
521521 // must start with an alphanumeric character.
522 func normalizeDebianProgramName(str string) string {
522 func normalizeDebianPackageName(str string) string {
523523 lowerDigitPlusMinusDot := func(r rune) rune {
524524 switch {
525525 case r >= 'a' && r <= 'z' || '0' <= r && r <= '9':
553553 "git.sr.ht": "sourcehut",
554554 "github.com": "github",
555555 "gitlab.com": "gitlab",
556 "go.step.sm": "step",
556557 "go.uber.org": "uber",
557558 "go4.org": "go4",
558559 "gocloud.dev": "gocloud",
588589 parts := strings.Split(gopkg, "/")
589590
590591 if t == typeProgram || t == typeProgramLibrary {
591 return normalizeDebianProgramName(parts[len(parts)-1])
592 return normalizeDebianPackageName(parts[len(parts)-1])
592593 }
593594
594595 host, err := shortHostName(gopkg, allowUnknownHoster)
597598 }
598599 parts[0] = host
599600
600 for i := range parts {
601 if i == 0 {
602 continue
603 }
604
605 parts[i] = normalizeDebianProgramName(parts[i])
606 }
607
608 return strings.Trim("golang-"+strings.Join(parts, "-"), "-")
601 return normalizeDebianPackageName("golang-" + strings.Join(parts, "-"))
609602 }
610603
611604 func getDebianName() string {
1414
1515 func TestAcceptInput(t *testing.T) {
1616 for _, tt := range shortName {
17 in := normalizeDebianProgramName(tt.in)
17 in := normalizeDebianPackageName(tt.in)
1818 if in != tt.out {
1919 t.Errorf("userInput(%q) => %q, want %q", tt.in, in, tt.out)
2020 }
3434 {"7h_make*go+3*.@", "7h-makego+3."},
3535 }
3636
37 func TestNormalizeDebianProgramName(t *testing.T) {
37 func TestNormalizeDebianPackageName(t *testing.T) {
3838 for _, tt := range miscName {
39 s := normalizeDebianProgramName(tt.in)
39 s := normalizeDebianPackageName(tt.in)
4040 if s != tt.out {
41 t.Errorf("normalizeDebianProgramName(%q) => %q, want %q", tt.in, s, tt.out)
41 t.Errorf("normalizeDebianPackageName(%q) => %q, want %q", tt.in, s, tt.out)
4242 }
4343 }
4444 }
5151 {"github.com/Debian/dh-make-golang", typeProgram, "dh-make-golang"},
5252 {"github.com/Debian/DH-make-golang", typeGuess, "golang-github-debian-dh-make-golang"},
5353 {"github.com/Debian/dh_make_golang", typeGuess, "golang-github-debian-dh-make-golang"},
54 {"github.com/sean-/seed", typeGuess, "golang-github-sean--seed"},
55 {"git.sr.ht/~sircmpwn/getopt", typeGuess, "golang-sourcehut-sircmpwn-getopt"},
56 {"golang.org/x/term", typeLibrary, "golang-golang-x-term"},
5457 }
5558
5659 func TestDebianNameFromGopkg(t *testing.T) {
4242 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4343 See the License for the specific language governing permissions and
4444 limitations under the License.
45 .
45 Comment:
4646 On Debian systems, the complete text of the Apache version 2.0 license
4747 can be found in "/usr/share/common-licenses/Apache-2.0".
4848 `,
4949 "MPL-2.0": ` This Source Code Form is subject to the terms of the Mozilla Public
5050 License, v. 2.0. If a copy of the MPL was not distributed with this
5151 file, You can obtain one at http://mozilla.org/MPL/2.0/.
52 .
52 Comment:
5353 On Debian systems, the complete text of the MPL-2.0 license can be found
5454 in "/usr/share/common-licenses/MPL-2.0".
5555 `,
157157 sort.Strings(builddeps)
158158 fprintfControlField(f, "Build-Depends", builddeps)
159159
160 fmt.Fprintf(f, "Standards-Version: 4.5.0\n")
160 fmt.Fprintf(f, "Standards-Version: 4.5.1\n")
161161 fmt.Fprintf(f, "Vcs-Browser: https://salsa.debian.org/go-team/packages/%s\n", debsrc)
162162 fmt.Fprintf(f, "Vcs-Git: https://salsa.debian.org/go-team/packages/%s.git\n", debsrc)
163163 fmt.Fprintf(f, "Homepage: %s\n", getHomepageForGopkg(gopkg))